-
Notifications
You must be signed in to change notification settings - Fork 1
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
bug: first depositor to a gate can front-run #219
Comments
Related: transmissions11/solmate#178 |
Related: tweet |
I am hesitant on the proposed mitigation by OZ because it introduces additional decimal precision. Also, it would affect all depositors, instead of the first depositor. Regarding the fix to require a minimum initial deposit, his criticism was that this value is arbitrary and opinionated. While that may be true, I am not sure if it is a sufficiently strong consideration. |
min deposit amount per token and make it sane? We run into this problem w sandclock and a single lusd deposit was enough to make the attack prohibitively expensive iirc. Agreed that we shouldn't care about it being opinionated. |
I'm in the minimum initial deposit camp as well. It's such a small amount I'd even require it in the constructor so we bear the burden. WDYT? |
I think that is a good idea. We can have the minimum initial deposit set as a constructor argument so that we can account for non-18 decimals like WBTC at deployment, and since the minimum initial deposit is already transferred, we do not need to change the existing code outside of the constructor. |
I realized there are two obstacles to implementing the transfer of the initial amount in the constructor in our current design.
Since we would still need to do (3) even if we provide the initial deposit in the constructor, then it seems cleaner to leave it out of the constructor. |
This is more complex than I originally thought. If we are unable to assign the yang amount corresponding to the minimum initial deposit to an inaccessible address, then the usual method of requiring a minimum initial deposit would not be sufficient to protect against this exploit. A malicious user can deposit the minimum (e.g. 1000 wei) then withdraw in full except 1 wei. I am now of the opinion that the constructor approach is better with the following addition:
This will allow us to mint the yang for the initial minimum deposit, without assigning it to a trove and exposing it to redistributions. |
So in |
After some tinkering around, I think we can do a real mint in a less straightforward manner instead of performing the token transfer in the constructor of Gate:
Since a deployed Gate is unusable until it is properly added via This allows us to (1) properly mint the yang for the equivalent token balance in the gate; (2) not subject any trove to a dust amoutn of yang, and therefore susceptible to redistribution; (3) does not require any changes to existing authorizations. |
That looks like a solid solution 👍 |
The Gate module is a simplified implementation of ERC-4626, and there is a known vulnerability with the first issuance of shares (
yang
in Aura's case) when the total supply of shares is0
. See this video by Spearbit on their audit of Maple Finance.This is how an attack would happen assuming the token is WETH, as replicated from the video:
Recommended solution:
The text was updated successfully, but these errors were encountered: