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

Fix FYDai Flashmint bug #360

merged 1 commit into from Oct 13, 2020

Fix FYDai Flashmint bug #360

merged 1 commit into from Oct 13, 2020


Copy link

@gakonst gakonst commented Oct 12, 2020

Only allow flashminting to msg.sender.

This prevents messing with the reserves of pools and getting mispriced quotes.

Luckily, our proxies still work, since we always used address(this) as the to field, which would always be the same as msg.sender.

This fixes the vulnerability where you would:
1. flashmint to the pool (skew prices)
2. buy/sell to the pool
3. burn from the pool -> stealing funds
@gakonst gakonst changed the title WIP: Repro pool drain bug Fix FYDai Flashmint bug Oct 13, 2020
Copy link

@alcueca alcueca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @gakonst

@alcueca alcueca merged commit 0a553ac into master Oct 13, 2020
Copy link

alcueca commented Oct 13, 2020

Btw, the deeper reason for this bug was not following my own set patterns for contract composition. If I would have done it right in the first place it should have been:

function flashMint(address from, address to, uint256 fyDaiAmount, bytes calldata data)
    external lock override 
        _mint(to, fyDaiAmount);
        IFlashMinter(msg.sender).executeOnFlashMint(from, to, fyDaiAmount, data);
        _burn(from, fyDaiAmount);

However, given that we only flash mint to msg.sender ourselves, that the parameters are a bit of a mind futz, and the amount of abuse that can come from flash minting, I'll try that pattern elsewhere, and not on fyDai v1.

@alcueca alcueca deleted the fix-flashmint-bug branch October 22, 2020 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants