Multi-layer defense ensuring every node serves identical, untampered code. SRI enforcement, content probing, manifest consensus, and IP discrimination detection.
The marketplace uses a defense-in-depth strategy to ensure every user loads the exact same code from every node. A compromised node that serves tampered JavaScript could steal wallet keys, redirect payments, or manipulate transaction parameters.
| Attack | Description | Defense Layer |
|---|---|---|
| Direct code injection | Node serves modified JS bundles | SRI enforcement, release manifest |
| Two-directory attack | Node maintains clean code for audits, tampered code for users | Content probing (browser-style requests) |
| IP discrimination | Node detects auditing node IPs and serves clean code to them only | Client bundle attestation + SRI |
| Gateway collusion | Gateway + node collude to serve tampered content | Session attestation, multi-gateway verification |
The gateway sits between the serving node and the browser. When proxying HTML navigation responses, the gateway:
<script src="..."> and <link rel="stylesheet"> tags in the response.integrity="sha256-..." crossorigin="anonymous" attributes.The browser itself enforces SRI before any JavaScript executes. If the serving node tampers with a script after the gateway computed the hash, the browser refuses to execute it. This is a browser-level guarantee that tampered JS cannot bypass.
The gateway also injects a <meta name="x-bundle-fingerprint"> tag containing a composite hash of all asset SRI hashes. This fingerprint is used by the client attestation system.
<!-- Gateway injects integrity attributes and bundle fingerprint -->
<head>
<meta name="x-bundle-fingerprint" content="a1b2c3...64hex">
<script src="/_next/static/chunks/main.js"
integrity="sha256-ABC123..."
crossorigin="anonymous"></script>
</head>A rogue node's only options:
There is no option 3.
Every node computes a deterministic manifest of all served files:
.next/static/, .next/server/, and public/ directories.manifestHash = SHA256(sorted chunk hashes).Nodes broadcast their manifest hash via BUNDLE_INTEGRITY_ATTESTATION protocol events. The explorer tracks which manifest hash each node reports. Divergent nodes are flagged.
Audit frequency: Every 5 minutes, each node queries all peers for their manifest hash.
A rogue node could maintain two build directories — clean code for peer audits, tampered code for users. The manifest audit (Layer 2) wouldn't catch this because it's self-reported.
Content probing solves this by fetching actual served content as a regular user:
/api/release/manifest to get the declared asset list.The rogue node cannot distinguish this request from a real user request, so it cannot serve different content.
Request headers (indistinguishable from a browser):
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
Accept-Encoding: identity
(NO x-node-pubkey, NO x-node-signature, NO x-dm-skip-quorum)Audit frequency: Every 15 minutes (heavier than manifest checks).
Detection probability: With 200 chunks and 1 tampered, probing 5 random chunks:
Even with content probing, a rogue node could whitelist known node IPs and serve clean code to them while serving tampered code to everyone else.
Client bundle attestation closes this gap:
x-bundle-fingerprint meta tag.Because SRI guarantees the client code is honest, the client's report is trustworthy. The rogue node cannot serve tampered JS that lies about its own fingerprint, because the browser would refuse to execute it (SRI check fails).
Client → POST /node/bundle-attestation/verify (directly to peer)
Body: { clientFingerprint: "a1b2c3...", servingNodeId: "suspect-node" }
Peer response: { matches: false, expectedFingerprint: "d4e5f6..." }
→ IP DISCRIMINATION DETECTEDWhen bundle divergence is detected at any layer:
| Severity | Action |
|---|---|
| Manifest mismatch | Node quarantined (5-min TTL), BUNDLE_INTEGRITY_ATTESTATION event gossiped |
| Content probe mismatch | MISBEHAVIOR_PROOF with type BUNDLE_DIVERGENCE, misbehavior strike applied |
| IP discrimination | Governance lock on stake (7 days), misbehavior strike, explorer flag |
The misbehavior strike system escalates:
BUNDLE_INTEGRITY_ATTESTATION
bundleManifestHash: string (64 hex)
chunkCount: number
releaseVersion: string
checkedPeerNodeIds: string[]
agreeingPeerCount: number
divergentPeerNodeIds: string[]
attestedAt: ISO timestamp