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

triggerDepeg() and triggerEndEpoch() can be frontrunned #141

Closed
code423n4 opened this issue Sep 17, 2022 · 4 comments
Closed

triggerDepeg() and triggerEndEpoch() can be frontrunned #141

code423n4 opened this issue Sep 17, 2022 · 4 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate This issue or pull request already exists edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Sep 17, 2022

Lines of code

https://github.com/code-423n4/2022-09-y2k-finance/blob/2175c044af98509261e4147edeb48e1036773771/src/Vault.sol#L203

Vulnerability details

Impact

In Vault.withdraw() you have modifier epochHasEnded(). But it's just checking time, no check if Controller already called triggerDepeg() or triggerEndEpoch()

So anyone can frontrun Controller transactions and withdraw their funds before without losses. For example risker can frontrun trx and withdraw funds in case of triggerDepeg() without funds loss

entitledAmount =
                    // @audit-ok high сначала делим - разве это не приведет к проблемам
                    amount.divWadDown(idFinalTVL[id]).mulDivDown(
                        idClaimTVL[id],
                        1 ether
                    ) +
                    amount;

So he will save his funds and get amount back

https://github.com/code-423n4/2022-09-y2k-finance/blob/2175c044af98509261e4147edeb48e1036773771/src/Vault.sol#L203

Tools Used

vs code

Recommended Mitigation Steps

Add explicit var, tells that epoch already ended by Controller. And only after that allow users to withdraw funds

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Sep 17, 2022
code423n4 added a commit that referenced this issue Sep 17, 2022
@3xHarry
Copy link
Collaborator

3xHarry commented Sep 22, 2022

dup #421

@MiguelBits MiguelBits added the duplicate This issue or pull request already exists label Sep 23, 2022
@HickupHH3
Copy link
Collaborator

dup #69

@HickupHH3 HickupHH3 added the satisfactory satisfies C4 submission criteria; eligible for awards label Oct 18, 2022
@0xRuslanSh
Copy link

Hi guys!
No 'Confirmed' label here, is it ok?
@HickupHH3

@HickupHH3
Copy link
Collaborator

@Ruslan2702 yes it's ok, it's been marked as a dup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate This issue or pull request already exists edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

5 participants