Protocol fee is significantly overcharged upon liquidations
The liquidation code calculates the protocol fee from the debt being repaid rather than from the collateral bonus, contradicting the code's own comment and the intended design. This overcharges the protocol fee, since the debt to cover is usually much larger than the collateral bonus.
samuraii77 Follow with aestheticbhai, Chimajax and 5 others
Originally disclosed on Code4rena
Submitted by samuraii77, also found by aestheticbhai, Chimajax, Joseph_Nwodoh, oxwhite, snufflesrea, TheWeb3Mechanic, and WhiteKnightK
contracts/kinetic-router/src/liquidation.rs#L350-L358
Upon liquidations, we compute protocol fee as follows:
// Calculate protocol fee from liquidation premium.
// Fee is taken from collateral bonus (not debt repayment) to maintain proper accounting.
let protocol_fee_bps = storage::get_flash_loan_premium(env);
let (protocol_fee_collateral, liquidator_collateral) = if protocol_fee_bps == 0 {
(0u128, collateral_amount_to_transfer)
} else {
// M-07: Round UP to favor protocol
let protocol_fee_debt = percent_mul_up(debt_to_cover, protocol_fee_bps)?;
The comment there clearly states:
// Fee is taken from collateral bonus (not debt repayment) to maintain proper accounting.
However, as seen, the code does:
let protocol_fee_debt = percent_mul_up(debt_to_cover, protocol_fee_bps)?;
The protocol fee is taken exactly from the debt repayment and not from the collateral bonus, the opposite of what they are saying. If we reference that to Aave, they correctly take it from the collateral bonus as it should be:
vars.liquidationProtocolFee = vars.bonusCollateral.percentMul(
vars.liquidationProtocolFeePercentage
);
This significantly overcharges the fees, against the developer’s intent, as the debt to cover is usually significantly higher than the collateral bonus.
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 fee is computed with the debt amount as the base instead of the collateral bonus, contrary to the stated intent in the comment.
Impact
The protocol fee is significantly overcharged on liquidations, taking more from the liquidation than the developers intended.
What the attacker needed
A liquidation occurs
The fix
The fee should be calculated from the collateral bonus, as the comment and the Aave reference describe, rather than from the debt to cover.
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 a borrower is liquidated, the liquidator repays some debt and receives a bonus in collateral as a reward. The protocol also takes a small cut, and the design says this cut should come from that bonus. Instead the code takes the cut from the much larger debt amount, so the fee is far bigger than intended.
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.