Open code423n4 opened 3 years ago
0xRajeev
_prepareWithdraw() and _prepareWithdrawOnBehalf() emit FundsWithdrawn event but their @dev Natspec comments say this:
@dev It emits a FundsWithdrawn event if the amount of withdrawn ether is greater than 0.
FundsWithdrawn
However, this event is emitted before the greater-than 0 check performed by the callers of these functions.
https://github.com/maple-labs/maple-token/blob/dda1b2018e89d684323b14ce7b9226c9c00e4ffa/contracts/ERC2222.sol#L59-L72
https://github.com/maple-labs/maple-token/blob/dda1b2018e89d684323b14ce7b9226c9c00e4ffa/contracts/ERC2222.sol#L74-L87
Callers which perform the greater-than 0 check after the call to above functions (which already would have emitted the event):
https://github.com/maple-labs/maple-token/blob/dda1b2018e89d684323b14ce7b9226c9c00e4ffa/contracts/ERC2222.sol#L177-L188
https://github.com/maple-labs/maple-token/blob/dda1b2018e89d684323b14ce7b9226c9c00e4ffa/contracts/ERC2222.sol#L190-L201
Manual Analysis
Change comment or event emission location to match each other.
Duplicate of #96
Handle
0xRajeev
Vulnerability details
Impact
_prepareWithdraw() and _prepareWithdrawOnBehalf() emit FundsWithdrawn event but their @dev Natspec comments say this:
@dev It emits a
FundsWithdrawn
event if the amount of withdrawn ether is greater than 0.However, this event is emitted before the greater-than 0 check performed by the callers of these functions.
Proof of Concept
https://github.com/maple-labs/maple-token/blob/dda1b2018e89d684323b14ce7b9226c9c00e4ffa/contracts/ERC2222.sol#L59-L72
https://github.com/maple-labs/maple-token/blob/dda1b2018e89d684323b14ce7b9226c9c00e4ffa/contracts/ERC2222.sol#L74-L87
Callers which perform the greater-than 0 check after the call to above functions (which already would have emitted the event):
https://github.com/maple-labs/maple-token/blob/dda1b2018e89d684323b14ce7b9226c9c00e4ffa/contracts/ERC2222.sol#L177-L188
https://github.com/maple-labs/maple-token/blob/dda1b2018e89d684323b14ce7b9226c9c00e4ffa/contracts/ERC2222.sol#L190-L201
Tools Used
Manual Analysis
Recommended Mitigation Steps
Change comment or event emission location to match each other.