Skip to content

Precision Loss Attack in Compound Forks

Description

In Compound forks, a precision loss attack is possible if redeemAmount is taken from the arguments of redeemFresh() when there is a market with totalSupply = 0 and collateralFactor != 0.

Examples

Insecure Code

solidity
function redeemFresh(...) internal {
  redeemAmount = redeemAmountIn;
  ...
}

Secure Code

solidity
function redeemFresh(...) internal {
  require(redeemAmountIn > 0, "Invalid redeem amount");
  redeemAmount = redeemAmountIn;
  ...
}

Remediation

Validate and sanitize the redeemAmount before using it in the redeemFresh() function to prevent precision loss attacks.

Rule Details

FieldValue
IDCODE-0471
CategoryCrypto
SeverityCRITICAL
CWECWE-1339
ConfidenceHIGH
ImpactHIGH
LikelihoodHIGH
ExploitabilityMODERATE
Tagsprecision loss, compound forks, redeemFresh
OWASPN/A

References