Skip to content
PlutusShield
Live on Cardano Preview testnet

Security & audit scope

What an auditor would review, the rules the contracts must never break, the tests that pin each rule down, and who holds which keys today. Written for reviewers; nothing here is a claim of safety.

← Back to site
DocsSecurity & audit scope

Where things stand#

Automated checks on main (recorded Oct 13, 2026 at commit e7269f3 by pnpm test:report)
SuiteCommandResult
Cardano validators (Aiken)pnpm test:cardano131 of 131 checks passing
Cardano end-to-end (Lucid emulator)pnpm test:deployFull depeg + exploit-cover flow: 36 steps, 12 of them refused Buys, Settles, Expires and bad committees
Midnight circuits (Compact simulator)pnpm test:midnight60 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:sdk209 of 209 tests
Oracle relaypnpm test:relay14 of 14 tests
Committee enrollment kitpnpm --filter @plutusshield/committee test3 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#

Audit scope
ComponentSourceHolds funds or decides payouts?
Depeg cover validatorcontracts/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 validatorcontracts/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 librariesoracle.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 onpackages/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.

Cardano invariants and their tests
InvariantTests
Exactly one pool per deployment: InitPool consumes the seed UTxO, and the pool can't move without its NFTinit_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 tranchesdeposit_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 capswithdraw_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 tranchebuy_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 exactlypremium_golden_vector_matches_sdkcapacity_rules_match_sdk_capssdk_golden_vectors
Cover can't be backdated and starts only after the waiting periodbuy_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 depegbuy_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 periodsettle_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 gracesettle_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 trancheexpire_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 tokenmint_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 countexploit_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 coverexploit_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).

Midnight invariants and their tests
InvariantTests
The ledger stores commitments only, never the holder key or the coverage amountissuer 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 tonon-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 openingholder 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 endsafter 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 voteconstructor 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 votes2-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 itvotes 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 agreeSDK 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.

Privileged roles
RoleCanCan'tHeld 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 salesPay a policy outside its cover period or above its coverage, or pay from the wrong trancheOne 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 coveragePay more or less than the coverage, pay after the claim grace, or settle with one signatureTeam-run (all three keys). Outside operators enroll through /assessors
Midnight committee seats (v2, 2-of-3)Vote a pending claim approved or rejectedVote twice in a round, vote without a pending claim, or move Cardano fundsTeam-run (all three seats)
Midnight issuerMirror 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 holderTeam relay
Mock tUSDCx minting key (Preview only)Mint test USDC at willAnything on mainnet: real USDCx is Circle's assetDeployer 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. fileClaim needs 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 test

The 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).