Users Who Queue Withdrawal Before A Slashing Event Disadvantage Users Who Queue After And Eventually Leads To Loss Of Funds For Them
Withdrawal requests lock in the HYPE amount at the exchange rate current when queued, so users who queued before a slashing event are paid at the old, higher rate. After a slash, those earlier withdrawals can drain the contract balance, leaving later queued users and remaining holders with less than their fair share.
franfran20 Follow with 0xG0P1, 0xLeveler and 32 others
Originally disclosed on Code4rena
Submitted by franfran20, also found by 0xG0P1, 0xLeveler, 0xpiken, adamIdarrha, Afriauditor, ak1, Atharv, Audinarey, btk, d3e4, falconhoof, gesha17, givn, harry, holydevoti0n, IzuMan, ke1caM, knight18695, komronkh, KupiaSec, marchev, mrudenko, MrValioBg, octeezy, oxelmiguel12, peanuts, phoenixV110, rouhsamad, ThanatOS, trachev, typicalHuman, vangrim, zhaojohnson, and zzebra83
Finding description and impact
Lets take the scenario where the HYPE to KHYPE exchange is 1 KHYPE = 1.5 KHYPE.
At this point, let’s assume that there are in total 50 KHYPE tokens queued for withdrawals, that is 75 HYPE queued for withdrawals while the remaining 20 KHYPE are still held by their respective holders worth 30 HYPE in all.
This means that the locked in amount in the queued Withdrawals for each user across all queued withdrawals is 75 HYPE.
We know this because of the logic in the queueWithdrawal function in the StakingManager below:
uint256 hypeAmount = stakingAccountant.kHYPEToHYPE(postFeeKHYPE);
// Lock kHYPE tokens
kHYPE.transferFrom(msg.sender, address(this), kHYPEAmount);
// Create withdrawal request
_withdrawalRequests[msg.sender][withdrawalId] = WithdrawalRequest({
hypeAmount: hypeAmount,
kHYPEAmount: postFeeKHYPE,
kHYPEFee: kHYPEFee,
timestamp: block.timestamp
});
That gives us a total of 70 KHYPE to 105 HYPE across the board when calulating the exchange ratio (including rewards).
Now let’s assume for some reason there’s a slashing event and the amount of HYPE in total reduces from 105 KHYPE to 75 KHYPE.
Now it leaves us with an exchange ratio of 70 KHYPE to 75 HYPE i.e 1 KHYPE = 1.071 HYPE.
Since the guys who withdrew earlier already have their withdrawal delay processing first locked in with the ratio that was used before the slash, they all successfully confirm their withdrawal first and take the whole 75 HYPE available, leaving 0 HYPE left for all the remaining 20 KHYPE holders.
You can see the confirmWithdrawal function uses the withdrawalRequest amount hypeAmount stored which uses the previous ratio.
function confirmWithdrawal(uint256 withdrawalId) external nonReentrant whenNotPaused {
// @note - the process confirmation basically makes sure the khype amount to be withdrawn is in the contracts
// ... it burns it, transfers the fee and makes sure the withdrawal delay has been exceeded, deletes the withdrawal request, updates the totalclaimed and totalqueuedwithdrawals
// ... it then returns the hype amount to be received by the user
uint256 amount = _processConfirmation(msg.sender, withdrawalId);
require(amount > 0, "No valid withdrawal request");
// @note - makes sure that the contract has the specified amount required to satisfy the withdrawals
// @note - this is where the issue lies I guess, maybe not here, but if there was a slashing occurence before this confirmation of withdrawal, there could be an issue???
require(address(this).balance >= amount, "Insufficient contract balance");
// @note - updates the totalClaimed hype across all SM
stakingAccountant.recordClaim(amount);
// Process withdrawal using call instead of transfer
(bool success,) = payable(msg.sender).call{value: amount}("");
require(success, "Transfer failed");
}
This leads to loss of stake for the remaining KHYPE holders even though there was enough to go 1:1.
Recommended Mitigation Steps
A possible mitigation would be when confirming withdrawals, not to use the hypeAmount stored in the withdrawal request but to recalculate with the new ratio.
Kinetiq disputed and commented:
Exchange rate adjusts only during rewards or slashing. When users queue withdrawals, their assets exit the validator, earning no profits, so the exchange rate remains fixed as when queued, until confirmation. The rate fluctuates slightly upon claiming due to total supply changes, but this is acceptable and not an issue for us.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the withdrawal confirmation pays the HYPE amount stored when the request was queued rather than recalculating it at the current exchange rate, so a slashing event is not reflected in earlier requests.
Impact
Remaining KHYPE holders and later queued withdrawals could lose funds because earlier requests are paid at the pre-slash rate; the project disputed this, arguing the rate is fixed while assets are out of the validator.
What the attacker needed
A slashing event occurs; withdrawals queued before the slash; contract holds queued funds
The fix
When confirming a withdrawal, the amount should be recalculated using the current exchange rate rather than the stored amount, though the project disputed that this is needed.
How it was found
- Assume an exchange rate of 1 KHYPE to 1.5 HYPE with 50 KHYPE queued for withdrawal and 20 KHYPE still held.
- A slashing event reduces total HYPE so the exchange rate falls to about 1 KHYPE to 1.071 HYPE.
- Earlier queued withdrawals confirm first at the old stored amount and take the whole available balance.
- Later queued users and remaining holders are left with nothing.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Users can ask to take their staked tokens out later, and the amount they will receive is fixed at the moment they ask. If the value of the staked pool drops in the meantime (a 'slashing' event, where staked funds are penalised), the earlier requests are still paid the old, higher amount. That can use up the pool's funds, so people who asked later, or who never asked, get less than they should.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.