15,000 USDC
View results
Submission Details
Severity: gas

Underflows not handled properly

Summary

Currently, the protocol login allows everyone to call redeemCollateral and burnDsc and because of that in certain conditions, underflow can occur.

Vulnerability Details

If a user who has 0 collateral deposited and respectively dsc minted or wants to redeem more than he has and calls redeemCollateral or burnDsc will lead to underflow on these lines:

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/DSCEngine.sol#L285
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/DSCEngine.sol#L273

Impact

No impact. It will lead to unexpected reverts in the user interface.

Tools Used

Manual

Recommendations

Add some type of checking at the beginning of the functions to verify the amount which user gives as an argument to redeem collateral or burn dsc should be lower or equal to his amounts in the two mappings which are used.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.