CalculateBPT doesnt divide by basis points infl
The calculateBPT function in FluxToken.sol multiplies the amount by bptMultiplier without dividing by the basis points constant, inflating the result by 10000x. An attacker could claim far more FLUX than intended and use it to boost bribe payments unfairly.
- Disclosed after under an hour
31478 - [SC - High] calculateBPT doesnt divide by basis points infl...
Submitted on May 20th 2024 at 05:03:00 UTC by @Holterhus for Boost | Alchemix
Report ID: #31478
Report type: Smart Contract
Report severity: High
Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/FluxToken.sol
Impacts:
- Theft of unclaimed royalties
Description
Brief/Intro
The calculateBPT() function in FluxToken.sol (which is used when claiming FLUX for NFT holders) inflates the result by 10000x, as it doesn't divide by basis points.
Vulnerability Details
bptMultiplier sets the ratio of FLUX that patron NFT holders receive. It is intended to set the value to 0.4% by setting it to 40 and dividing by BPS.
/// @notice The ratio of FLUX patron NFT holders receive (.4%)
uint256 public bptMultiplier = 40;
However, when BPT is calculated, we never divide by BPS:
function calculateBPT(uint256 _amount) public view returns (uint256 bptOut) {
bptOut = _amount * bptMultiplier;
}
Impact Details
This function is used when calculating the amount of FLUX that is claimable for NFT holders. The result is that this value will be inflated by 10000x, so 10000x more FLUX will be claimed than should be. This excess FLUX can be used for boosting bribe payments in an unfair manner (since the user should not have as much boosting ability as they receive).
References
FluxToken.sol
Proof of Concept
The following test can be added to FluxToken.t.sol. It should return 0.4% of amount, which would equal 40, but instead returns 400_000.
function test_InflatedBPT() external {
uint256 amount = 10_000;
uint256 bptCalculation = flux.calculateBPT(amount);
assertEq(bptCalculation, 400_000);
}
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
The calculateBPT function multiplies the amount by bptMultiplier but omits division by the basis points constant (BPS), so the result is 10000x too large.
Impact
The inflated FLUX could be claimed and used to boost bribe payments unfairly, as the user would have more boosting power than intended.
What the attacker needed
None
How it was found
- Call calculateBPT with an amount of 10,000.
- Observe that the returned value is 400,000 instead of the expected 40.
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.
A smart contract function that calculates a reward forgot to divide by a scaling factor, so it pays out 10,000 times too much. Someone could claim that inflated reward and use it to unfairly influence a voting or bribe system.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.