Any stake will be reverted until the SurplusGuildMinter applies the loss. #166
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
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#L136
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/GuildToken.sol#L252-L255
Vulnerability details
Impact
Multiple users can
stake
in oneterm
throughSurplusGuildMinter
.If that
term
experiences anyloss
, no users canstake
in it until theSurplusGuildMinter
applies theloss
.Applying
loss
, in this context, means reducing thegauge weight
– the sum ofguilds
the users staked throughSurplusGuildMinter
– to0
.It's obvious that
interest
can still be assigned to theloss-experienced
gauge
.As a result, some users may wish to receive
interest
through thatterm
, while others want tostake
again.This inconsistency poses a challenge, and user
stakes
will revert until theloss
is applied.This could lead to fund loss due to
gas
fees.I marked this as medium because it may result in fund loss and violate the expectations of users who still wish to receive
rewards
.Proof of Concept
When a user attempts to stake in a
term
, it increases the gauge weight ofSurplusGuildMinter
for thatterm
.https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/SurplusGuildMinter.sol#L136
In the
_incrementGaugeWeight
function, we check whether this user has applied loss in the event that the gauge has undergone someloss
.If not, it will revert.
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/GuildToken.sol#L252-L255
For instance, some users staked in a
term T
throughSurplusGuildMinter
.After some time, that
term
experienced aloss
.Some users can attempt to stake in
term T
, but their efforts will revert becauseSurplusGuildMinter
has not yet applied theloss
.The PoC for this is as below:
Tools Used
Recommended Mitigation Steps
We can call the
applyGaugeLoss
function for the first user who tries to stake in aloss-experienced gauge
.This can resolve the above problem.
However, it's important to note that other users won't receive rewards anymore because the
gauge weight
becomes 0.Assessed type
DoS
The text was updated successfully, but these errors were encountered: