Funds can be stolen using the `Helpers::scaleAmount` function.
When scaling the amount
provided with the Helpers::scaleAmount
function, the user may receive more funds than they are supposed to. In this line uint256 scaleFactor = 10 ** (18 - decimals)
, if decimals
is greater than 18
, the function will not revert because of the unchecked
keyword. Instead of reverting, it will return an incorrect uint256
number instead of the negative number and continue execution with this incorrect number:
For example: Suppose we call scaleAmount with:
amount = 5
decimals = 20
Here’s what happens:
Calculation of Exponent: 18 - 20 = -2
, so scaleFactor = 10 ** -2
.
Overflow Occurs: Solidity doesn’t support negative exponents in integer operations, so it interprets 10 ** -2
incorrectly, resulting in an extremely large number due to underflow in the exponentiation operation.
Incorrect Scale Factor: The overflowed scaleFactor
will hold a large, incorrect value, potentially leading to further overflow if we calculate amount * scaleFactor
. If scaleFactor
overflows to something like 2^256 - 1
, multiplying it by amount
will also overflow.
Loss of funds: Attackers might exploit an underflow if they can influence the input values, leading to unexpected or excessive tokens.
Unexpected Reverts or Errors: If the overflowed scaleFactor
is used in calculations, it may produce nonsensical results or cause reverts in later calculations, especially when multiplied by another large number.
Possibly DOS
Manual analysis.
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.