-
Notifications
You must be signed in to change notification settings - Fork 11
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
Any user can avoid slashing losses by frontrunning #1006
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-877
high quality report
This report is of especially high quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Comments
c4-bot-7
added
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
labels
Dec 28, 2023
The issue is well demonstrated, properly formatted, contains a coded POC. |
c4-pre-sort
added
the
high quality report
This report is of especially high quality
label
Dec 29, 2023
0xSorryNotSorry marked the issue as high quality report |
0xSorryNotSorry marked the issue as duplicate of #906 |
0xSorryNotSorry marked the issue as duplicate of #877 |
Trumpero marked the issue as unsatisfactory: |
c4-judge
added
the
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
label
Jan 25, 2024
Trumpero marked the issue as unsatisfactory: |
1 similar comment
Trumpero marked the issue as unsatisfactory: |
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-877
high quality report
This report is of especially high quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/SurplusGuildMinter.sol#L158-L212
Vulnerability details
Impact
Any user can avoid slashing losses with a frontrun call that will create a loss on the system (eg. invoke
notifyPnL
with a negative amount). This should not be correct as he can then stake with no risk at all and only get rewards. Users who stake get rewards in exchange for carrying a risk of slashing in case of losses.Proof of Concept
There is no mechanism to prevent frontrunning the call that creates a loss. An attacker could simply unstake his whole stake before the loss is notified to the system. This way he gets the full benefit of earning rewards with no risk of slashing.
Add this test to
SurplusGuildMinter.t.sol
file and add importimport "@forge-std/console.sol";
Run with
forge test --match-path ./test/unit/loan/SurplusGuildMinter.t.sol -vvv
Logs: Bob credit balance: 114000000000000000000
Tools Used
Manual review
Recommended Mitigation Steps
Implement a mechanism where a user has to
requestUnstake()
and afterunstakeDelay
they can callunstake()
. TheunstakeDelay
can be really small. Even1 block
would be enough as they cannot frontrun the transaction anymore. Would be a good idea to put more in case of a low gas tx.Assessed type
Timing
The text was updated successfully, but these errors were encountered: