Within the DSCEngine#_redeemCollateral(), there is no input validation to check whether or not the amount of collateral to be repaid (amountCollateral) would be less than or equal to the deposited-amount of collateral ( s_collateralDeposited[from][tokenCollateralAddress]).
If a user send more than the deposited-amount of collateral ( s_collateralDeposited[from][tokenCollateralAddress]) as the amount of collateral to be repaid (amountCollateral) when the user call the DSCEngine#redeemCollateral(), the excess amount of collateral would be stuck in the SC forever.
Within the DSCEngine#redeemCollateral(), the DSCEngine#_redeemCollateral() would be called like this:
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L188
Within the DSCEngine#_redeemCollateral(), the amount of collateral to be repaid (amountCollateral) would be deducted from the deposited-amount of collateral (s_collateralDeposited) like this:
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L285
Within the DSCEngine#_redeemCollateral() above, the amount of collateral to be repaid (amountCollateral) is supposed to be less than or equal to the deposited-amount of collateral ( s_collateralDeposited[from][tokenCollateralAddress]).
However, within the DSCEngine#_redeemCollateral() above, there is no input validation to check whether or not the amount of collateral to be repaid (amountCollateral) would be less than or equal to the deposited-amount of collateral ( s_collateralDeposited[from][tokenCollateralAddress]).
If a user send more than the deposited-amount of collateral ( s_collateralDeposited[from][tokenCollateralAddress]) as the amount of collateral to be repaid (amountCollateral) when the user call the DSCEngine#redeemCollateral(), the excess amount of collateral would be stuck in the SC forever.
If a user send more than the deposited-amount of collateral ( s_collateralDeposited[from][tokenCollateralAddress]) as the amount of collateral to be repaid (amountCollateral) when the user call the DSCEngine#redeemCollateral(), the excess amount of collateral would be stuck in the SC forever.
Foundry
Within the DSCEngine#_redeemCollateral(), consider adding an input validation to check whether or not the amount of collateral to be repaid (amountCollateral) would be less than or equal to the deposited-amount of collateral ( s_collateralDeposited[from][tokenCollateralAddress]).
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.