Users can to front-run a slash transaction without incurring any slashing penaltie. #509
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-877
sufficient quality report
This report is of sufficient 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
Vulnerability details
Users can stake his credit tokens in the SuplusGuildMinter.sol contract to vote for a gauge(term) and earn some fees by the interes paid for the borrowers. Staking in the SuplusGuildMinter come with the consecuence that if the gauge that you are voting on get a loss, all his credit token amount staked get slashed.
Losses in a gauge are notified by the profit manager in the notifyPnl function :
Wich is called by the term when there is an auction that result in bad deb or a forgive loan
Knowing this, an attacker can front runt the call, forgive, onbid, bid, notifyPnL transaction and send the unstake transaction afterward with higher gas to ensure its prioritized execution.
Impact
Users or attackers can claim all their fees, front-run the slash transaction, (call, forgive, unbid, bid, notifyPnL) and stake in different gauges. By repeatedly front-running loss transactions (call, forgive, unbid, bid) and staking in alternative gauges, they can effectively avoid losses and continue earning fees, resulting in a direct loss for the protocol.
Proof of Concept
Run the next function Test in foundry in
file:2023-12-ethereumcreditguild/test/unit/loan /SurplusGuildMinter.t.sol
In this simple proof of concept, I demonstrate that User 1 can front-run the notifyPnl transaction, avoiding any losses, while User 2 gets completely slashed.
Tools Used
Manual, Foundry
Recommended Mitigation Steps
Consider adding an unstaking period to prevent users from front-running the slash transaction. With an unstaking period in place, users would be required to wait for a specified duration before unstaking, reducing the risk of front-running.
Assessed type
Other
The text was updated successfully, but these errors were encountered: