osmosis-labs / osmosis

The AMM Laboratory
https://app.osmosis.zone
Apache License 2.0
890 stars 585 forks source link

Analysis of BeforeSend hook impact on Osmosis modules #2613

Open ljah8 opened 2 years ago

ljah8 commented 2 years ago

The main task during the Informal Audit of Before Send hook design and implementation was to detect the possible area of impact and to see if there are places that could lead to panicking in modules affected the most.

Artifacts:

BeforeSend hook Facts:

Expectations:

Analysis Summary:

Within this issue will be described the analysis of Before Send hook impact on the Osmosis app, gamm, superfluid and token factory modules.

The potential problem can appear in the gamm module when a user successfully joins the pool. When trying to exit the pool an error in the smart contract can appear which besides smart contract-specified token disables withdrawing tokens of the other denominations which exist in the same pool, but do not cause error. Similar problems can happen when swapping tokens.

ExitPool - checks if the amount of exit coins is correct: https://github.com/osmosis-labs/osmosis/blob/a9d1ad654ec68354c7665bc4088fdb15b91dc9ec/x/gamm/keeper/msg_server.go#L142-L145

applyExitPoolStateChange - sends tokens to the user that exits the pool: https://github.com/osmosis-labs/osmosis/blob/a9d1ad654ec68354c7665bc4088fdb15b91dc9ec/x/gamm/keeper/share.go#L32-L36

Concerns:

Gamm module:

Superfluid module:

Tokenfactory module:

App:

Conclusion for BeforeSend hook impact on Osmosis module

For the following modules, there is no negative impact:

Potential negative impact is explained in separate issues:

dalmirel commented 2 years ago

Tagging audit collaboration team, to review issues as agreed. @ValarDragon @sunnya97