_doSherX optimistically assumes premiums will be paid
The `_doSherX` function only pays off accrued premiums for tokens where the payout would otherwise revert, but calculates the payout amount assuming all premiums are paid. An attacker could receive an inflated payout because the calculation overestimates the available underlying balance.
Submitted by cmichel
The _doSherX function does not attempt to pay off the accrued premiums (“pay off debt”) for most tokens, only for the ones that would otherwise revert the tx:
// Expensive operation, only execute to prevent tx reverts
if (amounts[i] > ps.sherXUnderlying) {
LibPool.payOffDebtAll(tokens[i]);
}
The amounts = LibSherX.calcUnderlying(totalSherX) array is an optimistic view assuming all outstanding, accrued premiums would indeed be paid until now. However, it could be that a protocol does not have enough balance to pay out these premiums and updating the state using LibPool.payOffDebtAll(tokens[i]); would fail for a token.
An inflated amount is then paid out to the user based on the optimistic calcUnderlying call.
Evert0x (Sherlock) acknowledged:
Fair point, the protocol is optimistic the protocols can payoff their debt.
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 function uses an optimistic calculation of underlying tokens without ensuring all accrued premiums are actually paid off, leading to an inflated payout.
What the attacker needed
None
The fix
The function should pay off all accrued premiums before calculating the payout amount, or adjust the calculation to reflect only actually paid premiums.
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.
This is a smart contract bug where a function calculates how much a user should get by assuming all debts are paid, but it only actually pays debts when necessary to avoid errors. So the user might get more than they should because the calculation is too optimistic.
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.