-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HIGH: SLOT owner claims are incorrect when there is only 1 slot owner. #426
Comments
dmvt marked the issue as primary issue |
vince0656 marked the issue as sponsor disputed |
I disputed it is because for a single collateralized SLOT owner you don't need to issue pro-rata ETH until the SLOT is topped up (see Stakehouse protocol for more info). For example:
if there is only 1 collateralized owner, then it gets 0.25 even if there is a slashing. it's only after a top up that the ETH can be split because then the contract knows who to allocate the ETH to. For a savvy bot, if you top up before a claim is made to the syndicate then they will get a % of the 0.25 because then the collateralized owners goes to 2 rather than one where their balance will then determine what proportion. |
dmvt marked the issue as nullified |
The report explains that there is inconsistent calculation between claimAsCollateralizedSLOTOwner and previewUnclaimedETHAsCollateralizedSlotOwner. The sponsor's explanation, also not 100% clear to me, reasons that claimAsCollateralizedSLOTOwner() is calculating as intended. So if that is so, the preview function is miscalculating. Suppose currentSlashAmount = 0.
But claim uses unproceessedForKnot without division:
So preview function shows a quarter of the actual accrued rewards, when there is 1 slot owner. In this case, severity should be dropped to M because function will lie to user, but eventually does not actually give them less funds than supposed to. |
@trust1995 thank you for pointing out the preview function. it should behave more like the state changing function |
dmvt marked the issue as not nullified |
dmvt changed the severity to QA (Quality Assurance) |
dmvt marked the issue as grade-b |
Lines of code
https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/syndicate/Syndicate.sol#L511
Vulnerability details
Description
In Syndicate.sol, _updateCollateralizedSlotOwnersLiabilitySnapshot function calculates accruedEarningPerCollateralizedSlotOwnerOfKnot for each slot owner. Later this variable is used to satisfy claims in claimAsCollateralizedSLOTOwner().
We can take a look at the following code:
In the block inside
if (numberOfCollateralisedSlotOwnersForKnot == 1)
, accruedEarningPerCollateralizedSlotOwnerOfKnot of the only owner is incremented by unprocessedETHForCurrentKnot.However, if there are several slot owners, each one is credited a relative portion of unprocessedETHForCurrentKnot, divided by (4 ether - currentSlashedAmount). This is an issue since the Syndicate does not take into account the slashedAmount if there is only one owner.
We can confirm this is inconsistent with the preview function:
Since we don't divide by (4 ether - currentSlashedAmount), it is the same behavior as currentSlashedAmount = 3 ether, which means SLOT owner may receive either much more or much less than they should when claiming.
Impact
SLOT owner claims are incorrect when there is only 1 slot owner.
Proof of Concept
Tools Used
Manual audit
Recommended Mitigation Steps
Change the calculation to be consistent in both scenarios.
The text was updated successfully, but these errors were encountered: