The incentive contracts are not compatible with rebasing/deflationary/inflationary tokens
The incentive contracts cache token balances and reward amounts, so when a rebasing token changes the contract's balance, functions like clawback and drawRaffle can revert or operate on outdated information. This can cause a denial of service for the owner and participants.
0xNirix Follow with 0xbranded, 0xdeadbeef and 5 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-06-boost-aa-wallet-judging/issues/460
The protocol has acknowledged this issue.
Found by
0xNirix, 0xbranded, 0xdeadbeef, Atharv, ZanyBonzy, denzi_, ge6a, haxagon
Summary
The protocol wants to work with all kind of tokens including rebasing tokens. From weirdERC20 we can read more about Balance Modfications Outisde of Transfers (rebasing/airdrops) section which states
Some tokens may make arbitrary balance modifications outside of transfers (e.g. Ampleforth style rebasing tokens, Compound style airdrops of governance tokens, mintable/burnable tokens).
Some smart contract systems cache token balances (e.g. Balancer, Uniswap-V2), and arbitrary modifications to underlying balances can mean that the contract is operating with outdated information.
Vulnerability Detail
One such example of not supporting in the code is the ERC20Incentive::clawback() function
function clawback(bytes calldata data_) external override onlyOwner returns (bool) {
ClawbackPayload memory claim_ = abi.decode(data_, (ClawbackPayload));
(uint256 amount) = abi.decode(claim_.data, (uint256));
if (strategy == Strategy.RAFFLE) {
// Ensure the amount is the full reward and there are no raffle entries, then reset the limit
if (amount != reward || claims > 0) revert BoostError.ClaimFailed(msg.sender, abi.encode(claim_));
limit = 0;
} else {
// Ensure the amount is a multiple of the reward and reduce the max claims accordingly
if (amount % reward != 0) revert BoostError.ClaimFailed(msg.sender, abi.encode(claim_));
limit -= amount / reward;
}
The variable reward is being used in these if conditions, reward is set during initialization of the contract. It is either set as the full amount for raffles or the amount of reward per person for pools.
Lets consider the raffle situation for this report.
In the initialize() function, suppose that the reward amount in the data is sent as 10e18, this is set as reward for the raffle after confirming by checking the balance of the contract.
Now suppose after some time the balance has changed due to rebasing. The reward variable is still 10e18 but the actual balance of the contract is different.
In the clawback() function, the owner wants to withdraw the full amount of the raffle. If they provide the rebased balance of the contract, the function will revert due to the following if condition
if (amount != reward || claims > 0) revert BoostError.ClaimFailed(msg.sender, abi.encode(claim_));
If they provide 10e18 as amount which was the original amount and the current balance of the contract is lower then the following line will cause a revert
asset.safeTransfer(claim_.target, amount);
This is only one instance of an issue, these issues are present in the Incentive contracts which use ERC20s.
Similarly ERC20Incentive::drawRaffle() will also not work if the actual balance of the contract has changed to a lower amount.
Impact
The balances are outdated and will cause hindrances for all parties involved. Denial of Service when the balances rebase.
Code Snippet
Tool used
Manual Review
Recommendation
Track the balances after each transfer in/out to keep updated data in the contracts.
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 contracts store the reward amount and assume the contract's token balance stays constant, without updating for rebasing or other balance changes.
Impact
The owner cannot withdraw the full reward and the raffle cannot be drawn, causing a denial of service when the token balance changes.
What the attacker needed
The incentive uses a rebasing token; The token balance changes after initialisation
The fix
The contracts should track the actual token balance after each transfer in and out to keep the stored data up to date.
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.
Some tokens automatically change how many tokens every holder has, without anyone sending or receiving tokens. The smart contracts in this report remember the old amount, so when they try to use the new amount, their checks fail and the action stops working.
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.