code-423n4 / 2024-05-munchables-validation

0 stars 0 forks source link

`LockManager` does not handle tokens that do not revert on failure #610

Open c4-bot-8 opened 6 months ago

c4-bot-8 commented 6 months ago

Lines of code

https://github.com/code-423n4/2024-05-munchables/blob/57dff486c3cd905f21b330c2157fe23da2a4807d/src/managers/LockManager.sol#L373-L380 https://github.com/code-423n4/2024-05-munchables/blob/57dff486c3cd905f21b330c2157fe23da2a4807d/src/managers/LockManager.sol#L421-L424

Vulnerability details

Impact

This can lead to

Per the audit documentation tokens that do not revert on failure are in the scope of this audit.

Proof of Concept

Some ERC20 Tokens do not revert on failure of the transfer function, but return a bool value instead. Some do not return any value. Therefore it is required to check if a value was returned, and if true, which value it is. This is not done on some places in these contracts.

When players lock their tokens with lock(...) function the player’s lockedToken.quantity is updated to include the amount tokens that the player entered.

However, if the the tokenContract is a token that does not revert on failure,

File: LockManager.sol
373:         // Transfer erc tokens
374:         if (_tokenContract != address(0)) { // normal ERC not ETH
375:             IERC20 token = IERC20(_tokenContract);
376:  @>         token.transferFrom(_tokenOwner, address(this), _quantity);
377:         }
...
379:         lockedToken.remainder = remainder;
380:         lockedToken.quantity += _quantity;

Tools Used

Manual review

Recommended Mitigation Steps

Assessed type

Token-Transfer