Public vaults can become insolvent because of missing `yIntercept` update
The PublicVault contract fails to deduct the payment amount from yIntercept in beforePayment(), causing the vault's inferred total assets to be inflated. This miscalculation can lead to vault insolvency.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/197
Found by
0xRajeev, zzykxx
Summary
The deduction of yIntercept during payments is missing in beforePayment() which can lead to vault insolvency.
Vulnerability Detail
yIntercept is declared as "sum of all LienToken amounts" and documented elsewhere as "yIntercept (virtual assets) of a PublicVault". It is used to calculate the total assets of a public vault as: slope.mulDivDown(delta_t, 1) + yIntercept.
It is expected to be updated on deposits, payments, withdrawals, liquidations. However, the deduction of yIntercept during payments is missing in beforePayment(). As noted in the function's Natspec:
/**
* @notice Hook to update the slope and yIntercept of the PublicVault on payment.
* The rate for the LienToken is subtracted from the total slope of the PublicVault, and recalculated in afterPayment().
* @param lienId The ID of the lien.
* @param amount The amount paid off to deduct from the yIntercept of the PublicVault.
*/
the amount of payment should be deducted from yIntercept but is missing.
Impact
PoC: https://gist.github.com/berndartmueller/477cc1026d3fe3e226795a34bb8a903a
This missing update will inflate the inferred value of the public vault corresponding to its actual value leading to eventual insolvency because of resulting protocol miscalculations.
Code Snippet
Tool used
Manual Review
Recommendation
Update yIntercept in beforePayment() by the amount value.
Discussion
androolloyd
tagging @SantiagoGregory but i believe this is a documentation error, will address
secureum
Escalate for 2 USDC.
Given the vault insolvency impact as described and demonstrated by the PoC, we still think this is a high-severity impact (not Medium as judged). The other dup #92 also reported this as a High.
cc @berndartmueller @lucyoa
sherlock-admin
Escalate for 2 USDC.
Given the vault insolvency impact as described and demonstrated by the PoC, we still think this is a high-severity impact (not Medium as judged). The other dup #92 also reported this as a High.
cc @berndartmueller @lucyoa
You've created a valid escalation for 2 USDC!
To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Evert0x
Escalation accepted
sherlock-admin
Escalation accepted
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
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 beforePayment() function does not update yIntercept by subtracting the payment amount, contrary to its documented purpose.
Impact
This missing update will inflate the inferred value of the public vault corresponding to its actual value leading to eventual insolvency because of resulting protocol miscalculations.
What the attacker needed
None
The fix
Update yIntercept in beforePayment() by the amount value.
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.
A public vault tracks its total assets using a formula that includes a value called yIntercept. When a payment is made, the code should reduce yIntercept by the payment amount, but it does not. This makes the vault appear to have more assets than it actually does, which could cause it to become insolvent.
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.