security/ops: shielded pool threat model, abuse controls, relayer operations and staged rollout #1587
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/cl8y-dex-terraclassic#1587
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.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.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.terra1zlmv2xydxcusurtr6rl78wsvytdc6mfex6hep7.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/,docs/runbooks/dex-prometheus-monitoring.md,make verify-issue-1544); anomaly thresholds per SEC-G02/#435.docs/qa/issue-1397/README.md(schema 2, no actor identifiers, explicit non-anonymity language), #1206 aggregate digest, #1202 privacy-reviewed product events.docs/security-posture.mddoes 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:
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.mddocs/runbooks/: newshielded-pool-operations.md,shielded-pool-incident.md,shielded-relayer.md,shielded-cap-changes.md; updates tolaunch-checklist.md,anomaly-signals.md,wasm-admin-migration.md,key-custody.md,cw20-whitelist-policy.mdmonitoring/(dashboards, alert rules),docs/runbooks/dex-prometheus-monitoring.mdscripts/(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.mdRecommended direction
Threat model and claim matrix. Extend
docs/shielded-pool.mdwith 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. Updatesecurity-posture.mdand 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.Abuse and compliance policy. Write an explicit policy, wired into config and reviews:
PROTOCOL_EXEMPT/MANAGER_EXEMPT/the discount registry;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.Monitoring and invariants. Add alerts and a dashboard for:
LIABILITY+ pending settlement; any negative delta pages immediately; a persistent mismatch pauses deposits (governance action) and opens an incident;PauseDepositsandUpdateConfigevents, wasm admin/migration events;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.
Incident playbooks. Add
shielded-pool-incident.mdcovering: 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 adocs/qa/issue-<N>/record.Audit, supply chain and staged rollout. Gate the program:
cw20-codeid-audits-style decompile/checksum for the pool and any new dependency (ed25519/hash), build provenance and optimizer checksums;security.txt, with an explicit note that note loss/key theft is not recoverable;PauseDeposits; withdrawals remain live; state-preserving migration is the only upgrade path.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.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.
Public communication. Add a short, accurate shielding section to
security-posture.mdand 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
docs/qa/issue-<N>/README.md; executed failures remain FAIL. No issue closure, cap increase or "deployed" claim without real evidence.Acceptance criteria
docs/shielded-pool.mdcontains 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.mdand the user incident FAQ are updated and cross-linked; no anonymity/mixer/untraceable wording remains anywhere.shielded-pool-operations.mdandshielded-pool-incident.mdcover 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.make verify-issue-<N>checks the docs cross-links, cap/config values, alert rules, runbook links and deploy-trace fields, anddocs/qa/issue-<N>/README.mdrecords the evidence and explicit skips.Test plan: functional paths
Test plan: attacks, hacks and abuse
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-suppliedtrader; verify token/contract tests reject it and the policy/ops checks detect an attempted change.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.docs/qa/issue-<N>/README.md, with explicit skips for unavailable external audits or production checks. Executed failures remain FAIL.Out of scope / follow-ups