Possible incentive theft through the arbitraryCall() function
The arbitraryCall function could be used to pre-approve a token allowance for a malicious recipient before any incentive was created. Once a user provided that token as an incentive, the malicious recipient could transfer the tokens out.
Originally disclosed on Code4rena
Submitted by toastedsteaksandwich, also found by Omik, ScopeLift, bitbopper, pedroais, gzeon, Meta0xNull, and wuwe1
Impact
The Locke.arbitraryCall() function allows the inherited governance contract to perform arbitrary contract calls within certain constraints. Contract calls to tokens provided as incentives through the createIncentive() function are not allowed if there is some still some balance according to the incentives mapping (See line 735 referenced below).
However, the token can still be called prior any user creating an incentive, so it’s possible for the arbitraryCall() function to be used to set an allowance on an incentive token before the contract has actually received any of the token through createIncentive().
In summary:
- If some possible incentive tokens are known prior to being provided, the
arbitraryCall()function can be used to pre-approve a token allowance for a malicious recipient. - Once a user calls
createIncentive()and provides one of the pre-approved tokens, the malicious recipient can calltransferFromon the provided incentive token and withdraw the tokens.
Proof of Concept
https://github.com/code-423n4/2021-11-streaming/blob/main/Streaming/src/Locke.sol#L735
Recommended Mitigation Steps
Recommendation 1
Limit the types of incentive tokens so it can be checked that it’s not the target contract for the arbitraryCall().
Recommendation 2
Validate that the allowance of the target contract (if available) has not changed.
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 check that prevents arbitrary calls to incentive tokens only applies when an incentive balance exists, so allowances can be set before any incentive is created.
Impact
A malicious recipient could steal incentive tokens provided by users.
What the attacker needed
Knowledge of possible incentive tokens; ability to call arbitraryCall(); a user creates an incentive with the token
The fix
The contract should limit the types of incentive tokens or validate that the allowance of the target contract has not changed.
How it was found
- Identify possible incentive tokens in advance.
- Use arbitraryCall() to pre-approve a token allowance for a malicious recipient.
- Wait for a user to call createIncentive() with the pre-approved token.
- The malicious recipient calls transferFrom to withdraw the incentive tokens.
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 lets a governance function make arbitrary calls to other contracts. The contract tried to block calls to incentive tokens only after an incentive existed, but an attacker could set an allowance before any incentive was created. Then, when a user deposited that token as an incentive, the attacker could take it.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.