Fee-on-transfer check can be avoided #119
Labels
1 (Low Risk)
Assets are not at risk. State handling, function incorrect as to spec, issues with comments
bug
Something isn't working
disagree with severity
Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments)
duplicate
This issue or pull request already exists
Handle
harleythedog
Vulnerability details
Impact
In
Exchange.sol
, there is a check inaddLiquidity
to see if thebase
token is a fee-on-transfer token (and it reverts if it is, since this is not supported and would break a lot of the internal accounting):This check can easily be avoided by transferring 1 wei of the base token to the contract before supplying the initial liquidity. This would create an exchange with a fee-on-transfer base token, which is not desirable and new users might interact with these exchanges, not knowing that the exchange logic will not work correctly and thus should not be interacted with.
Proof of Concept
See referenced code here.
Tools Used
Inspection.
Recommended Mitigation Steps
Instead of checking if
balanceOf
is 0, the contract should check that the internalBalance is 0. So I recommend changing line 123/124 to be:This way, there is no way of supplying initial liquidity an exchange that has fee-on-transfer tokens as the base token.
The text was updated successfully, but these errors were encountered: