Skip to content

Use of nonReentrant in Hub.sol is ineffective #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hats-bug-reporter bot opened this issue Sep 16, 2024 · 1 comment
Open

Use of nonReentrant in Hub.sol is ineffective #111

hats-bug-reporter bot opened this issue Sep 16, 2024 · 1 comment
Labels

Comments

@hats-bug-reporter
Copy link

Github username: --
Twitter username: --
Submission hash (on-chain): 0x573c78274f78b77bd666dc29eb3ad97ff8560d3a7d3b09d32760e5c32b073eb0
Severity: low

Description:
Description\

In Hub.sol, the operateFlowMatrix function is decorated with nonReentrant(0).

This makes it impossible to reenter the contract by calling operateFlowMatrix a second time. This is an important safeguard, as operateFlowMatrix can make calls to many external functions - specifically the ERC1155 callbacks

However, the protection is only partial, as the Hub.sol contract can still be re-entered during the execution operateFlowMatrix through all functions that are not decorated with the nonReentrant modifier, such as transfer, mint, burn, etc.

We do not see a particular attack here, but the nonReentrant modifier seems to be used here as a just-in-case safeguard, and is less effective than it could be.

Mitigation
Mark all public (state-changing) functions nonReentrant

We also note that the single argument in your nonReentrant implementation is ignored, and can be removed for clarity.

@benjaminbollen
Copy link

Thanks, this has been remarked but is a clear reformulation. The concern with adding more code is that Hub.sol has been on the compile size limit for a long time, and every opcode added needs to be balanced by other code removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant