security/ops: shielded pool threat model, abuse controls, relayer operations and staged rollout #1587

Open
opened 2026-10-29 00:34:52 +00:00 by PlasticDigits · 0 comments
Owner

Problem and scope

Operate and govern the shielded pool safely. This issue is the program layer for #1583 (pool), #1584 (private swaps), #1585 (indexer/API) and #1586 (dApp): the threat model and precise privacy claims, the abuse/compliance policy, the relayer reference service and its key operations, solvency/privacy monitoring, incident playbooks, the audit and supply-chain gate, and the staged rollout with hard caps.

It does not implement the contracts or clients. It must be completed before any mainnet deployment with material value, and it must produce machine-checkable gates (config caps, alerts, runbooks, review sign-off) rather than prose only.

Current codebase and investigation

Reviewed checkout: 38c154958.

  • Security posture and trust model: docs/security-posture.md (TVL bands, audit status, admin controls, residual risks), docs/security-model.md (governance, hooks, off-chain trust boundaries), docs/contracts-security-audit.md (invariant matrix P1–L17 and residual risks), docs/exploit-replay-matrix.md, docs/user-incident-faq.md, docs/CG_CMC_COMPLIANCE.md.
  • Operator controls: docs/runbooks/launch-checklist.md, docs/runbooks/wasm-admin-migration.md, docs/runbooks/key-custody.md, docs/runbooks/cw20-whitelist-policy.md, docs/runbooks/cw20-code-id-ops.md, docs/runbooks/governance-emergency-rehearsal.md, docs/runbooks/anomaly-signals.md, docs/reference/governance-multisig.md, docs/templates/deploy-trace.md.
  • Governance: factory/DEX 2-of-3 for factory/router/pairs/fee-discount and the ustr-cmm treasury; ust1-window/wrap-oracle and listed wrap CW20 controls have EOA residuals tracked on #526/#697. Production multisig terra1zlmv2xydxcusurtr6rl78wsvytdc6mfex6hep7.
  • Supply chain and code-id assurance: docs/supply-chain-security.md, cw20-codeid-audits/{PROCEDURE.md,CATALOG.md}, smartcontracts/artifacts/build-provenance.json, optimizer/checksums, docs/qa/issue-589/README.md, docs/qa/issue-623/README.md.
  • Monitoring: Prometheus/Grafana work is #1544 (monitoring/, docs/runbooks/dex-prometheus-monitoring.md, make verify-issue-1544); anomaly thresholds per SEC-G02/#435.
  • Evidence/privacy precedent: docs/qa/issue-1397/README.md (schema 2, no actor identifiers, explicit non-anonymity language), #1206 aggregate digest, #1202 privacy-reviewed product events.
  • There is no relayer, no shielded-specific monitoring, no solvency invariant alert, no note-loss playbook, no shielding abuse/compliance policy, no cap-change procedure for this product, and no staged rollout plan. docs/security-posture.md does not mention shielding at all, so the public posture and the dApp footer would currently be silent on a materially different risk class.

Why a new implementation is needed

A note pool changes the risk shape in ways the existing DEX posture does not cover:

  • Custody concentration: one contract holds all shielded balances. A bug, a compromised upgrade key or a wrong code id is a single, large blast radius, not a per-pair risk bounded by liquidity.
  • Bearer notes: a lost note key/backup is irreversible loss; a stolen key is theft that no admin can freeze or reverse. Support and incident response must say this plainly and must not promise recovery.
  • Privacy claims: "shielded" invites users and regulators to assume anonymity. The actual guarantee is narrow (DEX-level non-attribution, pool-executed swaps) and must be stated with the same precision as #1397's evidence policy.
  • Abuse surface: pooled balances and a relayer can be used for structuring, wash volume, blacklist evasion, or general mixing if the allowlist and caps are loosened. The feature is not a mixer, but without an explicit policy and monitoring it will be treated as one.
  • Operational blind spots: a silent liability/balance mismatch, a nullifier replay attempt, a tree bug or a relayer compromise are not detectable with the current DEX dashboards.

Relevant files

  • docs/shielded-pool.md (threat model, claim matrix; created by #1583 and hardened here)
  • docs/security-posture.md, docs/security-model.md, docs/contracts-security-audit.md, docs/user-incident-faq.md, docs/CG_CMC_COMPLIANCE.md
  • docs/runbooks/: new shielded-pool-operations.md, shielded-pool-incident.md, shielded-relayer.md, shielded-cap-changes.md; updates to launch-checklist.md, anomaly-signals.md, wasm-admin-migration.md, key-custody.md, cw20-whitelist-policy.md
  • monitoring/ (dashboards, alert rules), docs/runbooks/dex-prometheus-monitoring.md
  • scripts/ (relayer reference service, reconciliation probe, cap audit, verify-issue-<N>)
  • cw20-codeid-audits/ (new code id report), docs/qa/issue-<N>/README.md, skills/AGENTS_SHIELDED_OPS.md
  1. Threat model and claim matrix. Extend docs/shielded-pool.md with assets (pool CW20 balances, note keys, relayer gas key, indexer data, user devices), actors (user, relayer, governance, wasm admin, indexer operator, chain analyst, attacker), trust boundaries, and a table of guarantees: what is hidden (DEX attribution; the pool is the trader), what is public (amounts, deposit tx, note graph, timing, pool address), what is not provided (anonymity, amount privacy, mixer-grade unlinkability, sanction resistance). Bind each claim to a test or a documented limitation. Update security-posture.md and the user incident FAQ so the public posture and the dApp notice agree. Remove/forbid any anonymity or "untraceable" wording across docs, UI and issue text.

  2. Abuse and compliance policy. Write an explicit policy, wired into config and reviews:

    • allowlisted CL8Y-controlled tokens only; no third-party tokens, no native assets, no P2P notes, no cross-pool transfers, no generic mixer use;
    • deposit/withdraw/swap caps: per note, per token TVL, per block, per address per epoch, and a global cap that only governance may raise under § 6;
    • screening at the visible edges: reject a deposit whose visible sender is on the factory trading blacklist and a withdrawal whose destination is blacklisted, while documenting that note owners cannot be screened inside the pool and that this is a bearer system;
    • no fee-tier or exemption path for the pool; the pool is never added to PROTOCOL_EXEMPT/MANAGER_EXEMPT/the discount registry;
    • a sanctions/legal position and record-keeping scope (public chain data only; no note-key collection), and a prohibited-use statement; obtain a written legal/compliance review before mainnet;
    • a relayer policy: permissionless, no custody, may refuse, no user-specific tracking, published fee.
  3. Relayer reference service. Ship a small, stateless service (in scripts/ or a separate package, not in the indexer request path) that accepts a fully formed signed pool message, validates the fee bound and deadline, attaches the outer fee/gas, broadcasts, and returns the tx hash. Requirements: no note-key or calldata retention beyond the in-memory request; no IP logging beyond a bounded rate-limit bucket; rate limits and per-tx gas caps; a dedicated low-balance fee key with rotation and alerting; health/readiness; refusal and error responses; documented permissionless alternatives so a single relayer is never required; an explicit statement that the relayer sees the request (destination/amount/opening) and the user's network metadata. Do not build a relayer that can alter the signed message; the contract binding is the backstop.

  4. Monitoring and invariants. Add alerts and a dashboard for:

    • per-token solvency: on-chain CW20 balance vs LIABILITY + pending settlement; any negative delta pages immediately; a persistent mismatch pauses deposits (governance action) and opens an incident;
    • note/leaf growth, root age/history saturation, nullifier consumption rate, duplicate/burned-nullifier attempts, failed spends;
    • deposit/withdraw/swap volume and cap utilisation, per-block/per-address cap hits, blocked deposits/withdrawals;
    • pool code id/checksum and router code id drift, allowlist changes, PauseDeposits and UpdateConfig events, wasm admin/migration events;
    • relayer error/latency/refusal rate and fee-key balance;
    • indexer classification gaps (ambiguous shielded rows), API 4xx/429 rates and note-endpoint budget saturation.
      Metrics and logs must not contain note keys, openings, wallet addresses or user-identifying request data. Reuse #1544's Prometheus/Grafana stack and the anomaly-signals conventions; add a reconciliation probe script and a documented test that fires each alert in staging.
  5. Incident playbooks. Add shielded-pool-incident.md covering: solvency mismatch; a suspected tree/commitment bug; a note-key theft report; a relayer compromise or censorship event; a hostile/malformed note event; code-id drift or an unexpected migration; a paused pair/token interacting with shielded swaps; chain halt/reorg; and a governance-key compromise. For each: detection, immediate actions (what governance may and may not do), user communication, evidence preservation, disclosure, and the fact that there is no admin clawback/freeze of notes. Include a tabletop/dry-run with receipts, and a docs/qa/issue-<N>/ record.

  6. Audit, supply chain and staged rollout. Gate the program:

    • internal independent agent review plus, if available, an external audit of the new contract and router delta; publish the scope and findings; do not raise caps before remediation;
    • cw20-codeid-audits-style decompile/checksum for the pool and any new dependency (ed25519/hash), build provenance and optimizer checksums;
    • a bug-bounty/disclosure channel and a security.txt, with an explicit note that note loss/key theft is not recoverable;
    • staged rollout: LocalTerra → a capped testnet/staging deploy → mainnet with a deliberately low per-token/global cap, then cap increases only after a defined observation window (e.g. weeks), clean solvency/alert history and a fresh review. Each stage has exit criteria and a recorded decision. The kill switch is PauseDeposits; withdrawals remain live; state-preserving migration is the only upgrade path.
    • a make verify-issue-<N> harness that checks docs cross-links, cap/config values, alert rules exist, runbooks are linked, and the deployment trace records the pool/router code ids and checksums. Do not mutate production during verification.
  7. Governance and key operations. Document the pool's admin surface (config/caps/deposit pause/router rotation only), the 2-of-3 (or better) signer roster and rotation, monitoring of admin transactions, and the rule that no key can move notes or block withdrawals. Coordinate with the existing #526/#697 governance-split work; do not introduce a new EOA residual. A cap increase or a router rotation is a reviewed, logged action with a deploy trace.

  8. Public communication. Add a short, accurate shielding section to security-posture.md and the incident FAQ, link it from the dApp legal footer, and keep it in sync with #1586's notice. State the risk class, the cap, the audit status, the bearer-note loss risk, the absence of anonymity, and the support limits. Provide an anonymized incident-reporting path that never asks for a note key or seed phrase.

Constraints and guardrails

  • No anonymity claims. Every public surface (docs, dApp, listings, issue text, marketing) must say what is and is not hidden, and must not equate shielding with anonymity, untraceability, tax evasion or a mixer. Any claim must map to a test or a documented limitation.
  • No new fund-moving admin. Governance may change config/caps, pause deposits and rotate the router; it may not move, spend, freeze or seize notes. Do not add a "rescue" or "migration sweep" path. If a bug requires a state migration, it must preserve notes and liability and be reviewed.
  • Caps are hard limits. Initial caps must be deliberately small and written into the deploy trace/config; raising them requires the documented review + observation evidence. No "temporary" bypass by config in the frontend or relayer.
  • Privacy of operations. Monitoring, logs, metrics, relayer logs and incident records must not contain note keys, openings, wallet addresses, IP+intent tuples or user conversation. Aggregate counters only. Access to any incident data is least-privilege and time-bounded.
  • No production mutation for QA. Use LocalTerra/staging and disposable DBs (#1396); read-only production probes only. Do not publish exploit reproduction details that enable theft.
  • Supply chain: new crypto dependencies need a review, pin and provenance; builds use the optimizer and checksum pinning; no unverified wasm.
  • Honest failure: unavailable live/mainnet checks are explicit SKIPs in docs/qa/issue-<N>/README.md; executed failures remain FAIL. No issue closure, cap increase or "deployed" claim without real evidence.

Acceptance criteria

  • AC1: docs/shielded-pool.md contains the threat model, asset/actor table, claim matrix, explicit non-guarantees, key-loss model and gas/audit status; security-posture.md, security-model.md, contracts-security-audit.md and the user incident FAQ are updated and cross-linked; no anonymity/mixer/untraceable wording remains anywhere.
  • AC2: A written abuse/compliance policy covers allowlist, caps, edge screening, sanctions/legal position, record-keeping, prohibited use, relayer rules and the "not a mixer" statement, with a recorded legal/compliance review before mainnet.
  • AC3: The relayer reference service is deployable, stateless, rate-limited, fee/min-output/deadline-validating, uses a rotated low-balance fee key, logs no note data/IP-intent tuples, and has a documented permissionless fallback; a red-team of altered destination/fee/route and duplicate submit passes.
  • AC4: Monitoring includes per-token solvency vs liability + pending, nullifier/anomaly, cap, code-id drift, pause/config/admin and relayer alerts; each alert has a documented threshold and a staging test that fires it; metrics/logs contain no note/key/wallet data.
  • AC5: shielded-pool-operations.md and shielded-pool-incident.md cover solvency mismatch, tree/commitment bug, key theft, relayer compromise/censorship, code-id drift, pause interactions, chain/reorg, governance compromise, disclosure and user communication; a tabletop/dry-run receipt exists.
  • AC6: The audit/supply-chain gate is recorded: internal review, external audit (if available) with scope/findings/remediation, decompile/checksum for the pool and new dependencies, build provenance and a bug-bounty/disclosure channel.
  • AC7: A staged rollout plan with explicit per-stage caps, exit criteria, observation windows and recorded decisions exists; the mainnet deploy trace records pool/router code ids, checksums, cap values and the governance signer set; cap increases require the documented evidence.
  • AC8: Governance docs state the admin surface and the no-fund-moving/no-withdrawal-block rule; admin transactions are monitored; no new EOA residual is introduced; #526/#697 coordination is recorded.
  • AC9: make verify-issue-<N> checks the docs cross-links, cap/config values, alert rules, runbook links and deploy-trace fields, and docs/qa/issue-<N>/README.md records the evidence and explicit skips.
  • AC10: No user conversation, personal data, reporter attribution, wallet-owner identity, note key or mnemonic appears in docs, monitoring, issues, receipts or logs.

Test plan: functional paths

Path Required checks
Solvency Deposit/withdraw/change/swap/failed tx/tax-affected deposit; liability vs CW20 balance; pending settlement; forced mismatch via a test mutant; alert fires; deposits pause; withdrawals remain live.
Alerts Each rule (solvency, nullifier anomaly, cap hit, code-id drift, pause/config/admin, relayer, API budget) fires in staging and resolves; no note/key/address in labels or annotations.
Relayer Success, refusal, timeout, duplicate submit, altered destination/fee/route/owner, fee cap, gas cap, rate limit, key rotation, drained fee key, health/readiness, permissionless alternate.
Docs/claims Claim matrix vs contract/API/UI behaviour; no forbidden wording; dApp notice and incident FAQ agree; links from footer and runbooks work.
Caps/rollout Initial caps at/below the policy; cap audit script; increase/deploy trace; stage exit criteria; rollback; pause/unpause; migration with pending settlements.
Incident Tabletop for each scenario; evidence preservation; user notice; disclosure; support script rejects note-key/seed requests; no admin fund movement is proposed.
Governance 2-of-3 signer roster/rotation; admin tx monitoring; router rotation; config update; pause; all logged with a deploy trace.
Supply chain Optimizer build, checksum pin, decompile report, dependency pin/licence/provenance, bug-bounty/security.txt reachability.

Test plan: attacks, hacks and abuse

  • Money laundering/structuring/sanctions: many small deposits across addresses, deposit/withdraw amount matching, rapid in/out, P2P attempts, cross-pool asks, sanctioned/blacklisted visible senders/destinations, and requests to raise caps. Verify edge screening, caps, refusal/records, and that the docs do not market the pool as a mixer; legal review covers the residual.
  • Blacklist/tax/fee evasion: try to add the pool to PROTOCOL_EXEMPT/MANAGER_EXEMPT/the fee-discount registry, register a tier with the pool, route through the pool to avoid launch guards, or use a user-supplied trader; verify token/contract tests reject it and the policy/ops checks detect an attempted change.
  • Wash trading/incentive gaming: self-shield/self-swap cycles to inflate pair volume or listings, and cap/leaderboard gaming across note keys. Volume is economic and no shielded trader rank exists; document and monitor for anomalous self-flow; ensure no reward path keys on it.
  • Relayer collusion/censorship/DoS: relayer alters the signed fields (must revert), withholds, front-runs, leaks the request, refuses a user, or is drained/blocked. Verify binding, logs, permissionless alternates, rate limits and incident playbook.
  • Key/backup theft: stolen device/backup/passphrase, phishing for note keys, support impersonation, malicious backup import, shared-device residue. Confirm no recovery promise, guidance, and incident handling that does not request secrets.
  • Contract/upgrade: a buggy or malicious migration, code-id drift, a rogue router, a governance-key compromise, a dependency backdoor, or a wasm-admin mistake. Verify pins/checks, monitoring, review gates, state-preserving migration tests and disclosure.
  • Monitoring/privacy leakage: note keys/addresses in metrics, logs, alerts, dashboards, traces, error messages, or third-party monitoring. Run a static scan and a live staging capture; restrict access.
  • Economic/oracle interaction: shielded swaps moving thin pools, manipulating candles/TVL/price or washing DeFiLlama/GT volume; verify the existing price/oracle/TVL guards still apply and cap the product's size.
  • Chain-level: halt/reorg/upgrade while notes are pending, a pool pause/unpause race, a token migration during settlement. Playbooks and state checks must fail closed and preserve notes.

Verification criteria

  • make verify-issue-<N> runs the docs/claim cross-link checks, cap/config audit, alert-rule presence test, deploy-trace field check and the relayer unit/red-team tests; it must not mutate production.
  • Staging receipts show each alert firing and resolving; the solvency mismatch test pauses deposits and leaves withdrawals live; logs/metrics contain no note/key/wallet data (capture evidence).
  • The staged rollout record includes the mainnet cap values, pool/router code ids/checksums, governance roster, audit/review outcomes and the decision log; a cap increase without the evidence is FAIL.
  • The incident tabletop/dry-run receipt and the relayer red-team receipt are stored in docs/qa/issue-<N>/README.md, with explicit skips for unavailable external audits or production checks. Executed failures remain FAIL.
  • No conversation, personal data, reporter attribution, wallet-owner identity, note key or mnemonic appears in docs, monitoring, issue text, receipts or logs.

Out of scope / follow-ups

  • Contract/cryptography (#1583), private swap execution (#1584), indexer/API (#1585), dApp (#1586).
  • ZK/encrypted notes, P2P transfers, cross-pool swaps, third-party token admission, and any expansion of the claim surface: not in phase 1 and requires a new threat-model/audit cycle if proposed.
## Problem and scope Operate and govern the shielded pool safely. This issue is the program layer for #1583 (pool), #1584 (private swaps), #1585 (indexer/API) and #1586 (dApp): the threat model and precise privacy claims, the abuse/compliance policy, the relayer reference service and its key operations, solvency/privacy monitoring, incident playbooks, the audit and supply-chain gate, and the staged rollout with hard caps. It does not implement the contracts or clients. It must be completed **before** any mainnet deployment with material value, and it must produce machine-checkable gates (config caps, alerts, runbooks, review sign-off) rather than prose only. ## Current codebase and investigation Reviewed checkout: `38c154958`. - Security posture and trust model: `docs/security-posture.md` (TVL bands, audit status, admin controls, residual risks), `docs/security-model.md` (governance, hooks, off-chain trust boundaries), `docs/contracts-security-audit.md` (invariant matrix P1–L17 and residual risks), `docs/exploit-replay-matrix.md`, `docs/user-incident-faq.md`, `docs/CG_CMC_COMPLIANCE.md`. - Operator controls: `docs/runbooks/launch-checklist.md`, `docs/runbooks/wasm-admin-migration.md`, `docs/runbooks/key-custody.md`, `docs/runbooks/cw20-whitelist-policy.md`, `docs/runbooks/cw20-code-id-ops.md`, `docs/runbooks/governance-emergency-rehearsal.md`, `docs/runbooks/anomaly-signals.md`, `docs/reference/governance-multisig.md`, `docs/templates/deploy-trace.md`. - Governance: factory/DEX 2-of-3 for factory/router/pairs/fee-discount and the ustr-cmm treasury; ust1-window/wrap-oracle and listed wrap CW20 controls have EOA residuals tracked on #526/#697. Production multisig `terra1zlmv2xydxcusurtr6rl78wsvytdc6mfex6hep7`. - Supply chain and code-id assurance: `docs/supply-chain-security.md`, `cw20-codeid-audits/{PROCEDURE.md,CATALOG.md}`, `smartcontracts/artifacts/build-provenance.json`, optimizer/checksums, `docs/qa/issue-589/README.md`, `docs/qa/issue-623/README.md`. - Monitoring: Prometheus/Grafana work is #1544 (`monitoring/`, `docs/runbooks/dex-prometheus-monitoring.md`, `make verify-issue-1544`); anomaly thresholds per SEC-G02/#435. - Evidence/privacy precedent: `docs/qa/issue-1397/README.md` (schema 2, no actor identifiers, explicit non-anonymity language), #1206 aggregate digest, #1202 privacy-reviewed product events. - There is **no** relayer, no shielded-specific monitoring, no solvency invariant alert, no note-loss playbook, no shielding abuse/compliance policy, no cap-change procedure for this product, and no staged rollout plan. `docs/security-posture.md` does not mention shielding at all, so the public posture and the dApp footer would currently be silent on a materially different risk class. ## Why a new implementation is needed A note pool changes the risk shape in ways the existing DEX posture does not cover: - **Custody concentration:** one contract holds all shielded balances. A bug, a compromised upgrade key or a wrong code id is a single, large blast radius, not a per-pair risk bounded by liquidity. - **Bearer notes:** a lost note key/backup is irreversible loss; a stolen key is theft that no admin can freeze or reverse. Support and incident response must say this plainly and must not promise recovery. - **Privacy claims:** "shielded" invites users and regulators to assume anonymity. The actual guarantee is narrow (DEX-level non-attribution, pool-executed swaps) and must be stated with the same precision as #1397's evidence policy. - **Abuse surface:** pooled balances and a relayer can be used for structuring, wash volume, blacklist evasion, or general mixing if the allowlist and caps are loosened. The feature is not a mixer, but without an explicit policy and monitoring it will be treated as one. - **Operational blind spots:** a silent liability/balance mismatch, a nullifier replay attempt, a tree bug or a relayer compromise are not detectable with the current DEX dashboards. ## Relevant files - `docs/shielded-pool.md` (threat model, claim matrix; created by #1583 and hardened here) - `docs/security-posture.md`, `docs/security-model.md`, `docs/contracts-security-audit.md`, `docs/user-incident-faq.md`, `docs/CG_CMC_COMPLIANCE.md` - `docs/runbooks/`: new `shielded-pool-operations.md`, `shielded-pool-incident.md`, `shielded-relayer.md`, `shielded-cap-changes.md`; updates to `launch-checklist.md`, `anomaly-signals.md`, `wasm-admin-migration.md`, `key-custody.md`, `cw20-whitelist-policy.md` - `monitoring/` (dashboards, alert rules), `docs/runbooks/dex-prometheus-monitoring.md` - `scripts/` (relayer reference service, reconciliation probe, cap audit, `verify-issue-<N>`) - `cw20-codeid-audits/` (new code id report), `docs/qa/issue-<N>/README.md`, `skills/AGENTS_SHIELDED_OPS.md` ## Recommended direction 1. **Threat model and claim matrix.** Extend `docs/shielded-pool.md` with assets (pool CW20 balances, note keys, relayer gas key, indexer data, user devices), actors (user, relayer, governance, wasm admin, indexer operator, chain analyst, attacker), trust boundaries, and a table of guarantees: what is hidden (DEX attribution; the pool is the trader), what is public (amounts, deposit tx, note graph, timing, pool address), what is **not** provided (anonymity, amount privacy, mixer-grade unlinkability, sanction resistance). Bind each claim to a test or a documented limitation. Update `security-posture.md` and the user incident FAQ so the public posture and the dApp notice agree. Remove/forbid any anonymity or "untraceable" wording across docs, UI and issue text. 2. **Abuse and compliance policy.** Write an explicit policy, wired into config and reviews: - allowlisted CL8Y-controlled tokens only; no third-party tokens, no native assets, no P2P notes, no cross-pool transfers, no generic mixer use; - deposit/withdraw/swap caps: per note, per token TVL, per block, per address per epoch, and a global cap that only governance may raise under § 6; - screening at the visible edges: reject a deposit whose visible sender is on the factory trading blacklist and a withdrawal whose destination is blacklisted, while documenting that note owners cannot be screened inside the pool and that this is a bearer system; - no fee-tier or exemption path for the pool; the pool is never added to `PROTOCOL_EXEMPT`/`MANAGER_EXEMPT`/the discount registry; - a sanctions/legal position and record-keeping scope (public chain data only; no note-key collection), and a prohibited-use statement; obtain a written legal/compliance review before mainnet; - a relayer policy: permissionless, no custody, may refuse, no user-specific tracking, published fee. 3. **Relayer reference service.** Ship a small, stateless service (in `scripts/` or a separate package, not in the indexer request path) that accepts a fully formed signed pool message, validates the fee bound and deadline, attaches the outer fee/gas, broadcasts, and returns the tx hash. Requirements: no note-key or calldata retention beyond the in-memory request; no IP logging beyond a bounded rate-limit bucket; rate limits and per-tx gas caps; a dedicated low-balance fee key with rotation and alerting; health/readiness; refusal and error responses; documented permissionless alternatives so a single relayer is never required; an explicit statement that the relayer sees the request (destination/amount/opening) and the user's network metadata. Do not build a relayer that can alter the signed message; the contract binding is the backstop. 4. **Monitoring and invariants.** Add alerts and a dashboard for: - per-token solvency: on-chain CW20 balance vs `LIABILITY` + pending settlement; any negative delta pages immediately; a persistent mismatch pauses deposits (governance action) and opens an incident; - note/leaf growth, root age/history saturation, nullifier consumption rate, duplicate/burned-nullifier attempts, failed spends; - deposit/withdraw/swap volume and cap utilisation, per-block/per-address cap hits, blocked deposits/withdrawals; - pool code id/checksum and router code id drift, allowlist changes, `PauseDeposits` and `UpdateConfig` events, wasm admin/migration events; - relayer error/latency/refusal rate and fee-key balance; - indexer classification gaps (ambiguous shielded rows), API 4xx/429 rates and note-endpoint budget saturation. Metrics and logs must not contain note keys, openings, wallet addresses or user-identifying request data. Reuse #1544's Prometheus/Grafana stack and the anomaly-signals conventions; add a reconciliation probe script and a documented test that fires each alert in staging. 5. **Incident playbooks.** Add `shielded-pool-incident.md` covering: solvency mismatch; a suspected tree/commitment bug; a note-key theft report; a relayer compromise or censorship event; a hostile/malformed note event; code-id drift or an unexpected migration; a paused pair/token interacting with shielded swaps; chain halt/reorg; and a governance-key compromise. For each: detection, immediate actions (what governance may and may not do), user communication, evidence preservation, disclosure, and the fact that there is **no** admin clawback/freeze of notes. Include a tabletop/dry-run with receipts, and a `docs/qa/issue-<N>/` record. 6. **Audit, supply chain and staged rollout.** Gate the program: - internal independent agent review plus, if available, an external audit of the new contract and router delta; publish the scope and findings; do not raise caps before remediation; - `cw20-codeid-audits`-style decompile/checksum for the pool and any new dependency (`ed25519`/hash), build provenance and optimizer checksums; - a bug-bounty/disclosure channel and a `security.txt`, with an explicit note that note loss/key theft is not recoverable; - staged rollout: LocalTerra → a capped testnet/staging deploy → mainnet with a deliberately low per-token/global cap, then cap increases only after a defined observation window (e.g. weeks), clean solvency/alert history and a fresh review. Each stage has exit criteria and a recorded decision. The kill switch is `PauseDeposits`; withdrawals remain live; state-preserving migration is the only upgrade path. - a `make verify-issue-<N>` harness that checks docs cross-links, cap/config values, alert rules exist, runbooks are linked, and the deployment trace records the pool/router code ids and checksums. Do not mutate production during verification. 7. **Governance and key operations.** Document the pool's admin surface (config/caps/deposit pause/router rotation only), the 2-of-3 (or better) signer roster and rotation, monitoring of admin transactions, and the rule that no key can move notes or block withdrawals. Coordinate with the existing #526/#697 governance-split work; do not introduce a new EOA residual. A cap increase or a router rotation is a reviewed, logged action with a deploy trace. 8. **Public communication.** Add a short, accurate shielding section to `security-posture.md` and the incident FAQ, link it from the dApp legal footer, and keep it in sync with #1586's notice. State the risk class, the cap, the audit status, the bearer-note loss risk, the absence of anonymity, and the support limits. Provide an anonymized incident-reporting path that never asks for a note key or seed phrase. ## Constraints and guardrails - **No anonymity claims.** Every public surface (docs, dApp, listings, issue text, marketing) must say what is and is not hidden, and must not equate shielding with anonymity, untraceability, tax evasion or a mixer. Any claim must map to a test or a documented limitation. - **No new fund-moving admin.** Governance may change config/caps, pause deposits and rotate the router; it may not move, spend, freeze or seize notes. Do not add a "rescue" or "migration sweep" path. If a bug requires a state migration, it must preserve notes and liability and be reviewed. - **Caps are hard limits.** Initial caps must be deliberately small and written into the deploy trace/config; raising them requires the documented review + observation evidence. No "temporary" bypass by config in the frontend or relayer. - **Privacy of operations.** Monitoring, logs, metrics, relayer logs and incident records must not contain note keys, openings, wallet addresses, IP+intent tuples or user conversation. Aggregate counters only. Access to any incident data is least-privilege and time-bounded. - **No production mutation for QA.** Use LocalTerra/staging and disposable DBs (#1396); read-only production probes only. Do not publish exploit reproduction details that enable theft. - **Supply chain:** new crypto dependencies need a review, pin and provenance; builds use the optimizer and checksum pinning; no unverified wasm. - **Honest failure:** unavailable live/mainnet checks are explicit SKIPs in `docs/qa/issue-<N>/README.md`; executed failures remain FAIL. No issue closure, cap increase or "deployed" claim without real evidence. ## Acceptance criteria - [ ] AC1: `docs/shielded-pool.md` contains the threat model, asset/actor table, claim matrix, explicit non-guarantees, key-loss model and gas/audit status; `security-posture.md`, `security-model.md`, `contracts-security-audit.md` and the user incident FAQ are updated and cross-linked; no anonymity/mixer/untraceable wording remains anywhere. - [ ] AC2: A written abuse/compliance policy covers allowlist, caps, edge screening, sanctions/legal position, record-keeping, prohibited use, relayer rules and the "not a mixer" statement, with a recorded legal/compliance review before mainnet. - [ ] AC3: The relayer reference service is deployable, stateless, rate-limited, fee/min-output/deadline-validating, uses a rotated low-balance fee key, logs no note data/IP-intent tuples, and has a documented permissionless fallback; a red-team of altered destination/fee/route and duplicate submit passes. - [ ] AC4: Monitoring includes per-token solvency vs liability + pending, nullifier/anomaly, cap, code-id drift, pause/config/admin and relayer alerts; each alert has a documented threshold and a staging test that fires it; metrics/logs contain no note/key/wallet data. - [ ] AC5: `shielded-pool-operations.md` and `shielded-pool-incident.md` cover solvency mismatch, tree/commitment bug, key theft, relayer compromise/censorship, code-id drift, pause interactions, chain/reorg, governance compromise, disclosure and user communication; a tabletop/dry-run receipt exists. - [ ] AC6: The audit/supply-chain gate is recorded: internal review, external audit (if available) with scope/findings/remediation, decompile/checksum for the pool and new dependencies, build provenance and a bug-bounty/disclosure channel. - [ ] AC7: A staged rollout plan with explicit per-stage caps, exit criteria, observation windows and recorded decisions exists; the mainnet deploy trace records pool/router code ids, checksums, cap values and the governance signer set; cap increases require the documented evidence. - [ ] AC8: Governance docs state the admin surface and the no-fund-moving/no-withdrawal-block rule; admin transactions are monitored; no new EOA residual is introduced; #526/#697 coordination is recorded. - [ ] AC9: `make verify-issue-<N>` checks the docs cross-links, cap/config values, alert rules, runbook links and deploy-trace fields, and `docs/qa/issue-<N>/README.md` records the evidence and explicit skips. - [ ] AC10: No user conversation, personal data, reporter attribution, wallet-owner identity, note key or mnemonic appears in docs, monitoring, issues, receipts or logs. ## Test plan: functional paths | Path | Required checks | | --- | --- | | Solvency | Deposit/withdraw/change/swap/failed tx/tax-affected deposit; liability vs CW20 balance; pending settlement; forced mismatch via a test mutant; alert fires; deposits pause; withdrawals remain live. | | Alerts | Each rule (solvency, nullifier anomaly, cap hit, code-id drift, pause/config/admin, relayer, API budget) fires in staging and resolves; no note/key/address in labels or annotations. | | Relayer | Success, refusal, timeout, duplicate submit, altered destination/fee/route/owner, fee cap, gas cap, rate limit, key rotation, drained fee key, health/readiness, permissionless alternate. | | Docs/claims | Claim matrix vs contract/API/UI behaviour; no forbidden wording; dApp notice and incident FAQ agree; links from footer and runbooks work. | | Caps/rollout | Initial caps at/below the policy; cap audit script; increase/deploy trace; stage exit criteria; rollback; pause/unpause; migration with pending settlements. | | Incident | Tabletop for each scenario; evidence preservation; user notice; disclosure; support script rejects note-key/seed requests; no admin fund movement is proposed. | | Governance | 2-of-3 signer roster/rotation; admin tx monitoring; router rotation; config update; pause; all logged with a deploy trace. | | Supply chain | Optimizer build, checksum pin, decompile report, dependency pin/licence/provenance, bug-bounty/security.txt reachability. | ## Test plan: attacks, hacks and abuse - **Money laundering/structuring/sanctions:** many small deposits across addresses, deposit/withdraw amount matching, rapid in/out, P2P attempts, cross-pool asks, sanctioned/blacklisted visible senders/destinations, and requests to raise caps. Verify edge screening, caps, refusal/records, and that the docs do not market the pool as a mixer; legal review covers the residual. - **Blacklist/tax/fee evasion:** try to add the pool to `PROTOCOL_EXEMPT`/`MANAGER_EXEMPT`/the fee-discount registry, register a tier with the pool, route through the pool to avoid launch guards, or use a user-supplied `trader`; verify token/contract tests reject it and the policy/ops checks detect an attempted change. - **Wash trading/incentive gaming:** self-shield/self-swap cycles to inflate pair volume or listings, and cap/leaderboard gaming across note keys. Volume is economic and no shielded trader rank exists; document and monitor for anomalous self-flow; ensure no reward path keys on it. - **Relayer collusion/censorship/DoS:** relayer alters the signed fields (must revert), withholds, front-runs, leaks the request, refuses a user, or is drained/blocked. Verify binding, logs, permissionless alternates, rate limits and incident playbook. - **Key/backup theft:** stolen device/backup/passphrase, phishing for note keys, support impersonation, malicious backup import, shared-device residue. Confirm no recovery promise, guidance, and incident handling that does not request secrets. - **Contract/upgrade:** a buggy or malicious migration, code-id drift, a rogue router, a governance-key compromise, a dependency backdoor, or a wasm-admin mistake. Verify pins/checks, monitoring, review gates, state-preserving migration tests and disclosure. - **Monitoring/privacy leakage:** note keys/addresses in metrics, logs, alerts, dashboards, traces, error messages, or third-party monitoring. Run a static scan and a live staging capture; restrict access. - **Economic/oracle interaction:** shielded swaps moving thin pools, manipulating candles/TVL/price or washing DeFiLlama/GT volume; verify the existing price/oracle/TVL guards still apply and cap the product's size. - **Chain-level:** halt/reorg/upgrade while notes are pending, a pool pause/unpause race, a token migration during settlement. Playbooks and state checks must fail closed and preserve notes. ## Verification criteria - [ ] `make verify-issue-<N>` runs the docs/claim cross-link checks, cap/config audit, alert-rule presence test, deploy-trace field check and the relayer unit/red-team tests; it must not mutate production. - [ ] Staging receipts show each alert firing and resolving; the solvency mismatch test pauses deposits and leaves withdrawals live; logs/metrics contain no note/key/wallet data (capture evidence). - [ ] The staged rollout record includes the mainnet cap values, pool/router code ids/checksums, governance roster, audit/review outcomes and the decision log; a cap increase without the evidence is FAIL. - [ ] The incident tabletop/dry-run receipt and the relayer red-team receipt are stored in `docs/qa/issue-<N>/README.md`, with explicit skips for unavailable external audits or production checks. Executed failures remain FAIL. - [ ] No conversation, personal data, reporter attribution, wallet-owner identity, note key or mnemonic appears in docs, monitoring, issue text, receipts or logs. ## Out of scope / follow-ups - Contract/cryptography (#1583), private swap execution (#1584), indexer/API (#1585), dApp (#1586). - ZK/encrypted notes, P2P transfers, cross-pool swaps, third-party token admission, and any expansion of the claim surface: not in phase 1 and requires a new threat-model/audit cycle if proposed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code/cl8y-dex-terraclassic#1587
No description provided.