Upgraded Q -> 2 from #556 [1706974007287] #1290
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
duplicate-994
satisfactory
satisfies C4 submission criteria; eligible for awards
Judge has assessed an item in Issue #556 as 2 risk. The relevant finding follows:
[L-01] Users can frontrun
NotifyPnL
calls to earnrisk-free
rewards and avoid slashingBug Description
Calls to
ProfitManager::notifyPnL
are performed by terms when a profit or loss is generated. Guild stakers who are staked into a gauge while it experiences a profit will be eligible to claim rewards for that gauge/term. First, the gauge'sgaugeProfitIndex
is updated based on the profit generated:ProfitManager::notifyPnL#L383-L399
Next, stakers who were staked in the gauge will be able to collect the rewards via
ProfitManager::claimGaugeRewards
:ProfitManager::claimGaugeRewards#L427-L434
On the other hand, stakers who are staked into a gauge when it experiences a loss will have their Guild slashed. First, the time of the loss is recorded in the gauge:
ProfitManager::notifyPnL#L300-L305
Next, the loss can be applied to any staker who was staked into the gauge when the loss occured, resulting in the staker being slashed:
GuildToken::applyGaugeLoss#L133-L140
User's are not enforced to be staked into a gauge for a minimum amount of time in order to be eligible to receive rewards and therefore a user can stake into the gauge immediately before a profit is generated (in the same block) and then claim rewards via
claimGaugeRewards
.Similarly, stakers can avoid being slashed by immediately unstaking all their Guild before the loss is recorded (in the same block). Therefore, the user's
lastGaugeLossApplied
will be equal to thelastGaugeLoss
and the user will not be slashed.Impact
Users can frontrun
gainy notifyPnL
calls to collect rewards for a gauge that will experience a profit. This will result in all other stakers' rewards being diluted. The user is able to do this despite their total time staked in the gauge being0
(staked into gauge during the same block as profit). Additionally, the user is able to benefit from the reward system while taking onzero-risk
.Users can frontrun
lossy notifyPnL
calls to avoid being slashed. Since slashing is total, a loss of1 wei
will be as devastating to a staker as a loss of1_000e18
. Therefore, users are incentivized to actively try to avoid these losses by unstaking all of their Guild immediately before the gauge experiences a loss. User's who unstake will have to be sure the adjusted debt ceiling (after unstaking) does not fall below theissuance
for the gauge, or else the user will not be allowed to unstake their Guild.Proof of Concept
Place the following test inside of
/test/unit/governance/ProfitManager.t.sol
:Recommendation
Stakers can be enforced to be staked into a gauge for at least 1 block. This would ensure that user's are not able to stake into a gauge in the same block in which a profit is generated and collect rewards.
Unstaking can be restricted during auctions in order to prevent stakers from speculating on the likely-hood of a
loss
occuring and prevent them from unstaking before the loss is recorded.The text was updated successfully, but these errors were encountered: