The Checks-Effects-Interactions (CEI) pattern is a well-established defense against reentrancy. It ensures that all internal state is updated before making external calls. The function amendSellOrder()
interacts with user-provided ERC-20 tokens before state updates.
While reentrancy is here mitigated by the use of ERC-20
whitelisting tokens, the current implementation does not strictly follow CEI for the function amendSellOrder
, leaving room for a potential edge-case exploit, especially if a malicious ERC-20 token (with a callback function in transfer) or an ERC-777 tokens (compatible with ERC-20 but add a callback function) is inadvertently whitelisted.
Likelihood: Low
Occurs if a malicious or poorly designed token is added to allowedSellToken
(e.g., ERC-777 or tokens with non-standard behavior like hooks or deflation).
Requires a token to exploit safeTransfer
or safeTransferFrom
to call back into the contract and perform reentrant logic before the contract finishes state updates.
Impact: Low to Moderate
Could allow reentrant execution of amendSellOrder()
or buyOrder()
in edge cases, such as updating the same order multiple times before it’s finalized.
In the worst-case scenario, could result in inconsistent order state or duplicate transfers.
A malicious token is added to the allowedSellToken
mapping by governance or accident.
An attacker creates a sell order using the malicious token.
When someone calls buyOrder()
to fulfill that order, the token's transfer()
or transferFrom()
triggers a tokensReceived()
hook.
Inside that hook, the attacker calls amendSellOrder()
or another method on the contract.
Because state changes happen after some external calls (or between them), the attacker can re-enter the same function or related ones with inconsistent state. If another seller has also performed a sell order of this token, the attacker can use amend
to perform several transfers and take the amount of token put by the another seller.
Strictly apply the Checks-Effects-Interactions pattern in amendSellOrder
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.