arbitraryCall() can get blocked by an attacker
The arbitraryCall() function, used by governance to claim airdrops, is blocked if the token address has been used as an incentive, because a require statement reverts when incentives[who] is non-zero. An attacker can send a small incentive to that token address, preventing the airdrop claim until the stream ends and the incentive is cleared.
Originally disclosed on Code4rena
Submitted by GiveMeTestEther, also found by ScopeLift
Impact
arbitraryCall()’s (L733) use case is to claim airdrops by “gov”. If the address “who” is a token that could be send as an incentive by an attacker via createIncentive() then such claim can be made unusable, because on L735 there is a require(incentives\[who] == 0, "inc"); that reverts if a “who” token was received as an incentive.
In this case the the incentives\[who] can be set to 0 by the stream creator by calling claimIncentive() but only after the stream has ended according to require(block.timestamp >= endStream, "stream"); (L520)
If the airdrop is only claimable before the end of the stream, then the airdrop can never be claimed.
If “gov” is not the stream creator then the stream creator must become also the “gov” because claimIncentive() only can be called by the stream creator and the arbitraryCall() only by “gov”. If resetting incentives\[who] to 0 by calling claimIncentive() and arbitraryCall() for the “who” address doesn’t happen atomic, an attacker can send between those two calls again a “who” token.
Proof of Concept
- https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L733
- https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L500
Recommended Mitigation Steps
- Best option at the moment I can think of is to accept the risk but clearly communicate to users that this can happen
brockelmore (Streaming Protocol) acknowledged:
Yep this is the tradeoff being made. To maintain trustlessness, we cannot remove the
incentives[who] == 0check. Additionally, governance shouldn’t be in charge of an arbitrary stream’srecoverTokensfunction.The upshot of this is most
MerkleDropcontracts are generally external of the token itself and not baked into the ERC20 itself. If a user wants to grief governance, they could continuouslycreateIncentiveafter the stream creator claims the previous. But it does cost the user.
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 arbitraryCall() function includes a require statement that reverts if the target token address has a non-zero incentive balance, and an attacker can set that balance by creating an incentive.
Impact
An attacker could block governance from claiming an airdrop if the airdrop is only claimable before the stream ends, but the attack costs the attacker and the stream creator can clear the incentive after the stream ends.
What the attacker needed
Attacker can call createIncentive(); governance uses arbitraryCall() for airdrop; airdrop claim window before stream end
The fix
The team acknowledged the risk as a tradeoff and recommended communicating it to users; no code fix was applied.
How it was found
- Attacker calls createIncentive() with the token address that governance wants to use for an airdrop claim.
- This sets incentives[who] to a non-zero value.
- Governance calls arbitraryCall() for that token address, but the require(incentives[who] == 0) check fails and the call reverts.
- The incentive can only be cleared by the stream creator calling claimIncentive() after the stream ends, so the airdrop claim is blocked until then.
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 smart contract has a function for the project's governance to claim airdrops. But that function checks that a certain token address has not been used as an incentive. An attacker can send a tiny amount of that token as an incentive, which makes the check fail and blocks the airdrop claim.
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.