pow() is missing check on input parameters with 0 value
The pow() function in LogExpMath.sol lacks checks for zero inputs, unlike the Balancer original. This omission might lead to unexpected results, though no specific attack is described.
Submitted by gpersoon
Impact
The contract LogExpMath.sol seems to be a fork of the balancer LogExpMath.sol contract. It is mostly similar, except for checks for x and y being 0 in the beginning of the function pow(), see below.
This omission might lead to unexpected results.
Proof of Concept
function pow(uint256 x, uint256 y) internal pure returns (uint256) {
unchecked {
_require(x < 2**255, Errors.X_OUT_OF_BOUNDS);
function pow(uint256 x, uint256 y) internal pure returns (uint256) {
if (y == 0) {
// We solve the 0^0 indetermination by making it equal one.
return uint256(ONE_18);
}
if (x == 0) {
return 0;
}
_require(x < 2**255, Errors.X_OUT_OF_BOUNDS);
Recommended Mitigation Steps
Check if the extra code of the balance contract is useful and if so add it.
realisation (Overlay) disputed:
Out of scope
I disagree with sponsor regarding scope. The Contracts section of the Contest Scope lists several contracts which rely on
contracts/libraries/FixedPoint.sol. This contract uses thepowfunction containing the issue described. The warden has not described an exact attack but has show a math issue, which can certainly lead to a hypothetical loss of funds. Medium severity is appropriate and sponsor should definitely fix this.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the developers removed the zero-input checks when forking the Balancer contract, assuming they were unnecessary.
Impact
The missing checks could lead to unexpected mathematical results, which might hypothetically cause loss of funds, but no concrete attack is demonstrated.
What the attacker needed
None
The fix
The extra zero-input checks from the Balancer contract should be added if they are useful.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is about a maths function in a smart contract that calculates powers. The original version from another project had special handling for when the base or exponent is zero, but this copy left that out. That could cause wrong calculations, but the report does not show how an attacker would exploit it.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.