AuraSpell#openPositionFarm uses incorrect join type for balancer
The AuraSpell contract uses an empty userData field for Balancer join requests, which decodes to join type 0 (INIT). This causes transactions to revert for already-initialized pools, preventing users from opening farm positions.
0x52 Follow with cuthalion0x
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/120
Found by
0x52, cuthalion0x
Summary
The JoinPoolRequest uses "" for userData meaning that it will decode into 0. This is problematic because join requests of type 0 are "init" type joins and will revert for pools that are already initialized.
Vulnerability Detail
https://etherscan.io/address/0x5c6ee304399dbdb9c8ef030ab642b10820db8f56#code#F24#L49
enum JoinKind { INIT, EXACT_TOKENS_IN_FOR_BPT_OUT, TOKEN_IN_FOR_EXACT_BPT_OUT }
We see above that enum JoinKind is INIT for 0 values.
https://etherscan.io/address/0x5c6ee304399dbdb9c8ef030ab642b10820db8f56#code#F24#L290
return _joinExactTokensInForBPTOut(balances, normalizedWeights, userData);
} else if (kind == JoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT) {
return _joinTokenInForExactBPTOut(balances, normalizedWeights, userData);
} else {
_revert(Errors.UNHANDLED_JOIN_KIND);
}
Here user data is decoded into join type and since it is "" it will decode to type 0 which will result in a revert.
Impact
Users will be unable to open any farm position on AuraSpell
Code Snippet
Tool used
Manual Review
Recommendation
Uses JoinKind = 1 for user data
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 incorrectly sets the join type to 0 (INIT) instead of 1 (EXACT_TOKENS_IN_FOR_BPT_OUT) when constructing the join request.
Impact
Users will be unable to open any farm position on AuraSpell.
What the attacker needed
None
The fix
The userData should be set to encode JoinKind = 1 (EXACT_TOKENS_IN_FOR_BPT_OUT) instead of an empty value.
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.
When interacting with a Balancer pool, the contract must specify the type of join operation. An empty value defaults to the 'init' type, which only works for new pools. Since the pool is already active, the transaction fails, and users cannot create farm positions.
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.