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
merged 1 commit into from
Oct 13, 2020
Merged

Fix FYDai Flashmint bug #360

merged 1 commit into from
Oct 13, 2020

Conversation

gakonst
Copy link
Contributor

@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
@gakonst gakonst requested review from alcueca and samczsun October 13, 2020 10:20
Copy link
Contributor

@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
@alcueca
Copy link
Contributor

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 
    onlyHolderOrDelegate(from)
{
        _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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants