A malicious user can front-run the execution of profitManager.notifyPnL()
in order to avoid losses
#620
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
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/tokens/GuildToken.sol#L123
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/GuildToken.sol#L133
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/governance/ProfitManager.sol#L292
Vulnerability details
Impact
A user can vote for a lending term using the function GuildToken::incrementGauge(), so the lending term could increase its debt ceiling and borrowers can request loans under these terms. Conversely, if the lending terms incur losses, these losses are assumed by those who voted for those lending terms. The ProfitManager::notifyPnL() first notifies the losses, and then the function GuildToken::applyGaugeLoss() applies the losses to those who voted for that lending term.
The issue arise when a user who voted for a lending term can front-run the
ProfitManager
notification of the loss, leaving his position as a voter using the GuildToken::decrementGauge() function and thus preventing his guild tokens from being slashed. Sure, there may be some allocated debt being used by the gauge not allowing the decrease however in some cases the malicious voter can frontrun the loss notification and only gain rewards from his guild tokens that's why a medium severity for this issue is the best choice.Proof of Concept
For a test, I modeled a scenario where
Alice
uses40e18
tokens to vote in the lending termgauge1
which then incurs a loss.Alice
front-runs theProfitManager:notifyPnL()
transaction to remove her votes using theGuildToken::decrementGauge()
function, thus avoiding the loss of herGuildTokens
. Test steps:40e18
tokens to thegauge1
.gauge1
but before the loss notify occurs, alice frontrun and decrease his votes.applyGaugeLoss()
function) is reverted. Alice ends up without losses.gauge1
again without being penalized for previous losses.Tools used
Manual review
Recommended Mitigation Steps
To decrease a user's votes from a lending term, the user must wait a period of time so that these votes are not decreased before the losses are applied (malicious frontrun).
Assessed type
Context
The text was updated successfully, but these errors were encountered: