Kaspa x402

Security Threat Model

Status: alpha threat model for the Testnet-10 exact and batch-settlement profiles. Alpha.10 replaces the active batch binding with kaspa-escrow-v2 and template kaspa-x402-escrow-v2; older alpha snapshots are historical artifacts, not supported runtime profiles.

Assets

Trust Boundaries

Core Threats

ThreatMitigationResidual risk
Exact transaction replayExact payment identity includes network, transaction id, and output index. State stores reserve the identity before handler execution.Production stores need atomic compare-and-set behavior across workers.
Batch voucher replay or regressionA voucher signs the network, stable KIP-20 covenantId, and lifetime ceiling T. The store rejects T below the previously accepted ceiling and never resets T when the outpoint changes.Compromised client signing keys can authorize future settlement within available escrow value.
Stale or substituted batch headThe server persists the current outpoint, script, value V, and on-chain settled total S. Every accepted transition must consume that exact outpoint and prove the expected same-ID successor or terminal refund.KIP-20 does not provide covenant-id reverse lookup; loss of durable head state requires transaction-lineage recovery.
Ambiguous covenant genesisBefore accepting work, the server verifies the funding transaction has exactly one output: the expected genesis with the advertised script, value, initial state, and derived covenant id.Genesis evidence must be captured before transaction history can become unavailable through pruning or provider retention limits.
Parallel claim, top-up, or refundA shared per-lineage lock and transactional compare-and-set admit only one transition from the expected current outpoint. Broadcast attempts remain durable until reconciled.Network uncertainty can temporarily block the lane while the winning transaction is located and finalized.
Client refund broadcast uncertaintyBefore broadcast, the client durably reserves the exact signed transaction, deterministic transaction id, stable covenant id, and captured channel head. Unknown results are reconciled through trusted chain evidence without rebuilding or rebroadcasting.An unavailable or inconclusive reconciler keeps the channel blocked until accepted-or-confirmed evidence is available.
Duplicate retry double-executes protected workA durable work attempt binds channel, payment identifier, and request fingerprint before handler execution. A staged result is reused if final payment commit fails; conflicts fail.A crash after a non-repeatable side effect but before result staging still requires handler-owned idempotency or an outbox.
Handler failure consumes payment stateA and the request commitment advance only after protected handler success unless the flow has an explicit recoverable on-chain transition.Accepted genesis or top-up state remains live even when later protected work fails.
Stale node or RPC failureVerification fails closed unless required finality and covenant-transition evidence is present.Operators must monitor node health, pruning horizon, and finality lag.
Funding source policy bypassClient code checks required funding source against adapter-reported funding source.Wallet and treasury adapters still require independent audit.
Malicious facilitator widens capabilityFacilitator supported kinds are intersected with direct-mode server capability and explicit action settlers.Hosted facilitators need authentication, rate limits, and tenant isolation.
Covenant template driftEscrow fixture checks and transaction-v1 vectors pin script public key, state, covenant binding, fee, and output behavior.Mainnet requires an independent covenant and transaction-builder audit.

Exact Profiles

The default standard-native profile validates a native Kaspa transaction whose selected output pays the advertised amount exactly to the advertised recipient. The optional additive profile validates a transaction that spends the current advertised KIP-10 head and recreates a same-script successor whose increase is exactly the advertised amount. The successor increase is the sole merchant payment; a separate merchant output is forbidden. Verifiers derive transaction id, inputs, outputs, scripts, amounts, and continuation evidence from the transaction body and trusted UTXO lookups rather than payload hints.

Required checks include:

Batch-Settlement Profile

The Alpha.10 batch profile uses one singleton KIP-20 covenant lineage and lifetime cumulative vouchers. Define:

At voucher acceptance the server must enforce 0 <= S <= A <= T and (T - S) + R <= V. Here A - S is the outstanding actual charge and T - S is authorization headroom. All values are non-negative decimal sompi strings no greater than signed-int64 maximum (9223372036854775807).

Required checks include:

State Store Requirements

Production stores must provide atomic operations for:

In-memory stores are test fixtures only. See server-store-contract.md and server-runtime-lock-contract.md.

For client refunds, ChannelStore.applyRefundAttempt must atomically compare the captured outpoint, script, covenant id, value, channel status, and transaction id before marking the channel refunded and the attempt applied. A send error or unknown reconciliation result must leave the attempt open, block a second refund, and never trigger automatic rebroadcast.

Live Proof Boundary

The live proof runner validates evidence supplied by a live adapter. The committed reference adapter in scripts/live-adapter-reference.mjs is a reviewable Testnet-10 harness, not a production wallet, broadcaster, recovery journal, or settlement service. It receives RPC, funding, and SDK paths from operator environment variables and writes generated signing material under the ignored live data directory.

Live Testnet-10 success demonstrates alpha flow execution only; it is not a mainnet approval or audit substitute.

Source: /docs/security-threat-model.md