Skip to content

Research & Security ​

This page is for auditors, security researchers, and academics evaluating s402. Everything here is primary-source material — specs, threat models, invariants, and ADRs — not marketing copy.

If you're here to use s402, you probably want the Quick Start instead. If you're here to evaluate s402, read on.

Primary Artifacts ​

ArtifactWhat it coversAudience
WhitepaperProtocol motivation, scheme design, economic model, Sui rationaleAcademics, protocol designers
Wire Format SpecNormative HTTP headers, encoding, payload schemasImplementers, auditors
Threat ModelAdversarial analysis: what attackers can and cannot do, per schemeSecurity reviewers
Security ModelTrust assumptions, invariants, key-rotation and reorg handlingSecurity engineers
ArchitectureFacilitator contract, verify/settle split, receipt formatsSystem architects

Safety Invariants (S1–S13) ​

The protocol is governed by thirteen named invariants. Every implementation, adapter, and scheme must preserve them or be non-conforming. Full formal statements live in AGENTS.md; highlights:

InvariantStatement
S1Requirements never contain client-side secrets
S2Payment payloads are canonical — one byte representation per logical payload
S3Every scheme defines its own settlement atomicity semantics explicitly
S4Error codes are stable across versions — new codes may be added, existing ones never change meaning
S5Base64 encoding uses URL-safe alphabet with no padding
S6Version negotiation is explicit — no silent fallback across major versions
S7Core protocol is chain-agnostic — no chain-specific logic in the s402 package
S8Compat layers are one-way input — they normalize x402/MPP into s402, never reverse
S9Scheme digests are content-addressed — two schemes with the same digest are interchangeable
S10Settlement responses are signed by the facilitator — clients verify before trusting
S11Rate caps and ceilings are on-chain contract state, not server-held policy
S12Key rotation does not invalidate outstanding receipts
S13Reorgs up to chain-documented finality depth preserve receipt validity

See ADR-008 for the derivation of S9–S13.

Architecture Decision Records ​

The protocol's design decisions are tracked as ADRs. Each one states the question, options considered, chosen path, and consequences.

ADRDecision
001Protocol boundaries — what's in s402 vs chain adapters
002s402 is pure protocol — zero runtime chain dependencies
003Upto scheme design — on-chain ceiling, variable amount
004Extensions architecture — how to add non-core features without forking
005Interop when possible, superset when wise — governing strategic principle
006Version negotiation and scheme digests
007Settlement response envelope shape
008Safety invariants S9–S13 — content addressing, rotation, reorg
009Open gaps — known unresolved questions in rotation and reorg

Conformance Suite ​

Every official adapter passes 161 vectors in spec/vectors/. The vectors are language-agnostic JSON — run them against any implementation to verify compliance.

CategoryVector countWhat it tests
Requirements encode/decode24Server → Client challenge round-trips
Payload encode/decode28Client → Server payment round-trips
Roundtrip (full handshake)22End-to-end flow for all six schemes
Settlement encode/decode18Settlement response shape and signature
Settlement verification19Facilitator signature validation
Receipt format / parse16Receipt canonicalization
Compat normalize12x402 V1/V2 → s402 translation
Validation reject14Malformed inputs must reject, not silently accept
Body transport8HTTP body edge cases

Full schema and vector sources: spec/canonicalization.md and spec/vectors/.

Threat Model Summary ​

The full THREAT_MODEL covers seven adversary classes. Quick reference:

AdversaryWhat they trys402 mitigation
Malicious serverOver-charge, refuse delivery, forge receiptsOn-chain ceiling (Upto), atomic PTB settlement (Sui), arbiter (Escrow)
Malicious clientReplay, double-spend, forge payloadsCanonical encoding, nonce-based replay protection, on-chain settlement
Malicious facilitatorCensor, front-run, mis-settleDirect mode (no facilitator), signed settlement receipts, open facilitator market
Network adversaryDrop, delay, reorder HTTPIdempotent settlement by nonce, retry-safe semantics
Chain reorgInvalidate settled paymentsFinality-depth gating per scheme (S13), documented per-chain thresholds
Compromised keySign unauthorized paymentsKey rotation (S12), outstanding receipts survive rotation
Compat layer bugsx402/MPP inputs trigger s402 invariant violationsOne-way input only (S8), conformance vectors for every compat path

Formal Specification Status ​

  • Wire format: frozen for v0.5, additive-only for v0.6
  • Scheme semantics: Exact, Upto, Prepaid, Escrow, Stream frozen; Unlock finalizing for v0.5
  • Canonicalization: frozen — see spec/canonicalization.md
  • IETF Internet-Draft: draft-ahn-httpauth-s402-00 in preparation (DAN-342)

Audit Status ​

ScopeStatusAuditor
TypeScript core (s402)Internal review complete; external audit pending—
Move contracts (Sui, per-scheme)Internal review complete; formal audit required before mainnet3-auditor requirement (Swee policy)
Compat layersUnder active development—
Facilitator hosted serviceOperational; SOC 2 work pending—

No scheme is considered production-safe for non-trivial value until its Move contracts complete formal audit. The Sui testnet deployment is for integration testing only.

Bug Bounty ​

Responsible disclosure: see SECURITY.md. Critical protocol-level findings are bountied; contract-level findings on deployed Move code will be covered once bounties are live (tracked with mainnet launch).

Contributing Research ​

If you're doing academic or security research on s402:

  • x402 (Coinbase, 2025) — github.com/coinbase/x402. The EVM-native prior art; s402's compat layer reads x402 V1 and V2 natively.
  • MPP (Stripe + Tempo, 2026) — machinepayments.org. Multi-rail payment intents for machine commerce; s402 coexists via Accept-Payment.
  • AP2 (Google, 2026) — Agent Payments Protocol; s402 supports AP2 mandate delegation as a client credential.
  • RFC 9110 — HTTP Semantics, including the 402 status code reservation.
  • RFC 7231 — HTTP/1.1 Semantics, basis for Accept-Payment q-value negotiation.

Next Steps ​

Released under the Apache 2.0 License.