Can avoid guild slashing by frontrunning notifyGaugeLoss with decrementGauge #310
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/tokens/GuildToken.sol#L123
Vulnerability details
Impact
When a gauge loss occurs, the protocol intends to lock the gauge weight voting for that gauge and slash it, but it's possible to frontrun the gauge loss by decrementing your gauge weight, thereby avoiding being slashed.
Proof of Concept
When a gauge incurs a loss, the ProfitManager notifies the GuildToken by calling
notifyGaugeLoss
, which in turn locks all the current gauge weight.The intention for this as stated in the documentation is to prevent bank runs by disallowing users from withdrawing before being liquidated. However, this doesn't actually accomplish this intention as users can simply watch for the notifyGaugeLoss call in the mempool and have a script frontrun this call to decrement their gauge weight. This significantly reduces the risk incurred by gauge voting which thus applies that risk to the protocol instead.
Tools Used
Recommended Mitigation Steps
If a locking mechanism is intended to be used to prevent bank runs, the position should be locked upon deposit for a pre-defined duration. One option would be to incorporate the locking duration into the gauge weight such that locking for a longer duration results in a greater gauge weight.
Assessed type
Timing
The text was updated successfully, but these errors were encountered: