Smart contracts should protect against reentrancy attacks where external contracts can call back into the contract during execution to manipulate state.
The contract lacks explicit reentrancy guards and relies only on SafeERC20, which may not be sufficient protection against malicious tokens with hooks or callback mechanisms.
Likelihood:
When malicious ERC20 tokens with transfer hooks are added to the allowlist
When tokens implement callbacks or notifications on transfer
When users interact with contracts that have fallback functions
Impact:
Malicious tokens could reenter functions and manipulate order state
Multiple orders could be created or modified in a single transaction
Contract state could become inconsistent leading to fund loss
Reentrancy Attack Vector: This demonstrates how a malicious token can exploit the lack of reentrancy protection to manipulate order state.
Attack Flow:
Attacker deploys malicious ERC20 token with transfer hook
Owner unknowingly adds malicious token to allowlist
Attacker creates initial order with malicious token
During amendSellOrder
, malicious token's transfer hook is triggered
Hook calls back into amendSellOrder
again, potentially with different parameters
Order state becomes inconsistent due to nested modifications
Attack could drain funds or manipulate order parameters maliciously
Real-world risks:
ERC777 tokens have built-in transfer hooks
Some deflationary tokens have complex transfer logic
Upgradeable tokens could add hooks in future versions
Solution: Add OpenZeppelin's ReentrancyGuard to all functions that interact with external tokens.
Why this works:
ReentrancyGuard: Uses a simple state variable to prevent nested calls
Gas efficient: Only 2,300 gas overhead per protected function call
Battle-tested: Used by thousands of protocols, well-audited by OpenZeppelin
Comprehensive protection: Prevents both cross-function and same-function reentrancy
Alternative/Additional protections:
Checks-Effects-Interactions pattern: Modify state before external calls (already needed for H-01)
Token allowlist vetting: Carefully audit tokens before adding to allowlist
Pull payment pattern: Let users withdraw funds rather than pushing payments
Function-specific guards: Custom reentrancy protection for specific functions if needed
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.