Reproduced Exploit
Regnum Aurum: closeLiquidation reverts on an expired grace period even though the debt is 0
After a liquidation the borrower must repay and then call closeLiquidation inside the grace period. The grace check runs first. If the borrower repays and comes back after the deadline, closeLiquidation reverts GracePeriodExpired even though rawDebtBalance is 0. isUnderLiquidation stays true, so wi…
Loss
80 crvUSD of collateral stays in the pool. Debt is 0. Withdraw reverts
Chain
Ethereum
Category
logic
Date
May 2025
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 66186-h-24-unclosed-liquidation-blocks-collateral-recovery-pashov. Standalone Foundry PoC and full write-up: 66186-h-24-unclosed-liquidation-blocks-collateral-recovery-pashov_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/logic/liquidation-logic·vuln/logic/wrong-condition
Key info#
| Field | Value |
|---|---|
| Loss | 80 crvUSD of collateral stays in the pool. Debt is 0. Withdraw reverts |
| Vulnerable contract | LendingPool.closeLiquidation |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2025-05 |
| Compiler | solc 0.8.27, cancun, optimizer 200 |
| Bug class | Grace deadline is checked before the debt |
TL;DR#
After a liquidation the borrower must repay and then call closeLiquidation inside the grace period. The grace check runs first. If the borrower repays and comes back after the deadline, closeLiquidation reverts GracePeriodExpired even though rawDebtBalance is 0. isUnderLiquidation stays true, so withdrawAsset reverts CannotWithdrawUnderLiquidation. This run loads that post-deadline state: start time 0, grace length 0, debt 0, 80 crvUSD posted. Both calls revert. The 80 stays in the pool.
Background#
Pashov Audit Group, Regnum Aurum, May 2025, finding H-24, AuditVault id 66186. The Hardhat test warps 72 hours, repays, warps one more second, and expects GracePeriodExpired. A local run() cannot warp. The position is stored already past the deadline, which is the state of the user's next transaction in that test. The comparison is the report's comparison: block.timestamp > liquidationStartTime + liquidationGracePeriod. At Foundry's timestamp 1 and at the playground timestamp, timestamp > 0 is true.
The vulnerable code#
if (block.timestamp > position.liquidationStartTime + liquidationGracePeriod) {
revert("GracePeriodExpired"); // @> VULN: debt is not read before the grace deadline
}
if (!position.isInsured) revert("NotInsured");
uint256 positionDebt = position.rawDebtBalance;
if (positionDebt > 0) revert("DebtNotZero");
position.isUnderLiquidation = false;
- if (block.timestamp > position.liquidationStartTime + liquidationGracePeriod) {
+ if (position.rawDebtBalance > 0 && block.timestamp > position.liquidationStartTime + liquidationGracePeriod) {
revert("GracePeriodExpired");
}
Root cause#
The deadline gates the function before the debt is read. A zero-debt insured position that missed the window can never clear the flag. Withdrawal checks the flag and does not check the debt.
Preconditions#
- The position is insured, under liquidation, and the grace deadline is already behind
block.timestamp. - Debt has been repaid. Here it is stored as 0.
- 80 crvUSD of collateral is still booked on the position.
Attack walkthrough#
- The pool takes 80 crvUSD onto the expired position.
- The borrower calls
closeLiquidation. It revertsGracePeriodExpired. - The borrower calls
withdrawAsset. It reverts because the flag is still set. - The pool still holds 80 crvUSD. The borrower balance is 0.
Diagrams#
Impact#
The borrower cannot withdraw 80 crvUSD of collateral after repaying. The report also notes liquidateBorrower reverts when debt is 0, so the stability-pool path cannot clear the position either. The collateral is stuck.
Remediation#
Read the debt first. If it is 0, skip the grace check and clear isUnderLiquidation, which is the diff in the report.
How to reproduce#
cd 66186-h-24-unclosed-liquidation-blocks-collateral-recovery-pashov_exp
forge test -vv
test_zero_debt_still_cannot_close_or_withdraw asserts both reverts, debt 0, the flag still set, and 80 ether of collateral in the pool.
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/66186-h-24-unclosed-liquidation-blocks-collateral-recovery-pashov.md
- Report: https://github.com/pashov/audits/blob/master/team/md/RegnumAurum-security-review_2025-05-06.md
- Reduced from the
LiquidationProxy.closeLiquidationandLendingPool.withdrawAssetquotes in that report
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 66186-h-24-unclosed-liquidation-blocks-collateral-recovery-pashov_exp (evm-hack-registry mirror).
- AuditVault finding: 66186-h-24-unclosed-liquidation-blocks-collateral-recovery-pashov.
Alerts & third-party analyses
These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.