Status DataClose notification

Rain Disclosed Report

Audit Report

Liquidation erases committed stress loss and lets RAIN-backed USDR drain the stable reserve

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Summary

Root cause: SolvencyEngine.worstCaseLoss() counts volatile positions only through globalArt and globalInk; LiquidationTrigger.bark() removes both values before the auction clears but does not add the resulting vice or in-liquidation exposure to the loss calculation.

Exploit condition: After a normal collateral-price decline makes a vault unsafe, any account can call bark; an ordinary USDR holder can then redeem against reserve funds that were committed immediately before liquidation.

Impact: An attacker can drain stable reserve assets while volatile debt and its auction remain outstanding, leaving other USDR holders with unbacked liabilities and causing protocol insolvency.

Primary proof: pocs/RUSDR-001_liquidation_releases_committed_reserve/artifacts/run_poc.txt

Weakness: Business Logic Errors (HackenProof) / Protocol insolvency / CWE-682: Incorrect Calculation

Severity: Critical under HackenProof Smart Contracts v2.0, which classifies protocol insolvency, under-collateralization, and unbacked tokens as Critical.

  • The exploit uses only permissionless vault, liquidation, and PSM operations.
  • The proof drains 200 USDT, leaves the reserve at zero, and leaves 204.52 RAD of vice plus an uncleared auction.

Scope asset: https://github.com/hackenproof-public/rain-usdr-contracts/tree/main/contracts

Affected:

  • rain-usdr-contracts commit 5e6be73d34bdc3450c5db0f7d5db5c68a2011242 on main.

Attack Scenario

The attacker is an ordinary RAIN vault owner and USDR holder. The victim is a PSM depositor whose 200 USDT funds the stable reserve and who receives 200 USDR. The trust source is SolvencyEngine.worstCaseLoss() plus ReserveAccounting.committedEscrow(). The protected resource is the stable reserve committed against stress loss; Rain's specification says a RAIN minter or ordinary USDR holder cannot access this escrow.

The attacker deposits RAIN, mints 200 USDR, and waits for an ordinary market decline to make the vault unsafe. Immediately before liquidation, the system computes 172 USDR of stress loss, commits that amount, and correctly rejects the attacker's attempt to redeem 200 USDR for reserve USDT because only 28 USDR is free slack. The attacker then calls the permissionless bark() function. That call moves the vault's 200 USDR debt into vice and a live auction while removing the position from globalArt and globalInk. The next PSM redemption recomputes stress loss as zero, overwrites committed escrow with zero, and releases all 200 USDT to the attacker. The victim still holds 200 USDR, the reserve is empty, and 204.52 RAD of debt remains outstanding.

Technical Details / Evidence

LiquidationTrigger.bark() calls VaultEngine.grab() with negative debt and collateral changes, queues the debt, and starts the auction. grab() reduces the ilk's globalArt and globalInk while increasing vice through the negative dart accounting.

SolvencyEngine.worstCaseLoss() calculates loss only from each volatile ilk's current globalArt and globalInk, plus prediction-market exposure. It never reads VaultEngine.vice, the liquidation queue, or auction state. A fully barked position therefore contributes zero loss even though its debt is unresolved.

PegStabilityModule.buyStable() calls checkInvariant() immediately before redemption and trusts the resulting freeSlack(). Because the recomputation observes zero loss, it resets committed escrow to zero and permits the full reserve withdrawal.

Rain's USDR specification expressly includes a conservative reserve for positions past liquidation but not yet cleared in stress maximum loss, and states that RAIN minters and ordinary USDR holders cannot access committed escrow. The implementation violates both controls.

Impact

The attacker receives reserve USDT that the protocol had committed to cover a volatile-collateral shortfall. In the demonstrated state, 200 USDT leaves the reserve, a separate depositor retains 200 USDR, and the ledger still carries 204.52 RAD of vice with the auction uncleared. The documented Stress-MaxLoss <= Stable Reserve invariant is reduced from 172 <= 200 to 172 > 0, leaving the remaining USDR under-collateralized and the protocol insolvent under its own stress model.

Mitigation / Patch

Include unresolved liquidation exposure in worstCaseLoss(). Track per-ilk in-liquidation debt and collateral when bark() starts an auction, reduce those values only as take() actually covers debt or emergency settlement restores the position, and add their stressed net shortfall to live-vault loss. As a defense in depth, prevent updateCommittedEscrow() from decreasing while VaultEngine.vice() or auction debt is outstanding unless the new calculation explicitly proves that those positions remain covered.

Validation steps

Proof of Concept

The bundle is in pocs/RUSDR-001_liquidation_releases_committed_reserve/. run.sh clones the pinned repository, installs exact @openzeppelin/[email protected], corrects the repository's stale out-of-scope Base.t.sol import path without changing any in-scope contract, copies LiquidationEscrowReleasePoC.t.sol into the test directory, and runs only test_liquidationDropsCommittedLossAndReleasesReserve under Foundry 1.5.1. Compact output includes the authentic Foundry [PASS] receipt and the exact control, exploit, and impact deltas.

Steps to Reproduce

  1. Prerequisites: Linux, Bash, Git, Node.js with npm, Foundry 1.5.1, outbound HTTPS access to GitHub and npm, and no RPC credentials or environment variables.
  2. Enter the extracted PoC directory:
    unzip RUSDR-001_liquidation_releases_committed_reserve.zip
    cd RUSDR-001_liquidation_releases_committed_reserve
    
  3. Check prerequisites:
    ./run.sh --preflight
    
  4. Run the compact replay:
    ./run.sh
    
  5. Confirm the result: Observe [PASS] test_liquidationDropsCommittedLossAndReleasesReserve(), then Control: 172 USDR remains committed before bark; the 200-USDT redemption reverts., Exploit: bark drops reported loss to zero; the same 200-USDT redemption succeeds., Impact: the stable reserve reaches zero while an auction and more than 200 RAD of vice remain., and RESULT: PASS. Use ./run.sh --verbose or ./run.sh --full-output for full diagnostics.
  6. Cleanup: run.sh removes its unique temporary checkout automatically on success, failure, and interruption. It starts no service, container, local chain process, or live target session.

uploaded-image

Artifacts & Attachments

  • RUSDR-001_liquidation_releases_committed_reserve.zip - complete deterministic PoC bundle for upload.
  • pocs/RUSDR-001_liquidation_releases_committed_reserve/artifacts/run_poc.txt - primary proof with the native Foundry pass and emitted state deltas.
  • pocs/RUSDR-001_liquidation_releases_committed_reserve/LiquidationEscrowReleasePoC.t.sol - exploit and control test against the pinned contracts.
  • pocs/RUSDR-001_liquidation_releases_committed_reserve/artifacts/control_comparison.txt - concise expected-versus-vulnerable boundary comparison.

Attachments

RUSDR-001_liquidation_releases_committed_reserve.zip

Comments are hidden

This information is not publicly available.