Scoop ERC20 tokens from basket contract
The settleAuction function allows an attacker to specify any output token, including unrelated ERC20 tokens that may have been sent to the basket contract by mistake or airdrop. An attacker can call bondForRebalance and settleAuction to transfer those tokens to themselves.
Submitted by gpersoon
Impact
Suppose some unrelated ERC20 tokens end up in the basket contract (via an airdrop, a user mistake etc)
Then anyone can do a bondForRebalance() and settleAuction() to scoop these tokens.
The function settleAuction() allows you to specify an outputToken, so also completely unrelated tokens. Thus you can retrieve additional tokens with settleAuction()
Proof of Concept
https://github.com/code-423n4/2021-09-defiProtocol/blob/main/contracts/contracts/Auction.sol#L69 function settleAuction(.. address[] memory outputTokens, uint256[] memory outputWeights) public override { … for (uint256 i = 0; i < outputTokens.length; i++) { IERC20(outputTokens[i]).safeTransferFrom(address(basket), msg.sender, outputWeights[i]); }
Recommended Mitigation Steps
Check outputTokens are part of the previous basket tokens (e.g. basket.tokens() )
frank-beard (Kuiper) acknowledged
Alex the Entreprenerd (judge) commented:
If the Auction contract has any ERC20 that is not checked against the require, those tokens can be taken away for free. The warden didn’t directly mention this, but this can also apply to bounties. Any bounty specified in a token that is not protected can be taken without claiming the bounty (as the require won’t check for it)
I think that the finding has appropriate severity, although the warden didn’t directly mention the ability to steal bounties
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 settleAuction function does not validate that the outputTokens are among the basket's expected tokens.
Impact
Anyone could steal unrelated ERC20 tokens that end up in the basket contract, including tokens sent by mistake or as bounties.
What the attacker needed
Unrelated ERC20 tokens present in basket contract
The fix
The settleAuction function should check that each outputToken is part of the basket's token list.
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 holds tokens for trading. Normally, only the tokens it expects should be withdrawable. But the withdrawal function lets the caller name any token, so if someone accidentally sends a different token to the contract, anyone can 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.