stableswap: Add check for correct input asset denoms to joinPoolSharesInternal
and updatePoolForJoin
#2266
Labels
C:x/gamm
Changes, features and bugs related to the gamm module.
Good first issue
T:bug 🐛
Something isn't working
Background
Our current implementation of
JoinPool
for stableswap checks the number of input assets, but does not check what their specific denoms are. This allows for a scenario where arbitrary tokens can be sent into a pool, much like was the case in #1906.However, unlike in #1906, our stableswap implementation has no implicit denom check when updating pool assets, so anything that is passed in is just directly added to the pool:
osmosis/x/gamm/pool-models/stableswap/pool.go
Lines 163 to 166 in 5879583
If it weren't for a division by zero here incidentally catching denom deposits for denoms not in the pool, this would be a critical bug as it would allow spam/poisoned tokens to be sent into a pool to crowd out and ultimately drain liquidity.
We should add a denom check both in
joinPoolSharesInternal
and, to cover broader future cases, also add a check toupdatePoolForJoin
to make sure joining a pool does not change the number of assets in it.Suggested Design
Expand the condition below to ensure that
p.GetTotalPoolLiquidity()
is aDenomsSubsetOf
ofTokensIn
and vice versa (i.e. make sure denoms are equivalent):osmosis/x/gamm/pool-models/stableswap/amm.go
Line 382 in 5879583
Add a length check similar to the following to
updatePoolForJoin
in stableswap/pool.go:osmosis/x/gamm/pool-models/stableswap/pool.go
Lines 151 to 153 in 5879583
Acceptance Criteria
The text was updated successfully, but these errors were encountered: