Skip to content

Account for Vow surplus in End.thaw debt calculation#388

Open
daatsuka wants to merge 1 commit into
sky-ecosystem:masterfrom
daatsuka:security-vulnerability-disclosure-immune-373
Open

Account for Vow surplus in End.thaw debt calculation#388
daatsuka wants to merge 1 commit into
sky-ecosystem:masterfrom
daatsuka:security-vulnerability-disclosure-immune-373

Conversation

@daatsuka
Copy link
Copy Markdown

This change touches End.thaw() in src/end.sol. The previous implementation enforced a hard require that vat.dai(address(vow)) must be exactly zero before thaw() could proceed, and then computed debt purely as vat.debt() − cure.tell(). That two-step approach created a precondition that could block emergency shutdown in practice — any residual DAI surplus sitting in the Vow would cause thaw() to revert, even though that surplus is a legitimate part of the system's outstanding obligations and should simply be subtracted from the total debt figure rather than treated as a blocker.

The updated logic removes the surplus-must-be-zero guard and instead folds vat.dai(address(vow)) directly into the debt calculation: debt = sub(vat.debt(), add(vat.dai(address(vow)), cure.tell())). This means thaw() now accounts for both the Cure-reported bad debt and the Vow's DAI balance in a single arithmetic expression, producing a net debt figure that accurately reflects what collateral holders are owed during shutdown. The design keeps the same sub / add safe-math helpers already used throughout end.sol, so there is no new overflow surface, and the change is intentionally minimal — one require removed, one line rewritten — to keep the audit footprint small.

The rationale is straightforward: surplus DAI held by the Vow is not external to the debt accounting; ignoring it (or refusing to proceed when it exists) leads to an unnecessarily strict shutdown path that the original Immunefi report correctly identified as problematic. I verified locally by running the full Foundry test suite (forge test) against the modified contract — all existing End tests pass without modification, and thaw() no longer reverts when the Vow carries a non-zero DAI balance.

Closes #373

@DaiFoundation-DevOps
Copy link
Copy Markdown

DaiFoundation-DevOps commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Archived

2 participants