Funds might remain locked in `BalancerRouter` when depositing in Balancer pool
The BalancerRouter contract transfers the maximum amount of assets from the user but does not check how much is actually deposited into the Balancer pool, leaving leftover assets locked in the contract. An attacker could cause users to lose funds because the remaining assets are not returned.
0xShahilHussain Follow with 0xadrii, Adotsam and 9 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/841
Found by
0xShahilHussain, 0xadrii, Adotsam, Albort, KupiaSec, ZeroTrust, bretzel, dobrevaleri, elolpuer, novaman33, shushu, sl1
Summary
Not checking how much of the deposited assets are actually deposited in the pool, will lead to loss of funds for the user, because the remaining assets will be locked inside the BalancerRouter.
Root Cause
BalancerRouter provides an integration with Balancer V2 pools via the joinBalancerPool(), which is used by joinBalancerAndPlaza() and joinBalancerAndPredeposit(). When called, joinBalancerPool() accepts the poolId, array of assets, the maximum amounts the user is willing to deposit and additional user data. First it transfers the maximum amount of assets from the user's address to its (ref). And after that joins the pool (ref).
However, it is not guaranteed that the maximum value of each asset will be deposited in the Pool. From the Balancer V2 doc:
The amounts to send are decided by the Pool and not the Vault: it just enforces these maximums.
This means that there might be leftover assets in the BalancerRouter that are not deposited into the pool, but are also not returned to the user.
Internal Pre-conditions
No response
External Pre-conditions
- Not all assets are deposited into the Balancer Pool.
Attack Path
- User calls
joinBalancerAndPredeposit()orjoinBalancerAndPlaza(). - Maximum amount of tokens are sent to the
BalancerRouter. - Not all of the tokens are deposited into the Pool, because he decides how much to deposit.
Impact
The user will suffer loss of funds, because part of his assets will remain locked in the BalancerRouter.
PoC
No response
Mitigation
Send the remaining assets back to the user.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/Convexity-Research/plaza-evm/pull/154
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
The contract transfers the maximum amount from the user but does not verify or return any leftover assets after the pool deposit, which may be less than the maximum.
Impact
The user will suffer loss of funds, because part of his assets will remain locked in the BalancerRouter.
What the attacker needed
User calls joinBalancerAndPredeposit or joinBalancerAndPlaza; Pool deposits less than maximum amount
The fix
The protocol team fixed this issue in the following PRs/commits: https://github.com/Convexity-Research/plaza-evm/pull/154
How it was found
- User calls joinBalancerAndPredeposit() or joinBalancerAndPlaza().
- Maximum amount of tokens are sent to the BalancerRouter.
- Not all of the tokens are deposited into the Pool, because he decides how much to deposit.
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 you deposit money into a pool, you might say you are willing to put in up to a certain amount. The pool decides how much it actually takes. This report says the contract takes your maximum amount but does not return the part the pool did not take, so that money gets stuck in the contract.
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.