Spender can prevent operations to decrease its allowance and effectively spends all the granted allowance even though the owner was trying to remove the allowance. #361
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-145
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-09-centrifuge/blob/512e7a71ebd9ae76384f837204216f26380c9f91/src/token/ERC20.sol#L148-L159
Vulnerability details
Impact
Proof of Concept
If an owner wants to remove all the allowance from a spender using the
decreaseAllowance()
, it needs to send thesubtractedValue
set to the exact total allowance that the spender has been granted.Let's take as example: UserA (owner) grants 1000 allowance to UserB (spender), and after some time, the owner decides to remove all the allowance, so it sends a tx to remove 1000.
Tools Used
Manual Audit
Recommended Mitigation Steps
Allow the spender to remove all the allowance without needing to explicitly specify the remaining amount of allowance, when removing all the allowance send the max value of an uint256 to indicate that all the remaining allowance must be decreased to 0.
In this way, when owners want to reduce all the allowance, they won't need to explicitly specify the amount they want to reduce, instead, they just send the max value of uint256 and the code will automatically set the allowance of the specified spender to 0!
Assessed type
ERC20
The text was updated successfully, but these errors were encountered: