Duplicate LP token could lead to incorrect deposits
The addPool function does not check for duplicate lpToken addresses, allowing two pools to share the same lpToken. When depositAll is called on the first pool, it takes all lpTokens and deposits them under its own pid, leaving no balance for the second pool.
Originally disclosed on Code4rena
Submitted by csanuragjain, also found by kirk-baird and unforgiven
It was observed that addPool function is not checking for duplicate lpToken which allows 2 or more pools to have exact same lpToken. This can cause issue with deposits.
In case of duplicate lpToken, the first pool calling depositAll will take away all lpToken and deposit them under there own pid. This leaves no balance for 2nd pool.
Proof of Concept
- PoolManager call addPool function and uses lpToken as A
- PoolManager again call addPool function and mistakenly provides lpToken as A
- Now 2 pools will be created with lpToken as A
- depositAll function is called passing first pool.
- This takes all balance of lpToken A and depsoit it under first pool pid
- This mean no balance is left for second pool now
Recommended Mitigation Steps
Add a global variable keeping track of all lpToken added for pool. In case of duplicate lpToken addPool function should fail.
jetbrain10 (veToken Finance) confirmed and commented:
There is already a validation not allow to add duplicated gauges, pool manager contract, add pool function , but we have to add also a validation for lp token like gauges.
Alex the Entreprenerd (judge) commented:
The warden has shown how, due to a lack of validation, the assumption that each lpToken is used only on one pool can be broken. This will cause accounting issues.
For those reasons, I agree with Medium Severity.
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 addPool function lacks a check to prevent the same lpToken from being used in multiple pools.
Impact
The second pool loses its deposited lpTokens, causing accounting issues and incorrect deposits.
What the attacker needed
PoolManager mistakenly adds duplicate lpToken
The fix
The addPool function should be fixed to track all lpTokens and reject duplicates.
How it was found
- PoolManager calls addPool with lpToken A.
- PoolManager calls addPool again with the same lpToken A.
- Two pools are created with lpToken A.
- depositAll is called for the first pool.
- The first pool takes all lpToken A and deposits under its pid.
- No balance remains for the second pool.
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 pool is a place where users deposit tokens. The system assumes each token is used by only one pool, but it never checks this. If two pools use the same token, the first one to collect deposits takes everything, so the second pool gets nothing.
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.