Skip to content
Smart contracts Audit finding Advanced

Scaled-share rounding mismatch breaks transfer and withdraw accounting

The router validates transfers and withdrawals using the nominal underlying amount or a rounded balance view, while the token contract settles in scaled shares with upward rounding, so the actual balance change can differ from what was checked. An attacker could move more collateral than the health-factor check accounts for, or withdraw more underlying than their scaled balance supports.

v12 Follow with 0xc0ffEE, akhilmanga and 9 others

Originally disclosed on Code4rena

Submitted by v12, also found by 0xc0ffEE, akhilmanga, bunnyhunter, DemoreX, Kalogerone, Nyx, oziajibogu, Petrus, qed, smchuzza, and wuji

Found by V12

  • contracts/kinetic-router/src/validation.rs #L228
  • contracts/a-token/src/contract.rs #L254
  • contracts/kinetic-router/src/router.rs #L1840
  • contracts/kinetic-router/src/operations.rs #L132
  • contracts/a-token/src/contract.rs #L579
  • contracts/a-token/src/balance.rs #L26

Targets

  • KineticRouter::validateusercan_withdraw
  • AToken::burn_scaled
  • KineticRouter::validateandfinalize_transfer
  • KineticRouter::withdraw
  • ATokenContract::transfer_internal
  • AToken::balanceofwith_index

Affected Locations

  • KineticRouter.validateusercan_withdraw: Health-factor validation subtracts collateral using the requested underlying amount, even though the transfer path can move a larger effective balance once scaled-share rounding is applied.
  • AToken.burn_scaled: Withdrawal settlement burns capped scaled balances, so the actual state change can be smaller than the underlying amount the router pays out unless the amount is recomputed afterward.
  • KineticRouter.validateandfinalize_transfer: This transfer finalization path forwards the nominal transfer amount into validation instead of reconciling against the rounded scaled-share amount actually consumed by the token contract.
  • KineticRouter.withdraw: Withdrawals use the rounded underlying view returned by the token balance helper as if it were safely spendable, including the max-withdraw path.
  • ATokenContract.transfer_internal: Token transfers settle in scaled units with upward division, so the real balance reduction can exceed the nominal underlying amount checked by the router.
  • AToken.balanceofwith_index: This helper exposes a half-up rounded underlying balance, which the router later treats as an exact spendable amount.

Description

The router and aToken logic do not agree on what amount is actually being moved when balances are represented in scaled shares and converted back to underlying with rounding. In the transfer path, validate_user_can_withdraw and validate_and_finalize_transfer validate only the caller-supplied underlying amount, while transfer_internal can reduce the sender’s real collateral by more once rounded scaled shares are applied. In the withdrawal path, withdraw trusts the half-up rounded value from balance_of_with_index, but burn_scaled settles against capped scaled balances and may burn less than that rounded amount implies. Because the router does not derive the final underlying delta from the scaled amount actually transferred or burned, it can both under-check health factor on collateral exits and overpay reserve assets on withdraw. The common fix is to make transfer and withdrawal flows reconcile on the exact scaled-share movement first, then compute the corresponding underlying amount used for validation and payout with non-overpaying rounding.

Root Cause

Underlying-denominated checks and payouts are derived from rounded balance views or user input instead of from the exact scaled-share amount actually transferred or burned in transfer_internal and burn_scaled.

Impact

A borrower can move out more collateral value than the health-factor check accounts for, leaving a debt position undercollateralized and pushing losses onto the protocol if liquidation cannot cover the shortfall. Separately, withdrawers can collect rounded-up dust from shared reserve liquidity by receiving more underlying than their capped scaled balance supports. Together these mismatches enable conditional pool value extraction and creation of bad debt.

Proof of Concept

See this gist for full Proof of Concept


The original report as published on Code4rena, by v12. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

Underlying-denominated checks and payouts are derived from rounded balance views or user input instead of from the exact scaled-share amount actually transferred or burned.

Impact

A borrower could move out more collateral value than the health-factor check accounts for, leaving a debt position undercollateralized, and withdrawers could collect rounded-up dust from shared reserve liquidity.

What the attacker needed

A borrower or withdrawer position; scaled-share rounding mismatch present

The fix

Transfer and withdrawal flows should reconcile on the exact scaled-share movement first, then compute the corresponding underlying amount for validation and payout with non-overpaying rounding.

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 token can store balances as 'scaled shares' that are converted back to a normal amount with rounding. The router checks one number but the token contract actually moves a slightly different number, so the safety check can be wrong. This lets someone take out a bit more value than they should.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by v12

View all

37 more disclosed reports, best first.

More from K2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.