Where things stand#
| Suite | Command | Result |
|---|---|---|
| Cardano validators (Aiken) | pnpm test:cardano | 131 of 131 checks passing |
| Cardano end-to-end (Lucid emulator) | pnpm test:deploy | Full depeg + exploit-cover flow: 36 steps, 12 of them refused Buys, Settles, Expires and bad committees |
| Midnight circuits (Compact simulator) | pnpm test:midnight | 60 of 60 tests (v1 + v2 registry, claims relay, holder claim kits and the Settle gate, relay plan, ledger decoding) |
| SDK (quote, pool ledger, codecs, evidence, claim kit, committee) | pnpm test:sdk | 209 of 209 tests |
| Oracle relay | pnpm test:relay | 14 of 14 tests |
| Committee enrollment kit | pnpm --filter @plutusshield/committee test | 3 of 3 tests |
Passing tests show the code does what the tests check, nothing more. The value of this page is the mapping below: every rule we rely on names the code that enforces it and the test that would fail if it broke, so a reviewer can look for the rules that have no test.
In scope#
| Component | Source | Holds funds or decides payouts? |
|---|---|---|
| Depeg cover validator | contracts/cardano/validators/cover.ak (opens in a new tab) | Yes. Pool NFT, LP shares per tranche, policy mint, Buy / Settle / Expire, Deposit / Withdraw |
| Exploit cover validator | contracts/cardano/validators/exploit_cover.ak (opens in a new tab) | Yes. Same pool model; Settle needs M-of-N assessor-committee signatures instead of an oracle quorum |
| Oracle, pricing and naming libraries | oracle.ak (opens in a new tab), pricing.ak (opens in a new tab), names.ak (opens in a new tab), types.ak (opens in a new tab) | Yes. Feed authentication, quorum, sale circuit-breaker, premium floor, token names |
| Midnight policy registry v2 (live) | contracts/midnight/src/policy-cover-v2.compact (opens in a new tab) | Decides assessed claims (2-of-3 voteClaim). Holds no funds |
| Midnight policy registry v1 (history) | contracts/midnight/src/policy-cover.compact (opens in a new tab) | Single-assessor resolveClaim, kept for the first Preprod records |
| Off-chain code a payout depends on | packages/sdk (opens in a new tab), services/oracle-relay (opens in a new tab), contracts/midnight/relay (opens in a new tab) | Indirectly. Builds datums and commitments, computes the TWAP the feeds publish, mirrors policies into Midnight |
Out of scope: the marketing site, the share cards, and the demo scripts. The web app's transaction builders (apps/web/src/lib/tx (opens in a new tab)) are in scope only insofar as the validator must reject anything a malicious client could build. The validator is the security boundary, not the UI.
Cardano invariants#
Each row is a rule the validator must enforce on every transaction, with Aiken tests that would fail if it didn't. Test names are verbatim, so you can find each one with grep -n.
| Invariant | Tests |
|---|---|
| Exactly one pool per deployment: InitPool consumes the seed UTxO, and the pool can't move without its NFT | init_pool_consumes_seedinit_pool_without_seed_failspool_cannot_be_spent_without_its_nft |
| Malformed parameters are refused at InitPool (zero quorum, disabled price check, duplicate or missing assets) | init_pool_rejects_zero_quorum_paramsinit_pool_rejects_disabled_price_checkinit_pool_rejects_duplicate_assetsinit_pool_rejects_no_assets |
| LP shares are minted and burned pro rata, per tranche, and never across tranches | deposit_overminting_shares_failsdeposit_minting_other_tranche_lp_failswithdraw_more_than_share_value_failsusdc_withdraw_cannot_also_take_ada |
| Live cover stays fully backed: withdrawals stop at the capital lock, and buys stop at the utilization and single-policy caps | withdraw_below_capital_lock_failsbuy_beyond_utilization_cap_failsbuy_above_single_policy_cap_failsusdc_buy_capacity_is_per_tranche |
| The premium is at least the on-chain floor, in the policy's own currency, booked on its own tranche | buy_underpriced_premium_failsusdc_buy_underpriced_failsusdc_policy_paid_in_ada_failsusdc_buy_booked_on_ada_tranche_failsbuy_in_unaccepted_asset_fails |
| The SDK quote and the validator floor agree exactly | premium_golden_vector_matches_sdkcapacity_rules_match_sdk_capssdk_golden_vectors |
| Cover can't be backdated and starts only after the waiting period | buy_backdated_start_failsbuy_inside_waiting_period_failssettle_event_before_start_fails |
| Sale circuit-breaker: a Buy needs a fresh healthy reading from every allowlisted feed, so no cover is sold into a depeg | buy_during_active_depeg_failsbuy_with_one_feed_depegged_failsbuy_omitting_the_depegged_feed_failsbuy_with_stale_peg_reading_failsbuy_with_forged_peg_feed_failsomitting_a_feed_blocks_sale |
| Depeg Settle needs a quorum of distinct, authenticated, allowlisted feeds whose window meets the trigger inside the cover period | settle_unauthenticated_oracle_failssettle_unlisted_feed_name_failssettle_single_oracle_below_quorum_failssame_feed_twice_does_not_make_quorumsettle_trigger_not_met_failssettle_window_too_short_failssettle_event_after_expiry_fails |
| A policy pays at most once, exactly its coverage, from its own tranche, and only within the claim grace | settle_overpaying_pool_failsdouble_claim_keeping_policy_alive_failssecond_claim_after_payout_failsusdc_policy_cannot_be_paid_from_ada_tranchesettle_after_grace_fails |
| Expiry returns the reference deposit to the buyer's refund address (whoever submits it) and releases only that policy's tranche | expire_by_third_party_still_refunds_buyerexpire_keeping_deposit_failsexpire_short_refund_failsexpire_during_grace_failsexpire_releases_only_the_policy_tranche |
| Policy tokens are minted only through the pool, and a holder can burn only their own user token, never the reference token | mint_via_pool_requires_pool_inputburn_user_tokens_cannot_burn_ref_tokenpolicy_utxo_unlocks_only_with_ref_burn |
| Exploit Settle needs M distinct committee signatures; outsiders and duplicates don't count | exploit_settle_one_of_three_failsexploit_settle_one_assessor_plus_outsiders_failsexploit_settle_duplicate_signer_counted_once_failsexploit_settle_signed_by_someone_else_failscommittee_signatures_counts_members_once |
| A malformed committee can't be deployed (empty, duplicate member, bad key length, threshold outside 1..N) | exploit_init_rejects_empty_committeeexploit_init_rejects_duplicate_assessorexploit_init_rejects_short_assessor_hashexploit_init_rejects_zero_thresholdexploit_init_rejects_threshold_above_size |
| Exploit payouts are exact and end the cover | exploit_settle_overpaying_failsexploit_settle_underpaying_failsexploit_settle_keeping_active_cover_failsexploit_settle_without_burning_user_token_fails |
Midnight invariants#
The registry holds no funds, so its rules protect privacy and the claim decision. Tests run the compiled circuits in the Compact simulator; the names are verbatim from policy-cover.test.mjs (opens in a new tab) and policy-cover-v2.test.mjs (opens in a new tab).
| Invariant | Tests |
|---|---|
| The ledger stores commitments only, never the holder key or the coverage amount | issuer registers a policy; record stores only commitments |
| Only the issuer registers, each policy id once, and only with the holder and coverage the Cardano datum committed to | non-issuer cannot registerduplicate policy id rejectedregisterPolicy refuses a holder or coverage the Cardano datum did not commit to |
| proveCover proves coverage at or above a threshold without revealing it, and only for the real holder with the real opening | holder proves cover >= threshold without revealing amountproof fails above the committed amountproof fails with a forged openingstranger cannot prove or claim on someone else's policy |
| Holder rotation moves control completely: the old key loses every power, and rotation is blocked while a claim is pending or after the policy ends | after rotation the old key can no longer prove, claim or rotatecannot rotate while a claim is pendingcannot rotate after payout or expiry |
| Committee: three distinct members fixed at deployment; one vote per member per claim round; outsiders can't vote | constructor fixes a distinct 3-member committee and a 1..3 thresholda single member cannot vote twice, and outsiders cannot vote at all |
| A claim is decided only at the threshold, and a re-filed claim starts from zero votes | 2-of-3: one approval leaves the claim pending, the second pays ita re-filed claim opens a fresh round; earlier votes do not carry overvotes need a pending claim; paid or expired policies cannot be voted |
| Votes are public and attributable, so every decision names who made it | votes are attributable: the ledger records who voted which way |
| The SDK's commitments equal the compiled circuits byte for byte, so a Cardano datum and a Midnight record always agree | SDK holder / coverage / registration commitments equal the contract pure circuits on random inputsSDK evidenceCommitment equals the contract pure circuit on random inputsv2 keeps v1 commitment schemes byte-for-byte (SDK, Cardano datum and evidence stay valid) |
Privileged roles#
There is no admin key and no pause on either chain: parameters are fixed at deployment. These are the keys that still matter, and who holds them on the testnets today.
| Role | Can | Can't | Held by today |
|---|---|---|---|
| Oracle feed operators (3 Preview feeds, quorum 2) | Publish peg readings. A quorum can trigger depeg payouts; any one feed going stale or reporting a depeg closes sales | Pay a policy outside its cover period or above its coverage, or pay from the wrong tranche | One team operator signs all three feeds |
| Exploit-cover assessor committee (Cardano, 2-of-3) | Co-sign an exploit Settle that pays a policy's exact coverage | Pay more or less than the coverage, pay after the claim grace, or settle with one signature | Team-run (all three keys). Outside operators enroll through /assessors |
| Midnight committee seats (v2, 2-of-3) | Vote a pending claim approved or rejected | Vote twice in a round, vote without a pending claim, or move Cardano funds | Team-run (all three seats) |
| Midnight issuer | Mirror Cardano policies in (registerPolicy) and expire them (expirePolicy) | Register a holder or coverage the buyer didn't commit to in the Cardano datum, or prove or claim for a holder | Team relay |
| Mock tUSDCx minting key (Preview only) | Mint test USDC at will | Anything on mainnet: real USDCx is Circle's asset | Deployer key |
Cardano can't read Midnight. An exploit payout is trusted to the Cardano committee's signatures; each Settle carries tx metadata (label 7732) naming the Midnight decision, so every payout can be checked against a public Midnight record after the fact, but the validator itself doesn't verify it.
Known gaps#
Open items an auditor should know about before starting. Each one is also disclosed on the Risks page.
- Stale-but-healthy readings. Each oracle reading is its own UTxO, so a healthy reading stays usable for a Buy until it passes the max price age (2h by default), even after a newer reading reports a depeg. The waiting period limits the damage; the fix is a state-thread oracle with one live UTxO per feed.
- No oracle dispute window. A colluding quorum of feeds can trigger payouts, and nothing on-chain challenges them.
- Single-operator testnet roles. Every feed, committee key, committee seat, and the issuer is team-run on the testnets, so today's quorums prove the mechanics, not independence.
- No upgrade path. With no admin key, a bug is fixed by a new deployment and LPs moving their capital.
- No withdrawal delay. Better-informed LPs can withdraw free capital ahead of an event; only the capital lock limits this.
- Coverage is public on Cardano. The Midnight record hides it, but the Cardano datum doesn't yet.
- Exploit claim filing is holder-side.
fileClaimneeds the holder's Midnight key in a proving client. On /claim/evidence, File with Lace uses the local holder prove bridge for Compact prove and Lace for balance + submit; until that path has a finalized Preprod drill tx, production filing is the passphrase-encrypted claim kit (--claim … --kit …). Either way the key never goes to the operator relay. - Young toolchains. Pinned to Aiken v1.1.24 (stdlib v4.0.0), compactc 0.31.1 and compact-runtime 0.16.0. Compiler bugs are a real risk, but they sit outside this audit.
Reproduce the suite#
From a clean clone with Node 20+, pnpm 9, Aiken v1.1.24 and the Compact toolchain installed, one command runs everything in the table above:
pnpm install && pnpm testThe live testnet records the tests are compared against are public: the Preview deployment record (opens in a new tab), the Preprod v2 deployment record (opens in a new tab), and every policy's timeline on /policy.
Report a vulnerability#
Please report privately through a GitHub security advisory (opens in a new tab) on the repository rather than a public issue. Include the component, the transaction or test that shows the problem, and the testnet tx hash if you reproduced it on Preview or Preprod. The full policy is in SECURITY.md (opens in a new tab).
Grounded in
- SECURITY.md (opens in a new tab)
- contracts/cardano/validators/cover.ak (opens in a new tab)
- contracts/cardano/validators/exploit_cover.ak (opens in a new tab)
- contracts/cardano/lib/plutusshield/oracle.ak (opens in a new tab)
- contracts/midnight/src/policy-cover-v2.compact (opens in a new tab)
- contracts/midnight/test/policy-cover-v2.test.mjs (opens in a new tab)