The RToken's _update function, which is called during all token operations, uses an outdated liquidity index from LendingPool when scaling amounts. Since the liquidity index only increases over time and is not updated during transfer operations, users sending tokens lose funds due to incorrect scaling calculations.
The core issue lies in the _update function of RToken, which handles all token operations including transfers. Let's examine the implementation:
The problem occurs because:
Every token operation (transfer,transferFrom, mint, burn) calls _update
_update scales the amount using getNormalizedIncome() which returns the current liquidityIndex:
For transfer operations, this index is outdated because:
No state update is triggered during transfers
The index only gets updated during lendingPool operations or directly triger that.
The liquidityIndex naturally increases over time with accrued interest
This means when a user transfer amount X , it uses an outdated index to scale the amount to transfer , thus sending more than intended by the user
User transfer 100 tokens:
current outdated index = 1.5
actual index should be = 1.6 (after accrued interest)
The scaled amount sent = 100/1.5 = 66.67 scaled tokens
When it should be = 100/1.6 = 62.5 scaled tokens
the user here actually sent (66.67 * 1.6 = 106.67 )to receiver while he intended to send him only 100.
this is direct loss of the sender funds.
Note: This primarily affects transfer operations (transfer , transferFrom). Mint and burn operations are safe because they are called through the LendingPool, which updates the index state before calling them often.
i'm using foundry for test , to integrate foundry :
run :
add this to hardhat.config.cjs :
run :
comment the test/unit/libraries/ReserveLibraryMock.sol as it's causing compiling errors
inside test folder , create new dir foundry and inside it , create new file baseTest.sol , and copy/paste this there :
now create a pocs.sol inside test/foundry , and copy/paste this there :
The following test demonstrates how the outdated index in _update causes users to lose funds during transfers and transfer an amount that is more than intended:
Running this test shows:
Users performing transfers lose funds due to sending more scaled tokens than intended
The loss increases the longer the index hasn't been updated
Every transfer operation is affected, making this a systematic issue
Direct economic impact on users
Manual Review
Foundry
Update state before transfers:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.