Phoenix-Protocol-Group / phoenix-contracts

Source code of the smart contracts of the Phoenix DeFi hub DEX protocol
GNU General Public License v3.0
10 stars 6 forks source link

PHOAM-015: The provide_liquidity function allows negative values #345

Closed gangov closed 1 month ago

gangov commented 2 months ago

Location

./contracts/pool_stable/src/contract.rs

Description The provide_liquidity fails to validate that desired_a and desired_b are not negative. Coinspect attempted to exploit this problem, however the transaction reverted due to a check in the token contract that does not allow negative values. Should the pool use a token without such check, an attacker could attempt to subtract pooled funds by providing negative liquidity values.

Recommendation Add the validate_int_parameters function to ensure that values are not negative. Similarly to what's done in the volatile pool code.