Function joinTokenSingle in SingleTokenJoin.sol and SingleTokenJoinV2.sol can be made to fail
The joinTokenSingle function in SingleTokenJoin.sol and SingleTokenJoinV2.sol compares the contract's token balance to the user's expected output amount and reverts if they are unequal. An attacker can send a small amount of the basket's token to the contract, causing all subsequent joinTokenSingle calls to fail with 'FAILED_OUTPUT_AMOUNT'.
Originally disclosed on Code4rena
Submitted by pmerkleplant, also found by certora, hyh, p4st13r4, pauliax, robee, and WatchPug
Impact
There’s a griefing attack vulnerability in the function joinTokenSingle in SingleTokenJoin.sol as well as SingleTokenJoinV2.sol which makes any user transaction fail with “FAILEDOUTPUTAMOUNT”.
Proof of Concept
The JoinTokenStruct argument for joinTokenSingle includes a field outputAmount to indicate the amount of tokens the user should receive after joining a basket (see line 135 and 130).
However, this amount is compared to the contract’s balance of the token and reverts if the amount is unequal.
If an attacker sends some amount of a basket’s token to the contract, every call to this function will fail as long as the output token equals the attacker’s token send.
Recommended Mitigation Steps
Refactor the require statement to expect at least the outputAmount of tokens, i.e. require(outputAmount >= _joinTokenStruct.outputAmount).
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 contract uses an exact equality check between its token balance and the user's expected output amount, instead of checking that the balance is at least the expected amount.
Impact
An attacker can block all joinTokenSingle transactions for a given output token by sending a small amount of that token to the contract, causing a denial of service for legitimate users.
What the attacker needed
Attacker can send tokens to the contract; victim uses joinTokenSingle with that token
The fix
The require statement should be changed to check that the contract's balance is at least the expected output amount, rather than exactly equal.
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 users join a basket by depositing tokens and receiving a specific amount back. The contract checks that its token balance exactly matches the expected output amount, so if someone else sends even a tiny amount of that token to the contract, the balance no longer matches and every user's transaction fails. This is a griefing attack: the attacker does not steal funds but blocks others from using the service.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.