Closed c4-bot-5 closed 11 months ago
0xSorryNotSorry marked the issue as sufficient quality report
0xSorryNotSorry marked the issue as duplicate of #877
0xSorryNotSorry marked the issue as not a duplicate
0xSorryNotSorry marked the issue as duplicate of #994
Trumpero changed the severity to 2 (Med Risk)
Trumpero marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/governance/ProfitManager.sol#L388-L400 https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/GuildToken.sol#L142-L147
Vulnerability details
Impact
A malicious actor can slash other users' gauge weights to earn the entire share of subsequent gauge rewards for themselves.
Proof of Concept
A gauge's profit index is incremented whenever there's a positive PnL event through the following lines:
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/governance/ProfitManager.sol#L388-L400
The calculation depends on the total weight assigned to that gauge (
_gaugeWeight
), which can be manipulated by callingGuildToken.applyGaugeLoss
.Through malicious transaction/function call ordering, a malicious actor can steal all subsequent gauge rewards for themselves. When a lending term is about to be off-boarded, a malicious actor can perform the following attack:
Front-run the off-boarding transaction and assign a small amount of GUILD to that gauge.
Right after off-boarding has been initiated, call a loan that will incur bad debt, i.e.,
loanDebtInUSD > collateralInUSD
.Wait until the loan has been closed and has notified
ProfitManager
of a negative PnL event (or bid on the auction when PnL hits negative).Apply gauge loss to every other account assigned to that gauge.
Trigger positive PnL events either through bidding on called loans or ordering loan repayments after gauge losses have been applied.
Claim gauge rewards.
Steps 3-6 can be executed inside a MEV bundle to ensure that the malicious actor's gauge weight is the only one that is not slashed before gauge rewards are distributed.
Add the following test to
test/unit/tokens/GuildToken.t.sol
to see an example of how gauge rewards can be stolen:Tools Used
Manual review
Recommended Mitigation Steps
To properly mitigate against this attack, the slashing mechanism needs to be redesigned.
A band-aid solution to prevent this attack in the case of off-boarded lending terms can be to only allow slashing after all loans in the lending term have been closed.
Assessed type
MEV