Status DataClose notification

Rain Disclosed Report

Audit Report

Missing prospective solvency check lets debt issuance exceed the stable reserve

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Summary

Root cause: VaultEngine.frob() gates risk-increasing volatile-collateral actions using only the pre-state boolean saved by SolvencyEngine.checkInvariant(). Even when that value was refreshed immediately before the action, frob() never evaluates whether the proposed post-state loss breaches the reserve boundary.

Exploit condition: While the pre-state is healthy, an ordinary vault owner can atomically open or modify enough individually safe RAIN vaults to push Stress-MaxLoss above the configured threshold and, when the reserve is smaller than the ceiling-bounded maximum loss, above the full stable reserve.

Impact: The attacker receives transferable USDR after causing the protocol's code-enforced solvency invariant to fail. A later keeper update can stop further issuance but cannot undo the already-created under-reserved liabilities.

Primary proof: pocs/RUSDR-002_stale_solvency_gate/artifacts/run_poc.txt

Weakness: Business Logic Errors (HackenProof) / Protocol insolvency / CWE-754: Improper Check for Unusual or Exceptional Conditions

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

  • The exploit uses only permissionless collateral deposit, vault, and token-adapter operations.
  • The proof mints 400 transferable USDR and raises stress loss from 60 to 120 USDR against a 100-USDR reserve and a 90-USDR breach threshold.

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 holder. A separate PSM depositor supplies 100 USDT to the stable reserve. At the configured launch parameters, one vault containing 800 RAIN and 200 USDR of debt is safe at the live oracle price and contributes 60 USDR of stress loss. Calling checkInvariant() immediately before the exploit records a healthy state because 60 is below the 90-USDR threshold.

The attacker then executes another collateral deposit, vault open, and 200-USDR draw atomically. The second vault passes its individual 400% collateral-ratio check and the debt ceilings. frob() reads the previously stored false breach flag, so it accepts the action without considering that aggregate stress loss will become 120 USDR. The attacker exits all 400 internal USDR as ordinary transferable tokens.

The resulting state has 120 USDR of stress loss against only 100 USDR of stable reserve, yet isBreached() still returns false until a later caller invokes checkInvariant(). Refreshing the flag inside frob() before applying the action would not help: it would still observe the healthy 60-USDR pre-state. Enforcement must evaluate the proposed post-state. A later refresh makes subsequent debt draws revert, but the attacker already owns the issued tokens and the protocol already has 20 USDR of uncovered stress loss. A keeper cannot interleave with the attacker's transaction.

Technical Details / Evidence

VaultEngine.frob() reads ISolvencyEngine(solvencyEngine).isBreached() before applying dart and dink. That view returns only the last stored flag. The function then updates globalArt, globalInk, and total debt and checks only debt ceilings and the individual vault's oracle-price safety. It has no post-state reserve-invariant check.

SolvencyEngine.checkInvariant() is the only function that recomputes and stores breached. The interface itself documents isBreached() as the result of the last check, confirming that the gate is stale between explicit refreshes.

Rain's USDR specification says Stress-MaxLoss(t) <= Stable Reserve(t) is enforced in code at every block, and that the system refuses to extend risk that would breach the floor. An externally scheduled keeper refresh cannot enforce that invariant against an atomic transaction that creates the breach.

Impact

The demonstrated transaction creates 120 USDR of modeled stress loss while only 100 USDR of stable reserve exists. The protocol therefore cannot satisfy the exact solvency guarantee it presents as its core security boundary. The attacker receives 400 transferable USDR after passing all per-vault safety and ceiling checks, and the stored gate remains healthy throughout the transaction. At the shipped 100,000-USDR RAIN debt ceiling and stress parameters, RAIN debt can contribute approximately 30,000 USDR of modeled loss. Full-reserve overshoot is therefore reachable whenever the variable stable reserve is below that ceiling-bounded loss; for larger reserves, the same missing post-state check still permits an atomic breach of the 90% safety threshold up to the remaining debt ceiling.

Mitigation / Patch

Make every risk-increasing volatile-collateral frob() enforce the prospective post-state invariant synchronously. Either add a view that computes worstCaseLoss with the proposed globalArt/globalInk deltas and reject when it exceeds breachThreshold(), or apply the tentative state, call an invariant check, and revert the whole transaction when breached. Keep repayment and collateral top-ups open. Add a regression test that starts below the threshold and verifies the first action that would cross it reverts atomically.

Validation steps

Proof of Concept

The bundle is in pocs/RUSDR-002_stale_solvency_gate/. 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 StaleSolvencyGatePoC.t.sol into the test directory, and runs only test_staleGateAllowsAtomicInvariantBreach under Foundry 1.5.1.

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-002_stale_solvency_gate.zip
    cd RUSDR-002_stale_solvency_gate
    
  3. Check prerequisites:
    ./run.sh --preflight
    
  4. Run the compact replay:
    ./run.sh
    
  5. Confirm the result: Observe [PASS] test_staleGateAllowsAtomicInvariantBreach(), then Control: last checked loss is 60 USDR and the configured threshold is 90 USDR., Exploit: a second vault succeeds and raises live loss to 120 USDR while the stored gate remains false., Impact: stress loss exceeds the full 100-USDR reserve by 20 USDR before any keeper can intervene., 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-002_stale_solvency_gate.zip - complete deterministic PoC bundle for upload.
  • pocs/RUSDR-002_stale_solvency_gate/artifacts/run_poc.txt - primary proof with the native Foundry pass and emitted state deltas.
  • pocs/RUSDR-002_stale_solvency_gate/StaleSolvencyGatePoC.t.sol - exploit and control test against the pinned contracts.
  • pocs/RUSDR-002_stale_solvency_gate/artifacts/control_comparison.txt - concise expected-versus-vulnerable boundary comparison.

Attachments

RUSDR-002_stale_solvency_gate.zip

Comments are hidden

This information is not publicly available.