Open c4-bot-5 opened 10 months ago
bytes032 marked the issue as primary issue
bytes032 marked the issue as sufficient quality report
tserg (sponsor) confirmed
tserg marked the issue as disagree with severity
Caller still gets compensation, plus it is capped to 50 USD, so the impact of this is capped to 50 USD. User funds are also not at risk.
The Warden has showcased a way in which the compensation for the caller of the absorption will be lower than intended.
While the issue is valid, I agree with the Sponsor in that the severity of this cannot be considered high-risk. User funds are indeed affected, however, so I believe a medium-risk rating is more apt.
alex-ppg changed the severity to 2 (Med Risk)
alex-ppg marked the issue as satisfactory
alex-ppg marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/purger.cairo#L295
Vulnerability details
Impact
In absorb, since
shrine.melt
is being called afterfree
, caller will end up receiving less compensation than actually intended. It is because infree
, while checking user deposits, there are two cases when user has pending redistribution with exception: 1: User's yang 1 has zero balance 2: User's yang 1 has non zero balanceIn both cases user's balances are due for an update, if first n yang balances are zero, caller will miss out on compensation from unaccounted yang updates from all yangs due for redistribution until it encounters one with non zero yang balance. When it encounters first non-zero yang balance, it will still miss out on unaccounted fund from that yang as well, but after that it will be okay, since charge() would be called inside seize function which will then update balances for all yangs.
Proof of Concept
This is inside free function, where only after first non-zero yang balance is seize called and redistribution updated for trove and all its yangs. All calls to deposit will return less than actual balance of trove.
Tools Used
VS Code
Recommended Mitigation Steps
absorb
function should update order of melt and freeAssessed type
Other