Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 6 #6

Open
Edward-Lo opened this issue Sep 26, 2020 · 3 comments
Open

Issue 6 #6

Edward-Lo opened this issue Sep 26, 2020 · 3 comments

Comments

@Edward-Lo
Copy link
Collaborator

Description

The FlamingoSwapPairContract contract implements many functionalities for token-swap-pair. These interfaces will be called by FlamingoSwapRouterContract in many different scenarios.

For example. a user can claim his bonus after providing liquidity for a token-swap-pair by RemoveLiquidity function of FlamingoSwapRouterContract. It will first do some sanity checks, then transfer the liquidity token to the FlamingoSwapPairContract and calls Burn to remove the liquidity token and retrieve the tokens back and send them back to the user.

However, Burn is publicly avaiable, so an attacker can burn the liquidity token if someone mistakenly transfer it to the FlamingoSwapPairContract contract. There is a medium article by Dan Robinson thoroughly explains the concept and exploitation.

The same issue also applies to Mint and Swap.

Recommendation

Add permission checks for these functions.

@Ashuaidehao
Copy link
Contributor

I'v add "Router WhiteList" for permission check, please help to check if it can resolve the problem. Thanks!

@Ashuaidehao
Copy link
Contributor

Ralated Changes:

Assert(CheckIsRouter(callscript), "Only support transfer to me by Router");

Assert(CheckIsRouter(msgSender), "Only Router Can Swap");

Assert(CheckIsRouter(msgSender),"Only Router Can Burn");

Assert(CheckIsRouter(msgSender), "Only Router Can Mint");

@Edward-Lo
Copy link
Collaborator Author

Ralated Changes:

Assert(CheckIsRouter(callscript), "Only support transfer to me by Router");

Assert(CheckIsRouter(msgSender), "Only Router Can Swap");

Assert(CheckIsRouter(msgSender),"Only Router Can Burn");

Assert(CheckIsRouter(msgSender), "Only Router Can Mint");

I think these should do, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants