Status DataClose notification

Rain Disclosed Report

Audit Report

Circuit breaker averages in the manipulated price before comparison and misses above-threshold drops

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Summary

Root cause: On a recording-cadence call, CircuitBreaker.check() writes the current price into its 12-observation ring buffer before calling trendPrice() and measuring deviation. The value under test therefore pulls its own comparison baseline toward itself. Raw downward moves between 25% and 26.67% can fall below the shipped 25% threshold and skip activation.

Exploit condition: After the trend is established and vault collateralization has drifted into the 260%-to-400% buffer, an attacker sustains a narrowly chosen above-threshold RAIN manipulation through the OSM delay. The first honest keeper check() after promotion occurs at least 300 seconds after the last recorded observation. It records the manipulated price and incorrectly leaves the breaker inactive; the attacker observes that result and liquidates the newly unsafe vaults.

Impact: A 26% drop from a clean $0.75 trend is measured as only 24.361%. Across the same five barks, the inactive breaker exposes 50,000 USDR while an active-breaker control exposes 33,616 USDR even with the separate per-call throttle defect. The missed activation therefore adds 16,384 USDR of liquidation capacity, sells 28,114.972 extra RAIN, and creates a marginal 4,702.229-USDR value gap to the clean trend.

Primary proof: pocs/RUSDR-006_circuit_breaker_observation_dilution/artifacts/run_poc.txt

Weakness: Business Logic Errors (HackenProof) / Direct theft of user funds / CWE-682: Incorrect Calculation

Severity: Critical. The program accepts oracle-manipulation attacks and classifies direct theft of user funds as an in-scope impact.

  • The honest keeper's recording-cadence check sees a raw 26% deviation, above the 25% threshold.
  • Current-price insertion changes the comparison trend to $0.73375 and measures only 24.361%, leaving the breaker inactive.
  • The matched active-breaker control proves that missed activation exposes 16,384 extra USDR of capacity and a 4,702.229-USDR marginal value gap.

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

Affected:

  • rain-usdr-contracts commit bd6e03abe34936b7dbece2509b90457bd5c9b119, the revision pinned by the HackenProof scope asset.

Attack Scenario

Five users each open a vault containing 40,000 RAIN and 10,000 USDR of debt while RAIN is $1, exactly meeting the required 400% ratio. The attacker supplies 50,000 USDT through the PSM and internalizes the resulting USDR for auction purchases.

RAIN gradually moves to $0.75 without an above-threshold jump. The users' vaults are now at 300% collateralization: they cannot take new risk because they are below the 400% mat, but they remain above the 260% bark threshold. Twelve clean circuit-breaker observations establish a $0.75 trend.

The attacker sustains a $0.555 source price through the OSM delay, a 26% drop from $0.75. The first honest keeper check after that price becomes current lands on the documented 300-second observation cadence. Correct ordering would compare against the clean $0.75 trend and activate. The implementation instead replaces one $0.75 observation with $0.555 first. The average becomes $0.73375, and the price appears only 24.361% below its self-contaminated trend. The breaker stays inactive, and the attacker acts after observing that keeper transaction.

At $0.555, each target vault appears at 222% collateralization and is barkable. The attacker batches five bark() calls in the same block as the honest check. With the breaker inactive, those calls consume essentially all 50,000 USDR of shipped RAIN capacity. The matched control restores the identical pre-manipulation state, installs an active breaker, and repeats the same five barks. Because the separate per-call throttle defect remains present, even this control consumes 33,616 USDR rather than an ideal 10,000-USDR aggregate cap.

Comparing the two branches isolates the observation-ordering defect: missed activation adds 16,384 USDR of auctions and sells 28,114.972 extra RAIN. At the clean $0.75 trend, those additional sales create a 4,702.229-USDR marginal value gap for the attacker. The PoC still measures the active branch with the existing per-call throttle behavior, so this delta excludes that separately measured throttle defect.

The program excludes incorrect third-party oracle data and states that oracle-manipulation/flash-loan attacks are not excluded. Independently, functional correctness is an explicitly accepted impact. The PoC models the price locally and performs no testing against an oracle or third-party contract.

Technical Details / Evidence

CircuitBreaker.check() records currentPrice at lines 127-136 and only then computes _deviation(currentPrice, trendPrice()) at line 139. Once the ring is full, the current value receives a 1/12 weight in the baseline used to decide whether that same value is anomalous.

For a downward raw deviation d and a 12-value full buffer, the measured deviation after insertion is:

measured = (11 * d) / (12 - d)

At d = 26%, this is 24.361%. Solving measured <= 25% shows that a raw drop in (25%, 26.67%] avoids activation when the first check for that current price is eligible to record an observation—at least obsInterval after the previous recording. Within that state condition, the result is deterministic and does not depend on rounding. A more frequent check before the interval elapses compares against the clean buffer and activates normally.

The contract's own documentation says CircuitBreaker defends against price manipulation so a manipulated price cannot trigger a wave of unfair liquidations. Contaminating the reference before classification contradicts that design.

Once activation is missed, LiquidationTrigger.bark() exposes normal liquidation capacity. DutchAuction.take() transfers the seized collateral at the manipulated auction price, completing the direct-value path.

This activation error is independent of the per-call throttle calculation inside bark. Reordering observation and comparison fixes the missed activation but does not create an aggregate throttle quota. Conversely, enforcing an aggregate throttle while active does not fix a check() that incorrectly leaves the breaker inactive.

Impact

The bug creates a conditional blind band immediately beyond the configured threshold. The manipulated price must persist through the OSM delay, and the first keeper check after it becomes current must be eligible to record an observation. An attacker can time promotion near the public 300-second cadence, observe a diligent keeper's failed activation, and submit the liquidation batch immediately afterward. The claim does not assume that the attacker voluntarily calls check().

The PoC uses shipped debt ceilings, dust, collateral ratio, bark factor, liquidation caps, penalty, auction buffer, breaker threshold, observation interval, and 12-observation window. It snapshots one clean state, measures the vulnerable keeper-check branch, restores the snapshot, and measures the identical five-vault branch with the breaker active. The victims' positions were valid at creation and reached the vulnerable 300% buffer through an ordinary gradual price move.

Because the breaker was added specifically to contain price-manipulation liquidations, missing an above-threshold move exposes user collateral beyond even the current defective active-breaker baseline. The demonstrated marginal outcome is 16,384 USDR of additional auctions, 28,114.972 extra RAIN sold, and a 4,702.229-USDR value gap to the uncontaminated trend. Even if the program's oracle sentence were read narrowly, the broken 25% activation threshold independently meets its accepted functional-correctness impact.

Mitigation / Patch

Compute deviation against the existing trend before writing the current observation:

reference = trendPrice()
deviation = _deviation(currentPrice, reference)
updateObservationBuffer(currentPrice)
applyActivationOrCalmLogic(deviation)

Define explicit bootstrap behavior while the buffer is empty or partially filled, but never include the value being classified in its own reference set. Add boundary tests at 25%, slightly above 25%, and 26.67% with a full ring, asserting both the measured deviation and active state before and after observation insertion.

Validation steps

Proof of Concept

The bundle is in pocs/RUSDR-006_circuit_breaker_observation_dilution/. run.sh fetches the exact scope commit, verifies the checked-out HEAD, installs exact @openzeppelin/[email protected], copies CircuitBreakerObservationDilutionPoC.t.sol into the test directory, and runs only test_currentPriceObservationDilutesDeviationAndPreventsActivation 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-006_circuit_breaker_observation_dilution.zip
    cd RUSDR-006_circuit_breaker_observation_dilution
    
  3. Check prerequisites:
    ./run.sh --preflight
    
  4. Run the compact replay:
    ./run.sh
    
  5. Confirm the result: Observe [PASS] test_currentPriceObservationDilutesDeviationAndPreventsActivation(), then Control: with the breaker active, the same five barks consume 33,616 USDR., Exploit: an honest cadence check dilutes a raw 26% drop to 24.361%, leaving the breaker inactive and exposing 50,000 USDR., Impact: missed activation adds 16,384 USDR of capacity and sells 28,114+ extra RAIN at a 4,702+ USDR marginal gap., and RESULT: PASS.
  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-006_circuit_breaker_observation_dilution.zip - complete deterministic PoC bundle for upload.
  • pocs/RUSDR-006_circuit_breaker_observation_dilution/artifacts/run_poc.txt - primary proof with the native Foundry pass and emitted state deltas.
  • pocs/RUSDR-006_circuit_breaker_observation_dilution/CircuitBreakerObservationDilutionPoC.t.sol - exact-scope activation-bypass, liquidation, and monetization test.
  • pocs/RUSDR-006_circuit_breaker_observation_dilution/artifacts/control_comparison.txt - concise expected-versus-vulnerable boundary comparison.

Attachments

RUSDR-006_circuit_breaker_observation_dilution.zip

Comments are hidden

This information is not publicly available.