Owner can add more tokens than MAX_TOKENS
in BasketFacet
#278
Labels
0 (Non-critical)
Code style, clarity, syntax, versioning, off-chain monitoring (events etc), exclude gas optimisation
bug
Something isn't working
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Handle
Czar102
Vulnerability details
Impact
In
BasketFacet::addToken(...)
, theMAX_TOKENS
check is done before possible reentrancy in thebalance(...)
function, which is done before adding the token tobs
.An owner can pass ownership to the contract, which adds contracts as tokens, whose
balanceOf(...)
function allows the attacker contract to calladdToken(...)
again. TheMAX_TOKENS
check then passes, because the first added token hasn't been added tobs
yet. Thus, an attacker owner can add any number of tokens, being constrained only by block gas limit and stack depth.Tools Used
Manual analysis
Recommended Mitigation Steps
Consider making the reentrant call a part of the first check in the function.
The text was updated successfully, but these errors were encountered: