@7h3/protocol 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1317
- package/agentAdapter.d.ts +26 -0
- package/auditLog.d.ts +54 -0
- package/capability.d.ts +67 -0
- package/cborCodec.d.ts +34 -0
- package/conformanceVectors.d.ts +20 -0
- package/encryption.d.ts +85 -0
- package/envelopeCbor.d.ts +33 -0
- package/frameworkAdapters.d.ts +72 -0
- package/gateway.d.ts +53 -0
- package/grpcBinding.d.ts +29 -0
- package/httpBinding.d.ts +50 -0
- package/index.d.ts +39 -0
- package/index.js +3662 -0
- package/keyInfra.d.ts +64 -0
- package/keyRegistry.d.ts +9 -0
- package/keyRotation.d.ts +20 -0
- package/mcpGateway.d.ts +37 -0
- package/mcpTransports.d.ts +62 -0
- package/mcpWrapper.d.ts +83 -0
- package/otel.d.ts +65 -0
- package/package.json +13 -121
- package/policyEnforcer.d.ts +50 -0
- package/policyTelemetryFeedback.d.ts +11 -0
- package/{src/protocol.d.ts → protocol.d.ts} +1 -2
- package/protocolAgent.d.ts +58 -0
- package/protocolBinary.d.ts +8 -0
- package/protocolCapabilities.d.ts +24 -0
- package/protocolReplay.d.ts +35 -0
- package/protocolTransport.d.ts +73 -0
- package/queueBinding.d.ts +43 -0
- package/rateLimiter.d.ts +18 -0
- package/{src/redisClient.ts → redisClient.d.ts} +25 -75
- package/replayStores.d.ts +98 -0
- package/revocation.d.ts +71 -0
- package/routePolicy.d.ts +30 -0
- package/runtimePolicy.d.ts +24 -0
- package/runtimePolicyManager.d.ts +15 -0
- package/runtimePolicyPresets.d.ts +11 -0
- package/signedResponse.d.ts +21 -0
- package/stream.d.ts +59 -0
- package/telemetry.d.ts +79 -0
- package/webhookBinding.d.ts +30 -0
- package/wsBinding.d.ts +52 -0
- package/.dockerignore +0 -19
- package/.github/dependabot.yml +0 -32
- package/.github/workflows/ci.yml +0 -31
- package/.github/workflows/publish.yml +0 -59
- package/.github/workflows/scorecard.yml +0 -37
- package/7h3.example.yaml +0 -125
- package/CHANGELOG.md +0 -152
- package/CONTRIBUTING.md +0 -82
- package/Dockerfile +0 -73
- package/GOVERNANCE.md +0 -62
- package/SECURITY.md +0 -70
- package/bench-results/replay-cache-full-1777891033256.json +0 -10
- package/bench-results/replay-cache-full-1777896317488.json +0 -10
- package/bench-results/replay-cache-full-1777900993184.json +0 -10
- package/bench-results/replay-cache-full-1777901019285.json +0 -10
- package/bench-results/replay-cache-quick-1777870170126.json +0 -10
- package/bench-results/signature-profiles-quick-1775875160079.json +0 -85
- package/bench-results/signature-profiles-quick-1775983539716.json +0 -85
- package/bench-results/signature-profiles-quick-1776237913190.json +0 -85
- package/bench-results/wire-codecs-full-1777891019803.json +0 -93
- package/bench-results/wire-codecs-full-1777896260964.json +0 -93
- package/bench-results/wire-codecs-full-1777901004247.json +0 -93
- package/bench-results/wire-codecs-quick-1775972879056.json +0 -93
- package/bench-results/wire-codecs-quick-1775983541111.json +0 -93
- package/bench-results/wire-codecs-quick-1776237914299.json +0 -93
- package/bench-results/wire-codecs-quick-1777841285236.json +0 -93
- package/bench-results/wire-codecs-quick-1777841321772.json +0 -93
- package/bench-results/wire-codecs-quick-1777841330408.json +0 -93
- package/bench-results/wire-codecs-quick-1777852886082.json +0 -93
- package/bench-results/wire-codecs-quick-1777852988773.json +0 -93
- package/bench-results/wire-codecs-quick-1777870188095.json +0 -93
- package/bench-results/wire-codecs-quick-1777870263918.json +0 -93
- package/bench-results/wire-codecs-quick-1777870455034.json +0 -93
- package/bench-results/wire-codecs-quick-1778816163081.json +0 -93
- package/bench-results/wire-codecs-quick-1778843936130.json +0 -93
- package/bin/7h3.ts +0 -406
- package/conformance/7h3_v0_1.json +0 -77
- package/conformance/7h3_v0_1_binary.json +0 -20
- package/conformance/aip_v0_1_binary.json +0 -20
- package/docker-compose.yaml +0 -77
- package/docs/ADOPTION_PLAN.md +0 -120
- package/docs/AGENTS.md +0 -77
- package/docs/AIP_RFC_v0.1.md +0 -97
- package/docs/AI_DECISION_CARD.md +0 -122
- package/docs/AI_RUNTIME_POLICY.json +0 -126
- package/docs/AI_RUNTIME_POLICY.yaml +0 -110
- package/docs/BACKPRESSURE_TUNING.md +0 -65
- package/docs/BENCHMARK_CLAIM_MATRIX.md +0 -42
- package/docs/BENCHMARK_REPORT_TEMPLATE.md +0 -169
- package/docs/BINARY_CODEC_BENCH.md +0 -23
- package/docs/CLEAN_CLONE_RUNBOOK.md +0 -36
- package/docs/CLOCK_SKEW_POLICY.md +0 -30
- package/docs/DISTRIBUTED_REPLAY.md +0 -142
- package/docs/FUZZ_CAMPAIGN.md +0 -121
- package/docs/GATEWAY.md +0 -195
- package/docs/KEY_MANAGEMENT_POLICY.md +0 -53
- package/docs/KEY_REVOCATION.md +0 -69
- package/docs/MCP_WRAPPER.md +0 -159
- package/docs/MIGRATION_GUIDE.md +0 -40
- package/docs/OPERATORS.md +0 -184
- package/docs/PERF_REGRESSION_POLICY.md +0 -34
- package/docs/PROJECT_EXAMINATION_2026-05-31.md +0 -219
- package/docs/RELEASE_BENCHMARK_REPORT_2026-05-15.md +0 -135
- package/docs/RELEASE_GATE.md +0 -25
- package/docs/RELEASE_NOTES_v0.1.0.md +0 -54
- package/docs/SECURITY_REVIEW_2026-06-05.md +0 -165
- package/docs/TELEMETRY.md +0 -41
- package/docs/THREAT_MODEL.md +0 -89
- package/docs/VERSIONING_POLICY.md +0 -30
- package/docs/assets/banner-github.png +0 -0
- package/docs/assets/banner.png +0 -0
- package/docs/assets/banner.svg +0 -123
- package/eslint.config.js +0 -15
- package/fuzz/ts/harness-decode.ts +0 -136
- package/fuzz/ts/harness-verify.ts +0 -121
- package/fuzz/ts/run.ts +0 -35
- package/mcp-server/README.md +0 -38
- package/mcp-server/package-lock.json +0 -1187
- package/mcp-server/package.json +0 -35
- package/mcp-server/src/index.ts +0 -236
- package/mcp-server/tsconfig.json +0 -14
- package/scripts/aip-framework-quickstart.ts +0 -110
- package/scripts/aip-mcp-gateway.ts +0 -38
- package/scripts/aip-mcp-wrap-demo.ts +0 -72
- package/scripts/aip-quickstart.ts +0 -60
- package/scripts/bench-diff.ts +0 -118
- package/scripts/bench-protocol-e2e.ts +0 -937
- package/scripts/bench-protocol-openloop.ts +0 -1397
- package/scripts/bench-replay-cache.ts +0 -76
- package/scripts/bench-signature-profiles.ts +0 -180
- package/scripts/bench-wire-codecs.ts +0 -161
- package/scripts/build-binary-conformance.ts +0 -36
- package/scripts/build-release-dashboard.ts +0 -175
- package/scripts/canary-rollout.ts +0 -38
- package/scripts/mcpGatewayCli.test.ts +0 -116
- package/scripts/prepare-aip-package.ts +0 -88
- package/scripts/regen-conformance-sigs.ts +0 -18
- package/scripts/release-gate.ts +0 -19
- package/scripts/validate-runtime-policy.ts +0 -18
- package/sdk/browser/index.test.ts +0 -162
- package/sdk/browser/index.ts +0 -257
- package/sdk/browser/package.json +0 -13
- package/sdk/go/cbor.go +0 -551
- package/sdk/go/cbor_test.go +0 -232
- package/sdk/go/encryption.go +0 -280
- package/sdk/go/encryption_test.go +0 -318
- package/sdk/go/go.mod +0 -7
- package/sdk/go/go.sum +0 -4
- package/sdk/go/http.go +0 -135
- package/sdk/go/protocol.go +0 -324
- package/sdk/go/protocol_test.go +0 -334
- package/sdk/go/replay.go +0 -121
- package/sdk/go/replay_test.go +0 -149
- package/sdk/go/webhook.go +0 -136
- package/sdk/pq/package-lock.json +0 -1358
- package/sdk/pq/package.json +0 -42
- package/sdk/pq/src/index.test.ts +0 -143
- package/sdk/pq/src/index.ts +0 -166
- package/sdk/pq/tsconfig.json +0 -14
- package/sdk/pq/vitest.config.ts +0 -7
- package/sdk/python/README.md +0 -18
- package/sdk/python/protocol_7h3/__init__.py +0 -46
- package/sdk/python/protocol_7h3/encryption.py +0 -252
- package/sdk/python/protocol_7h3/http.py +0 -212
- package/sdk/python/protocol_7h3/keys.py +0 -149
- package/sdk/python/protocol_7h3/pq.py +0 -244
- package/sdk/python/protocol_7h3/protocol.py +0 -525
- package/sdk/python/protocol_7h3/queue.py +0 -118
- package/sdk/python/protocol_7h3/replay.py +0 -98
- package/sdk/python/protocol_7h3/webhook.py +0 -116
- package/sdk/python/pyproject.toml +0 -40
- package/sdk/python/tests/test_conformance.py +0 -110
- package/sdk/python/tests/test_encryption.py +0 -206
- package/sdk/python/tests/test_http.py +0 -305
- package/sdk/python/tests/test_keys.py +0 -417
- package/sdk/python/tests/test_queue.py +0 -120
- package/sdk/python/tests/test_webhook.py +0 -345
- package/sdk/rust/Cargo.lock +0 -371
- package/sdk/rust/Cargo.toml +0 -25
- package/sdk/rust/README.md +0 -31
- package/sdk/rust/fuzz/Cargo.toml +0 -29
- package/sdk/rust/fuzz/fuzz_targets/fuzz_canonicalize.rs +0 -46
- package/sdk/rust/fuzz/fuzz_targets/fuzz_decode.rs +0 -11
- package/sdk/rust/src/bin/aip_mcp_gateway.rs +0 -59
- package/sdk/rust/src/http.rs +0 -145
- package/sdk/rust/src/keys.rs +0 -161
- package/sdk/rust/src/lib.rs +0 -688
- package/sdk/rust/src/queue.rs +0 -79
- package/sdk/rust/src/webhook.rs +0 -86
- package/sdk/rust/tests/conformance.rs +0 -148
- package/sdk/rust/tests/gateway.rs +0 -130
- package/sdk/rust/tests/http_webhook_queue.rs +0 -201
- package/sdk/rust/tests/keys.rs +0 -189
- package/sdk/threshold/index.d.ts +0 -68
- package/sdk/threshold/index.d.ts.map +0 -1
- package/sdk/threshold/index.js +0 -254
- package/sdk/threshold/package-lock.json +0 -1361
- package/sdk/threshold/package.json +0 -39
- package/sdk/threshold/src/index.d.ts +0 -68
- package/sdk/threshold/src/index.d.ts.map +0 -1
- package/sdk/threshold/src/index.js +0 -254
- package/sdk/threshold/src/index.test.ts +0 -238
- package/sdk/threshold/src/index.ts +0 -355
- package/sdk/threshold/tsconfig.json +0 -19
- package/sdk/threshold/vitest.config.ts +0 -12
- package/src/agentAdapter.test.ts +0 -48
- package/src/agentAdapter.ts +0 -56
- package/src/auditLog.test.ts +0 -145
- package/src/auditLog.ts +0 -147
- package/src/capability.test.ts +0 -504
- package/src/capability.ts +0 -380
- package/src/cborCodec.test.ts +0 -263
- package/src/cborCodec.ts +0 -339
- package/src/conformance.test.ts +0 -136
- package/src/conformanceVectors.ts +0 -99
- package/src/encryption.test.ts +0 -206
- package/src/encryption.ts +0 -245
- package/src/envelopeCbor.ts +0 -140
- package/src/frameworkAdapters.test.ts +0 -290
- package/src/frameworkAdapters.ts +0 -261
- package/src/gateway.test.ts +0 -343
- package/src/gateway.ts +0 -246
- package/src/grpcBinding.test.ts +0 -211
- package/src/grpcBinding.ts +0 -103
- package/src/httpBinding.test.ts +0 -376
- package/src/httpBinding.ts +0 -189
- package/src/index.ts +0 -39
- package/src/keyInfra.test.ts +0 -278
- package/src/keyInfra.ts +0 -228
- package/src/keyRegistry.ts +0 -59
- package/src/keyRotation.test.ts +0 -78
- package/src/keyRotation.ts +0 -72
- package/src/mcpGateway.test.ts +0 -129
- package/src/mcpGateway.ts +0 -250
- package/src/mcpTransports.test.ts +0 -92
- package/src/mcpTransports.ts +0 -169
- package/src/mcpWrapper.test.ts +0 -179
- package/src/mcpWrapper.ts +0 -206
- package/src/otel.ts +0 -136
- package/src/policyEnforcer.test.ts +0 -99
- package/src/policyEnforcer.ts +0 -169
- package/src/policyTelemetryFeedback.test.ts +0 -25
- package/src/policyTelemetryFeedback.ts +0 -38
- package/src/protocol.bench.ts +0 -37
- package/src/protocol.d.ts.map +0 -1
- package/src/protocol.js +0 -294
- package/src/protocol.test.ts +0 -155
- package/src/protocol.ts +0 -414
- package/src/protocolAgent.test.ts +0 -105
- package/src/protocolAgent.ts +0 -169
- package/src/protocolBinary.test.ts +0 -165
- package/src/protocolBinary.ts +0 -312
- package/src/protocolCapabilities.ts +0 -70
- package/src/protocolFuzz.advanced.test.ts +0 -235
- package/src/protocolFuzz.test.ts +0 -111
- package/src/protocolNegative.test.ts +0 -97
- package/src/protocolReplay.test.ts +0 -71
- package/src/protocolReplay.ts +0 -194
- package/src/protocolTransport.test.ts +0 -556
- package/src/protocolTransport.ts +0 -483
- package/src/queueBinding.test.ts +0 -130
- package/src/queueBinding.ts +0 -102
- package/src/rateLimiter.test.ts +0 -96
- package/src/rateLimiter.ts +0 -46
- package/src/redisIntegration.test.ts +0 -134
- package/src/replayStores.test.ts +0 -273
- package/src/replayStores.ts +0 -215
- package/src/revocation.test.ts +0 -98
- package/src/revocation.ts +0 -0
- package/src/routePolicy.test.ts +0 -87
- package/src/routePolicy.ts +0 -72
- package/src/runtimePolicy.test.ts +0 -49
- package/src/runtimePolicy.ts +0 -81
- package/src/runtimePolicyManager.test.ts +0 -29
- package/src/runtimePolicyManager.ts +0 -50
- package/src/runtimePolicyPresets.ts +0 -43
- package/src/signedResponse.test.ts +0 -111
- package/src/signedResponse.ts +0 -83
- package/src/stream.test.ts +0 -254
- package/src/stream.ts +0 -417
- package/src/telemetry.test.ts +0 -251
- package/src/telemetry.ts +0 -299
- package/src/webhookBinding.test.ts +0 -144
- package/src/webhookBinding.ts +0 -115
- package/src/wsBinding.test.ts +0 -221
- package/src/wsBinding.ts +0 -200
- package/tsconfig.json +0 -15
- package/tsconfig.lib.json +0 -23
- package/vite.lib.config.ts +0 -16
- package/vitest.config.ts +0 -11
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# Internal Security Review — AIP v0.1.2
|
|
2
|
-
|
|
3
|
-
**Date:** 2026-06-05
|
|
4
|
-
**Reviewer:** Claude Code (AI-assisted internal review)
|
|
5
|
-
**Scope:** `@7h3/protocol` v0.1.2 — TypeScript sources, Python SDK, Rust SDK
|
|
6
|
-
**Status:** ⚠️ NOT an independent third-party audit. This review was performed by the same AI assistant that co-developed parts of the codebase. It is published for transparency; it does not substitute for an independent cryptographic audit.
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Summary
|
|
11
|
-
|
|
12
|
-
The core cryptographic choices are sound: WebCrypto primitives for both HMAC-SHA256 and Ed25519, constant-time verification, algorithm-confusion guards, and fail-closed revocation. Two real bugs were found and fixed in this review pass. No signature-forgery or authentication-bypass paths were identified.
|
|
13
|
-
|
|
14
|
-
| Finding | Severity | Status |
|
|
15
|
-
|---|---|---|
|
|
16
|
-
| Replay key collision via unescaped `\|` separator | Medium | **Fixed** — `encodeURIComponent` applied |
|
|
17
|
-
| Empty nonce not rejected by `validateEnvelope` | Low | **Fixed** — error diagnostic added |
|
|
18
|
-
| Rust cargo-fuzz targets uncompiled (README overclaim) | Low | **Corrected in README** |
|
|
19
|
-
| `recipient: null` vs `undefined` — cross-language parity gap | Low | Documented accepted risk |
|
|
20
|
-
| Revocation key space-separator (minor variant of #1) | Low | Documented accepted risk |
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Finding 1 — Replay Key Collision (Medium, Fixed)
|
|
25
|
-
|
|
26
|
-
**File:** `src/protocolReplay.ts` — `InMemoryReplayCache.makeKey` and `DistributedReplayCache.makeKey`
|
|
27
|
-
|
|
28
|
-
**Before:**
|
|
29
|
-
```ts
|
|
30
|
-
return `${envelope.header.sender}|${envelope.header.messageId}|${envelope.header.nonce}`
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Problem:** The `|` separator is unescaped. A sender named `"a|b"` with messageId `"c"` produces the same composite key as sender `"a"` with messageId `"b|c"`. If an attacker controls their own agent ID and can observe or predict a target agent's messageId, they can send a message first that "claims" the target's replay key, causing the legitimate message to be rejected as a replay.
|
|
34
|
-
|
|
35
|
-
**Security impact:** This is a **false-rejection DoS**, not a forgery or auth bypass. Signatures still cover the full, unencoded field values — an attacker cannot craft a message that validates under a victim's key. The worst they can achieve is having a legitimate message silently dropped.
|
|
36
|
-
|
|
37
|
-
**Fix applied:**
|
|
38
|
-
```ts
|
|
39
|
-
return `${encodeURIComponent(envelope.header.sender)}|${encodeURIComponent(envelope.header.messageId)}|${encodeURIComponent(envelope.header.nonce)}`
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
`encodeURIComponent` maps `|` → `%7C`, making cross-boundary collisions impossible. For typical agent IDs containing only word characters and hyphens, the output is byte-identical to the old format — no Redis key migration required for standard deployments.
|
|
43
|
-
|
|
44
|
-
**Note on deployed keys:** If your Redis instance already contains replay keys with agent IDs containing `|`, `%`, or other URI-reserved characters, those keys will have a different format after this fix. Existing entries will expire naturally via their TTL; no manual migration is needed.
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## Finding 2 — Empty Nonce Not Validated (Low, Fixed)
|
|
49
|
-
|
|
50
|
-
**File:** `src/protocol.ts` — `validateEnvelope`
|
|
51
|
-
|
|
52
|
-
**Problem:** `validateEnvelope` checked `messageId`, `sender`, `ttlMs`, `timestampMs`, and `content` but did not validate `nonce`. A missing or empty nonce produces a replay key of the form `sender||messageId`. While this doesn't defeat replay protection outright (the composite key still covers sender + messageId), it eliminates the entropy contribution of the nonce and allows any two messages with identical sender + messageId to collide in the replay cache, regardless of time.
|
|
53
|
-
|
|
54
|
-
**Fix applied:** Added `if (!nonce.trim()) diagnostics.push({ level: 'error', message: 'Missing nonce — replay protection requires a unique nonce per message' })`.
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Finding 3 — Rust cargo-fuzz Targets Uncompiled (Low, Corrected)
|
|
59
|
-
|
|
60
|
-
**File:** `sdk/rust/fuzz/`, `README.md` status table
|
|
61
|
-
|
|
62
|
-
**Problem:** `cargo-fuzz` is not installed in the development environment. The Rust fuzz targets (`fuzz_decode.rs`, `fuzz_canonicalize.rs`) were authored and reviewed but have never been compiled or run. The prior README entry claimed "✅ cargo-fuzz targets" without this qualification.
|
|
63
|
-
|
|
64
|
-
**Correction:** The README status now reads: "TypeScript harnesses run clean (50k/20k rounds); Rust targets authored, not yet executed (`cargo-fuzz` not installed)."
|
|
65
|
-
|
|
66
|
-
The targets themselves look structurally correct:
|
|
67
|
-
- `fuzz_decode`: feeds arbitrary bytes through `decode_envelope` under a no-panic invariant — correct
|
|
68
|
-
- `fuzz_canonicalize`: constructs `ProtocolEnvelope` from fuzz bytes, asserts `canonicalize_envelope` is idempotent — correct
|
|
69
|
-
|
|
70
|
-
To run:
|
|
71
|
-
```bash
|
|
72
|
-
rustup toolchain install nightly
|
|
73
|
-
cargo install cargo-fuzz
|
|
74
|
-
cargo +nightly fuzz run fuzz_decode --manifest-path sdk/rust/fuzz/Cargo.toml
|
|
75
|
-
cargo +nightly fuzz run fuzz_canonicalize --manifest-path sdk/rust/fuzz/Cargo.toml
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Finding 4 — `recipient: null` vs Absent (Low, Accepted Risk)
|
|
81
|
-
|
|
82
|
-
**File:** `src/protocol.ts` — `serializeHeaderCanonical`
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
if (header.recipient !== undefined) {
|
|
86
|
-
parts.push(`"recipient":${JSON.stringify(header.recipient)}`)
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
If a JSON message arrives with `"recipient": null`, JavaScript parses this as `null`, which passes the `!== undefined` check. `JSON.stringify(null)` produces `"null"`, so the canonical form includes `"recipient":null` — different from a message where `recipient` is absent entirely.
|
|
91
|
-
|
|
92
|
-
In the TypeScript type system, `ProtocolHeader.recipient` is typed as `string | undefined`. A `null` value is a type violation but not rejected at runtime.
|
|
93
|
-
|
|
94
|
-
**Cross-language risk:** The Rust SDK uses `Option<String>` for `recipient`, which serializes `None` as absent (the field is skipped). If a TS caller writes `recipient: null` and the Rust verifier receives it, the canonical forms diverge → signature mismatch.
|
|
95
|
-
|
|
96
|
-
**Status:** Accepted risk. The correct mitigation is to normalise `null` → `undefined` in the wire decoder. This is tracked as a future improvement. In practice, `null` recipients do not appear in protocol-generated envelopes (`createEnvelope` leaves `recipient` undefined when not supplied).
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## Finding 5 — Revocation Key Space Separator (Low, Accepted Risk)
|
|
101
|
-
|
|
102
|
-
**File:** `src/revocation.ts` — `InMemoryRevocationStore.makeKey` and `createRedisRevocationStore`
|
|
103
|
-
|
|
104
|
-
The revocation key format `"${sender} ${keyId}"` uses a space as separator. If a sender ID contains a space (e.g., `"agent one"`) and a keyId starts with something that continues the pattern, a collision is theoretically possible. However:
|
|
105
|
-
|
|
106
|
-
1. Key IDs in practice are short tokens like `"k1"`, `"prod-key-2026"` — not containing spaces
|
|
107
|
-
2. Agent IDs with spaces are unusual enough to warrant operator documentation
|
|
108
|
-
3. The collision would cause a revocation miss (treating a non-revoked key as revoked, or vice versa) — not an auth bypass
|
|
109
|
-
|
|
110
|
-
**Status:** Accepted risk. Documented in this review. Consider changing to `${encodeURIComponent(sender)}:${encodeURIComponent(keyId)}` in a future patch.
|
|
111
|
-
|
|
112
|
-
---
|
|
113
|
-
|
|
114
|
-
## Positive Findings
|
|
115
|
-
|
|
116
|
-
### Constant-time HMAC verification
|
|
117
|
-
|
|
118
|
-
`hmacVerify` delegates to `crypto.subtle.verify` (WebCrypto), which is specified to run in constant time. There is no string `===` comparison of signature bytes anywhere on the verify hot path.
|
|
119
|
-
|
|
120
|
-
### Algorithm confusion rejected
|
|
121
|
-
|
|
122
|
-
`verifyEnvelopeSignature` checks `signature.alg !== material.alg` before dispatching. An envelope signed with Ed25519 cannot be verified with HMAC material and vice versa — the check is at the dispatch level, before any cryptographic operation.
|
|
123
|
-
|
|
124
|
-
`verifyEnvelopeHmac` checks `envelope.signature.alg !== 'HS256'` explicitly before calling `hmacVerify`. Same for `verifyEnvelopeEd25519` / `'ED25519'`. Downgrade attacks via algorithm confusion are blocked at two independent points.
|
|
125
|
-
|
|
126
|
-
### Revocation fail-closed
|
|
127
|
-
|
|
128
|
-
`createRedisRevocationStore` defaults to `errorBehavior: 'reject'`. A Redis outage causes the store to treat the key as revoked. Cached stale-revoked entries serve during brief outages without allowing a previously-revoked key through.
|
|
129
|
-
|
|
130
|
-
### MCP wrapper — all four bindings present
|
|
131
|
-
|
|
132
|
-
Code review confirms all four claimed bindings in `src/mcpWrapper.ts`:
|
|
133
|
-
|
|
134
|
-
| Binding | Code location | Enforcement |
|
|
135
|
-
|---|---|---|
|
|
136
|
-
| Recipient | line 120: `envelope.header.recipient !== options.selfAgentId` | Returns 32600 error; handler does not run |
|
|
137
|
-
| Sender | line 176: `received.envelope.header.sender !== options.peerAgentId` | Throws; response discarded |
|
|
138
|
-
| Correlation | line 181: `body.correlationId !== decodeOptions.expectCorrelationId` | Throws; response discarded |
|
|
139
|
-
| Replay | `InMemoryReplayCache` injected by default in `wrapMcpServer` | Replay → `consume()` returns `{ok: false}` |
|
|
140
|
-
|
|
141
|
-
### Cross-language parity (within tested scope)
|
|
142
|
-
|
|
143
|
-
The three conformance vectors in `conformance/aip_v0_1.json` produce byte-identical signatures in TypeScript, Python, and Rust. The canonicalization format is simple string concatenation with fixed key order; there is no runtime type ambiguity within the tested input set.
|
|
144
|
-
|
|
145
|
-
**Caveat:** Three vectors are a narrow coverage set. Cross-language divergence on edge cases (very large integers, Unicode normalization, `NaN`/`Infinity` in numeric fields) is not covered by the current conformance suite.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## Scope Not Covered
|
|
150
|
-
|
|
151
|
-
| Area | Reason not covered |
|
|
152
|
-
|---|---|
|
|
153
|
-
| WebCrypto Ed25519 implementation | Browser/Node built-in; outside reviewable scope |
|
|
154
|
-
| Binary wire format (protocolBinary.ts) | Not reviewed in this pass — fuzz coverage via `protocolFuzz.advanced.test.ts` exists |
|
|
155
|
-
| Framework adapters (LangChain, LlamaIndex) | Translation adapters; lower security surface |
|
|
156
|
-
| Policy enforcer | Logic review only; not cryptographic |
|
|
157
|
-
| Python pure-Ed25519 implementation | Correctness verified against conformance vector; not audited for side channels |
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## Conclusion
|
|
162
|
-
|
|
163
|
-
The cryptographic architecture is well-chosen: standard primitives, no custom crypto, constant-time comparison, fail-closed defaults. The two bugs fixed in this review (replay key collision, empty nonce) were low-to-medium severity and have been patched. No authentication bypass, signature forgery, or replay-protection bypass paths were found.
|
|
164
|
-
|
|
165
|
-
**This review does not substitute for an independent third-party audit by a qualified cryptographer.** The parsing, canonicalization, and replay-cache logic remain unaudited by an external reviewer. Treat accordingly for high-stakes deployments.
|
package/docs/TELEMETRY.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Telemetry Events
|
|
2
|
-
|
|
3
|
-
Transport-level telemetry can be attached to `receiveEnvelope` via `telemetry` callback.
|
|
4
|
-
|
|
5
|
-
## Event phases
|
|
6
|
-
|
|
7
|
-
- `decoded`
|
|
8
|
-
- `rejected_clock_skew`
|
|
9
|
-
- `rejected_validation`
|
|
10
|
-
- `rejected_replay`
|
|
11
|
-
- `rejected_missing_signature`
|
|
12
|
-
- `rejected_missing_material`
|
|
13
|
-
- `rejected_bad_signature`
|
|
14
|
-
- `accepted`
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import { receiveEnvelope } from './src/protocolTransport'
|
|
20
|
-
|
|
21
|
-
await receiveEnvelope(rawEnvelope, {
|
|
22
|
-
nowMs: Date.now(),
|
|
23
|
-
replayCache,
|
|
24
|
-
secretResolver: async () => sharedSecret,
|
|
25
|
-
telemetry: async (event) => {
|
|
26
|
-
console.log(event.phase, event.sender, event.messageId, event.reason)
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Gateway audit events
|
|
32
|
-
|
|
33
|
-
`createAipMcpGatewayRuntime` supports `onAuditEvent` for request/policy traces.
|
|
34
|
-
|
|
35
|
-
Phases:
|
|
36
|
-
|
|
37
|
-
- `request_received`
|
|
38
|
-
- `policy`
|
|
39
|
-
- `verification_failed`
|
|
40
|
-
- `request_success`
|
|
41
|
-
- `request_error`
|
package/docs/THREAT_MODEL.md
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# 7h3 Protocol AIP Threat Model (v1.0 draft)
|
|
2
|
-
|
|
3
|
-
## Scope
|
|
4
|
-
|
|
5
|
-
This model covers `aip/0.1` envelope transport and verification paths in:
|
|
6
|
-
|
|
7
|
-
- `src/protocol.ts`
|
|
8
|
-
- `src/protocolTransport.ts`
|
|
9
|
-
- `src/mcpGateway.ts`
|
|
10
|
-
- `sdk/rust/src/lib.rs`
|
|
11
|
-
|
|
12
|
-
## Assets
|
|
13
|
-
|
|
14
|
-
- Message integrity and authenticity
|
|
15
|
-
- Agent identity binding (`sender`, `keyId`, signature material)
|
|
16
|
-
- Freshness (TTL + replay resistance)
|
|
17
|
-
- Gateway policy decisions (allowlist/auth/rate-limit)
|
|
18
|
-
|
|
19
|
-
## Assumptions
|
|
20
|
-
|
|
21
|
-
- Clocks are roughly synchronized within deployment skew limits.
|
|
22
|
-
- Secret/private-key material is provisioned securely outside protocol logic.
|
|
23
|
-
- Transport channel can be observed/modified by adversaries; protocol must detect tamper.
|
|
24
|
-
|
|
25
|
-
## Threats and controls
|
|
26
|
-
|
|
27
|
-
## Tampering
|
|
28
|
-
|
|
29
|
-
- Threat: attacker modifies envelope body/header in transit.
|
|
30
|
-
- Controls:
|
|
31
|
-
- canonical payload signing (`HS256` / `ED25519`)
|
|
32
|
-
- signature verification before acceptance
|
|
33
|
-
- canonical key order fixed to prevent ambiguous signing forms
|
|
34
|
-
|
|
35
|
-
## Replay
|
|
36
|
-
|
|
37
|
-
- Threat: attacker replays previously valid signed envelopes.
|
|
38
|
-
- Controls:
|
|
39
|
-
- TTL checks (`timestampMs + ttlMs`)
|
|
40
|
-
- replay cache consumption (`messageId` + `sender` + `nonce` semantics)
|
|
41
|
-
|
|
42
|
-
## Sender impersonation
|
|
43
|
-
|
|
44
|
-
- Threat: attacker signs as trusted sender with incorrect key material.
|
|
45
|
-
- Controls:
|
|
46
|
-
- verifier resolves material by `(keyId, sender)` context
|
|
47
|
-
- `signatureResolver`/`secretResolver` mapping policy in transport layer
|
|
48
|
-
|
|
49
|
-
## Algorithm confusion / downgrade
|
|
50
|
-
|
|
51
|
-
- Threat: attacker swaps `alg` or relies on omitted compact alg fields.
|
|
52
|
-
- Controls:
|
|
53
|
-
- explicit algorithm field in canonical signature object
|
|
54
|
-
- compact wire supports `sig.a`; default compatibility path only for legacy HS256
|
|
55
|
-
- verifier rejects material when resolved algorithm does not match envelope signature
|
|
56
|
-
|
|
57
|
-
## Gateway abuse
|
|
58
|
-
|
|
59
|
-
- Threat: unauthorized or abusive JSON-RPC method calls.
|
|
60
|
-
- Controls:
|
|
61
|
-
- method allowlist
|
|
62
|
-
- authorization policy hook
|
|
63
|
-
- rate-limit policy hook with context-aware keys
|
|
64
|
-
|
|
65
|
-
## Mitigated risks
|
|
66
|
-
|
|
67
|
-
- **Distributed replay** — a Redis-backed `DistributedReplayStore` is shipped
|
|
68
|
-
(`createRedisReplayStore`, `src/replayStores.ts`). It uses atomic `SET NX PX`,
|
|
69
|
-
batches via pipeline (`reserveMany`), and degrades to a local store on a Redis
|
|
70
|
-
outage so a node never blindly accepts replays and never hard-stops. See
|
|
71
|
-
`DISTRIBUTED_REPLAY.md`.
|
|
72
|
-
- **Fleet-wide key revocation** — a shared `RevocationStore`
|
|
73
|
-
(`createRedisRevocationStore`, `src/revocation.ts`) is consulted on the verify
|
|
74
|
-
path via `withRevocationCheck`. A key revoked on one node is rejected on all
|
|
75
|
-
nodes; reads are cached and fail **closed** by default. See `KEY_REVOCATION.md`.
|
|
76
|
-
|
|
77
|
-
## Remaining risks (open)
|
|
78
|
-
|
|
79
|
-
- No formal fuzz campaign yet for parser/canonicalization boundaries.
|
|
80
|
-
- Revocation/replay stores rely on a correctly provisioned, available Redis (or
|
|
81
|
-
equivalent) control plane; operators own its HA and clock synchronization.
|
|
82
|
-
- No third-party cryptographic audit yet.
|
|
83
|
-
|
|
84
|
-
## Required production mitigations
|
|
85
|
-
|
|
86
|
-
- Keep signature verification enabled by default in production paths.
|
|
87
|
-
- Deploy a shared replay store (`createRedisReplayStore`) for horizontally scaled gateways.
|
|
88
|
-
- Wire a shared revocation store (`createRedisRevocationStore` + `withRevocationCheck`)
|
|
89
|
-
and enforce key lifecycle policy (rotation, expiry, revocation) in the control plane.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# AIP Versioning Policy
|
|
2
|
-
|
|
3
|
-
## Protocol versions
|
|
4
|
-
|
|
5
|
-
- Protocol version is declared in `header.version` (for example `aip/0.1`).
|
|
6
|
-
- New major protocol versions must not silently alter canonicalization or signature semantics.
|
|
7
|
-
- Backward-incompatible wire or verification changes require a new minor/major protocol tag.
|
|
8
|
-
|
|
9
|
-
## Compatibility rules
|
|
10
|
-
|
|
11
|
-
- Patch releases: bug fixes only, no wire-format or canonicalization changes.
|
|
12
|
-
- Minor releases: additive changes only (new optional fields/capabilities, no required-field breakage).
|
|
13
|
-
- Major releases: allowed to remove or alter semantics with explicit migration documentation.
|
|
14
|
-
|
|
15
|
-
## Signature profile policy
|
|
16
|
-
|
|
17
|
-
- Supported profiles are explicitly declared by `signature.alg`.
|
|
18
|
-
- Adding a new signature profile is a minor release only if existing profiles continue to verify unchanged.
|
|
19
|
-
- Removing a profile requires a major release.
|
|
20
|
-
|
|
21
|
-
## SDK versioning
|
|
22
|
-
|
|
23
|
-
- TypeScript, Python, and Rust SDKs follow semver independently.
|
|
24
|
-
- Conformance fixture changes require SDK conformance updates in the same release train.
|
|
25
|
-
|
|
26
|
-
## Release evidence requirements
|
|
27
|
-
|
|
28
|
-
- Conformance suites (TS/Python/Rust) pass.
|
|
29
|
-
- Bench regression checks attached for performance-sensitive changes.
|
|
30
|
-
- Migration guide updated for any behavior change that impacts consumers.
|
|
Binary file
|
package/docs/assets/banner.png
DELETED
|
Binary file
|
package/docs/assets/banner.svg
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="640" viewBox="0 0 1280 640">
|
|
2
|
-
<defs>
|
|
3
|
-
<linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
4
|
-
<stop offset="0%" style="stop-color:#06060f"/>
|
|
5
|
-
<stop offset="100%" style="stop-color:#0c0c22"/>
|
|
6
|
-
</linearGradient>
|
|
7
|
-
<linearGradient id="accentGrad" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
8
|
-
<stop offset="0%" style="stop-color:#4f7cff"/>
|
|
9
|
-
<stop offset="100%" style="stop-color:#a855f7"/>
|
|
10
|
-
</linearGradient>
|
|
11
|
-
<pattern id="hex" x="0" y="0" width="70" height="60" patternUnits="userSpaceOnUse">
|
|
12
|
-
<polygon points="35,3 67,21 67,57 35,60 3,57 3,21" fill="none" stroke="#ffffff07" stroke-width="1"/>
|
|
13
|
-
</pattern>
|
|
14
|
-
<filter id="softglow" x="-10%" y="-10%" width="120%" height="120%">
|
|
15
|
-
<feGaussianBlur stdDeviation="2" result="blur"/>
|
|
16
|
-
<feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge>
|
|
17
|
-
</filter>
|
|
18
|
-
</defs>
|
|
19
|
-
|
|
20
|
-
<!-- Background -->
|
|
21
|
-
<rect width="1280" height="640" fill="url(#bg)"/>
|
|
22
|
-
<rect width="1280" height="640" fill="url(#hex)"/>
|
|
23
|
-
|
|
24
|
-
<!-- Ambient glows -->
|
|
25
|
-
<ellipse cx="180" cy="220" rx="300" ry="240" fill="#4f7cff" opacity="0.05"/>
|
|
26
|
-
<ellipse cx="1100" cy="420" rx="260" ry="200" fill="#a855f7" opacity="0.06"/>
|
|
27
|
-
|
|
28
|
-
<!-- Top accent bar -->
|
|
29
|
-
<rect x="0" y="0" width="1280" height="3" fill="url(#accentGrad)"/>
|
|
30
|
-
|
|
31
|
-
<!-- LEFT COLUMN -->
|
|
32
|
-
<text x="64" y="70" font-family="SF Mono,Consolas,monospace" font-size="12" fill="#4f7cff" letter-spacing="5" opacity="0.85">CRYPTOGRAPHIC AGENT PROTOCOL · v0.4.0</text>
|
|
33
|
-
<text x="58" y="162" font-family="Inter,Helvetica Neue,Arial,sans-serif" font-size="96" font-weight="800" fill="#ffffff" letter-spacing="-4">7h3 Protocol</text>
|
|
34
|
-
<text x="62" y="204" font-family="Inter,Helvetica Neue,Arial,sans-serif" font-size="22" font-weight="300" fill="#94a3b8" letter-spacing="0.3">Sign every message. Reject every replay.</text>
|
|
35
|
-
<rect x="62" y="220" width="320" height="2.5" rx="1.5" fill="url(#accentGrad)"/>
|
|
36
|
-
|
|
37
|
-
<!-- Transport pills -->
|
|
38
|
-
<text x="62" y="272" font-family="SF Mono,Consolas,monospace" font-size="10" fill="#475569" letter-spacing="4">SECURED TRANSPORTS</text>
|
|
39
|
-
<rect x="62" y="284" width="128" height="36" rx="7" fill="#0f1f3d" stroke="#4f7cff" stroke-width="1.2"/>
|
|
40
|
-
<text x="126" y="307" font-family="Inter,sans-serif" font-size="13" font-weight="600" fill="#93c5fd" text-anchor="middle">HTTP / REST</text>
|
|
41
|
-
<rect x="200" y="284" width="122" height="36" rx="7" fill="#131040" stroke="#6366f1" stroke-width="1.2"/>
|
|
42
|
-
<text x="261" y="307" font-family="Inter,sans-serif" font-size="13" font-weight="600" fill="#a5b4fc" text-anchor="middle">WebSocket</text>
|
|
43
|
-
<rect x="332" y="284" width="90" height="36" rx="7" fill="#160e3d" stroke="#8b5cf6" stroke-width="1.2"/>
|
|
44
|
-
<text x="377" y="307" font-family="Inter,sans-serif" font-size="13" font-weight="600" fill="#c4b5fd" text-anchor="middle">gRPC</text>
|
|
45
|
-
<rect x="432" y="284" width="120" height="36" rx="7" fill="#1a0f3d" stroke="#a855f7" stroke-width="1.2"/>
|
|
46
|
-
<text x="492" y="307" font-family="Inter,sans-serif" font-size="13" font-weight="600" fill="#d8b4fe" text-anchor="middle">Msg Queues</text>
|
|
47
|
-
<rect x="562" y="284" width="110" height="36" rx="7" fill="#2a0f2a" stroke="#ec4899" stroke-width="1.2"/>
|
|
48
|
-
<text x="617" y="307" font-family="Inter,sans-serif" font-size="13" font-weight="600" fill="#f9a8d4" text-anchor="middle">Webhooks</text>
|
|
49
|
-
|
|
50
|
-
<!-- SDK badges -->
|
|
51
|
-
<text x="62" y="356" font-family="SF Mono,Consolas,monospace" font-size="10" fill="#475569" letter-spacing="4">5 SDKs — ZERO RUNTIME DEPS</text>
|
|
52
|
-
<rect x="62" y="368" width="98" height="32" rx="6" fill="#0f1d30"/>
|
|
53
|
-
<text x="111" y="389" font-family="Inter,sans-serif" font-size="13" font-weight="700" fill="#60a5fa" text-anchor="middle">TypeScript</text>
|
|
54
|
-
<rect x="170" y="368" width="84" height="32" rx="6" fill="#0a1f12"/>
|
|
55
|
-
<text x="212" y="389" font-family="Inter,sans-serif" font-size="13" font-weight="700" fill="#4ade80" text-anchor="middle">Python</text>
|
|
56
|
-
<rect x="264" y="368" width="72" height="32" rx="6" fill="#1f0f05"/>
|
|
57
|
-
<text x="300" y="389" font-family="Inter,sans-serif" font-size="13" font-weight="700" fill="#fb923c" text-anchor="middle">Rust</text>
|
|
58
|
-
<rect x="346" y="368" width="62" height="32" rx="6" fill="#051520"/>
|
|
59
|
-
<text x="377" y="389" font-family="Inter,sans-serif" font-size="13" font-weight="700" fill="#38bdf8" text-anchor="middle">Go</text>
|
|
60
|
-
<rect x="418" y="368" width="98" height="32" rx="6" fill="#180e28"/>
|
|
61
|
-
<text x="467" y="389" font-family="Inter,sans-serif" font-size="13" font-weight="700" fill="#c084fc" text-anchor="middle">Browser</text>
|
|
62
|
-
|
|
63
|
-
<!-- Install commands -->
|
|
64
|
-
<rect x="62" y="420" width="650" height="116" rx="10" fill="#080d18" stroke="#1e293b" stroke-width="1"/>
|
|
65
|
-
<rect x="62" y="420" width="3" height="116" rx="1.5" fill="url(#accentGrad)"/>
|
|
66
|
-
<text x="82" y="450" font-family="SF Mono,Consolas,Courier New,monospace" font-size="12.5" fill="#4b5563">$</text>
|
|
67
|
-
<text x="98" y="450" font-family="SF Mono,Consolas,Courier New,monospace" font-size="12.5" fill="#cbd5e1">npm install <tspan fill="#60a5fa">@7h3/protocol</tspan></text>
|
|
68
|
-
<text x="82" y="476" font-family="SF Mono,Consolas,Courier New,monospace" font-size="12.5" fill="#4b5563">$</text>
|
|
69
|
-
<text x="98" y="476" font-family="SF Mono,Consolas,Courier New,monospace" font-size="12.5" fill="#cbd5e1">pip install <tspan fill="#4ade80">7h3-protocol</tspan></text>
|
|
70
|
-
<text x="82" y="502" font-family="SF Mono,Consolas,Courier New,monospace" font-size="12.5" fill="#4b5563">$</text>
|
|
71
|
-
<text x="98" y="502" font-family="SF Mono,Consolas,Courier New,monospace" font-size="12.5" fill="#cbd5e1">cargo add <tspan fill="#fb923c">protocol-7h3</tspan></text>
|
|
72
|
-
<text x="82" y="528" font-family="SF Mono,Consolas,Courier New,monospace" font-size="12.5" fill="#4b5563">$</text>
|
|
73
|
-
<text x="98" y="528" font-family="SF Mono,Consolas,Courier New,monospace" font-size="12.5" fill="#cbd5e1">go get <tspan fill="#38bdf8">github.com/IceMasterT/7h3-protocol/sdk/go</tspan></text>
|
|
74
|
-
|
|
75
|
-
<!-- RIGHT COLUMN — Stat cards -->
|
|
76
|
-
<rect x="776" y="52" width="210" height="112" rx="12" fill="#0a0f20" stroke="#4f7cff" stroke-width="1.2"/>
|
|
77
|
-
<text x="881" y="94" font-family="Inter,sans-serif" font-size="30" font-weight="800" fill="#4f7cff" text-anchor="middle" filter="url(#softglow)">Ed25519</text>
|
|
78
|
-
<text x="881" y="118" font-family="Inter,sans-serif" font-size="12" fill="#64748b" text-anchor="middle">Asymmetric signing</text>
|
|
79
|
-
<text x="881" y="138" font-family="Inter,sans-serif" font-size="11" fill="#334155" text-anchor="middle">PKCS8 · SPKI · base64url</text>
|
|
80
|
-
|
|
81
|
-
<rect x="1004" y="52" width="210" height="112" rx="12" fill="#0a1a12" stroke="#10b981" stroke-width="1.2"/>
|
|
82
|
-
<text x="1109" y="100" font-family="Inter,sans-serif" font-size="48" font-weight="800" fill="#10b981" text-anchor="middle" filter="url(#softglow)">278</text>
|
|
83
|
-
<text x="1109" y="124" font-family="Inter,sans-serif" font-size="12" fill="#64748b" text-anchor="middle">tests passing</text>
|
|
84
|
-
<text x="1109" y="142" font-family="Inter,sans-serif" font-size="11" fill="#334155" text-anchor="middle">TS · Python · Rust · Go</text>
|
|
85
|
-
|
|
86
|
-
<rect x="776" y="180" width="210" height="112" rx="12" fill="#130a20" stroke="#a855f7" stroke-width="1.2"/>
|
|
87
|
-
<text x="881" y="236" font-family="Inter,sans-serif" font-size="48" font-weight="800" fill="#a855f7" text-anchor="middle" filter="url(#softglow)">0</text>
|
|
88
|
-
<text x="881" y="260" font-family="Inter,sans-serif" font-size="12" fill="#64748b" text-anchor="middle">runtime deps</text>
|
|
89
|
-
<text x="881" y="278" font-family="Inter,sans-serif" font-size="11" fill="#334155" text-anchor="middle">Pure stdlib · all 5 SDKs</text>
|
|
90
|
-
|
|
91
|
-
<rect x="1004" y="180" width="210" height="112" rx="12" fill="#1a1400" stroke="#f59e0b" stroke-width="1.2"/>
|
|
92
|
-
<text x="1109" y="236" font-family="Inter,sans-serif" font-size="48" font-weight="800" fill="#f59e0b" text-anchor="middle" filter="url(#softglow)">5</text>
|
|
93
|
-
<text x="1109" y="260" font-family="Inter,sans-serif" font-size="12" fill="#64748b" text-anchor="middle">transports</text>
|
|
94
|
-
<text x="1109" y="278" font-family="Inter,sans-serif" font-size="11" fill="#334155" text-anchor="middle">One wire format: 7h3/0.1</text>
|
|
95
|
-
|
|
96
|
-
<!-- Security features panel -->
|
|
97
|
-
<rect x="776" y="308" width="438" height="242" rx="12" fill="#0a0d1a" stroke="#1e293b" stroke-width="1"/>
|
|
98
|
-
<rect x="776" y="308" width="438" height="3" rx="1.5" fill="url(#accentGrad)"/>
|
|
99
|
-
<text x="796" y="338" font-family="SF Mono,Consolas,monospace" font-size="10" fill="#475569" letter-spacing="4">SECURITY GUARANTEES</text>
|
|
100
|
-
|
|
101
|
-
<rect x="796" y="350" width="3" height="38" rx="1.5" fill="#4f7cff"/>
|
|
102
|
-
<text x="810" y="368" font-family="Inter,sans-serif" font-size="14" font-weight="600" fill="#e2e8f0">Verified sender identity</text>
|
|
103
|
-
<text x="810" y="384" font-family="Inter,sans-serif" font-size="11.5" fill="#475569">Ed25519 — cryptographically impossible to forge</text>
|
|
104
|
-
|
|
105
|
-
<rect x="796" y="398" width="3" height="38" rx="1.5" fill="#10b981"/>
|
|
106
|
-
<text x="810" y="416" font-family="Inter,sans-serif" font-size="14" font-weight="600" fill="#e2e8f0">Replay attack prevention</text>
|
|
107
|
-
<text x="810" y="432" font-family="Inter,sans-serif" font-size="11.5" fill="#475569">TTL + nonce — captured messages expire, can't be reused</text>
|
|
108
|
-
|
|
109
|
-
<rect x="796" y="446" width="3" height="38" rx="1.5" fill="#a855f7"/>
|
|
110
|
-
<text x="810" y="464" font-family="Inter,sans-serif" font-size="14" font-weight="600" fill="#e2e8f0">Tamper-evident audit log</text>
|
|
111
|
-
<text x="810" y="480" font-family="Inter,sans-serif" font-size="11.5" fill="#475569">Ed25519-signed entries — alter one byte, break the chain</text>
|
|
112
|
-
|
|
113
|
-
<rect x="796" y="494" width="3" height="38" rx="1.5" fill="#f59e0b"/>
|
|
114
|
-
<text x="810" y="512" font-family="Inter,sans-serif" font-size="14" font-weight="600" fill="#e2e8f0">Bidirectional trust</text>
|
|
115
|
-
<text x="810" y="528" font-family="Inter,sans-serif" font-size="11.5" fill="#475569">Servers sign responses — clients verify replies too</text>
|
|
116
|
-
|
|
117
|
-
<!-- Footer -->
|
|
118
|
-
<rect x="0" y="608" width="1280" height="32" fill="#04040c"/>
|
|
119
|
-
<rect x="0" y="608" width="1280" height="1" fill="#1e293b"/>
|
|
120
|
-
<text x="62" y="630" font-family="SF Mono,Consolas,monospace" font-size="12" fill="#334155">github.com/IceMasterT/7h3-protocol</text>
|
|
121
|
-
<text x="640" y="630" font-family="SF Mono,Consolas,monospace" font-size="12" fill="#334155" text-anchor="middle">MIT License · wire: 7h3/0.1 · Zero runtime deps</text>
|
|
122
|
-
<text x="1218" y="630" font-family="SF Mono,Consolas,monospace" font-size="12" fill="#334155" text-anchor="end">v0.4.0</text>
|
|
123
|
-
</svg>
|
package/eslint.config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import js from '@eslint/js'
|
|
2
|
-
import globals from 'globals'
|
|
3
|
-
import tseslint from 'typescript-eslint'
|
|
4
|
-
|
|
5
|
-
export default tseslint.config(
|
|
6
|
-
{ ignores: ['dist', 'node_modules', 'sdk/rust/target'] },
|
|
7
|
-
{
|
|
8
|
-
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
9
|
-
files: ['**/*.ts'],
|
|
10
|
-
languageOptions: {
|
|
11
|
-
ecmaVersion: 2022,
|
|
12
|
-
globals: { ...globals.node, ...globals.browser },
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
)
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fuzz harness: wire decoder resilience.
|
|
3
|
-
*
|
|
4
|
-
* Invariant: decodeEnvelope must NEVER throw on any input — arbitrary strings
|
|
5
|
-
* and arbitrary bytes both. On garbage it must return {ok: false}.
|
|
6
|
-
*
|
|
7
|
-
* Strategy: start from the conformance corpus, apply mutations, run N rounds.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { readFileSync } from 'node:fs'
|
|
11
|
-
import { join, dirname } from 'node:path'
|
|
12
|
-
import { fileURLToPath } from 'node:url'
|
|
13
|
-
import { decodeEnvelope } from '../../src/index.js'
|
|
14
|
-
|
|
15
|
-
const __dir = dirname(fileURLToPath(import.meta.url))
|
|
16
|
-
const VECTORS_PATH = join(__dir, '../../conformance/7h3_v0_1.json')
|
|
17
|
-
const ROUNDS = parseInt(process.env.FUZZ_ROUNDS ?? '50000', 10)
|
|
18
|
-
|
|
19
|
-
const { vectors, ed25519Vectors = [] } = JSON.parse(readFileSync(VECTORS_PATH, 'utf-8'))
|
|
20
|
-
|
|
21
|
-
// --- corpus: valid JSON and compact encodings from conformance vectors ---
|
|
22
|
-
const corpus: (string | Uint8Array)[] = []
|
|
23
|
-
for (const v of [...vectors, ...ed25519Vectors]) {
|
|
24
|
-
const env = v.envelope
|
|
25
|
-
corpus.push(JSON.stringify(env))
|
|
26
|
-
// compact encoding
|
|
27
|
-
corpus.push(
|
|
28
|
-
JSON.stringify({
|
|
29
|
-
v: env.header?.version,
|
|
30
|
-
mid: env.header?.messageId,
|
|
31
|
-
ts: env.header?.timestampMs,
|
|
32
|
-
ttl: env.header?.ttlMs,
|
|
33
|
-
s: env.header?.sender,
|
|
34
|
-
n: env.header?.nonce,
|
|
35
|
-
i: env.body?.intent,
|
|
36
|
-
c: env.body?.content,
|
|
37
|
-
}),
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
// seed with known-bad corpus
|
|
41
|
-
corpus.push('', '{}', '[]', 'null', '"string"', '{', '{"header":{}}', '{"header":{},"body":{}}')
|
|
42
|
-
|
|
43
|
-
// --- mutators ---
|
|
44
|
-
type Mutator = (input: string, rand: () => number) => string
|
|
45
|
-
|
|
46
|
-
const mutators: Mutator[] = [
|
|
47
|
-
// bit flip a byte
|
|
48
|
-
(s, r) => {
|
|
49
|
-
const buf = Buffer.from(s, 'utf-8')
|
|
50
|
-
if (!buf.length) return s
|
|
51
|
-
buf[Math.floor(r() * buf.length)] ^= 1 << Math.floor(r() * 8)
|
|
52
|
-
return buf.toString('utf-8')
|
|
53
|
-
},
|
|
54
|
-
// insert random byte
|
|
55
|
-
(s, r) => {
|
|
56
|
-
const buf = Buffer.from(s, 'utf-8')
|
|
57
|
-
const idx = Math.floor(r() * (buf.length + 1))
|
|
58
|
-
const b = Math.floor(r() * 256)
|
|
59
|
-
return Buffer.concat([buf.subarray(0, idx), Buffer.from([b]), buf.subarray(idx)]).toString('utf-8')
|
|
60
|
-
},
|
|
61
|
-
// delete a byte
|
|
62
|
-
(s, r) => {
|
|
63
|
-
const buf = Buffer.from(s, 'utf-8')
|
|
64
|
-
if (!buf.length) return s
|
|
65
|
-
const idx = Math.floor(r() * buf.length)
|
|
66
|
-
return Buffer.concat([buf.subarray(0, idx), buf.subarray(idx + 1)]).toString('utf-8')
|
|
67
|
-
},
|
|
68
|
-
// truncate
|
|
69
|
-
(s, r) => {
|
|
70
|
-
const buf = Buffer.from(s, 'utf-8')
|
|
71
|
-
return buf.subarray(0, Math.floor(r() * buf.length)).toString('utf-8')
|
|
72
|
-
},
|
|
73
|
-
// mutate a JSON field
|
|
74
|
-
(s, r) => {
|
|
75
|
-
try {
|
|
76
|
-
const obj = JSON.parse(s) as Record<string, unknown>
|
|
77
|
-
const keys = Object.keys(obj)
|
|
78
|
-
if (!keys.length) return s
|
|
79
|
-
const key = keys[Math.floor(r() * keys.length)]
|
|
80
|
-
const replacement = [null, 0, 1, -1, '', [], {}, true, false][Math.floor(r() * 9)]
|
|
81
|
-
obj[key] = replacement
|
|
82
|
-
return JSON.stringify(obj)
|
|
83
|
-
} catch {
|
|
84
|
-
return s
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
// replace a known token with another
|
|
88
|
-
(s, r) => {
|
|
89
|
-
const tokens = ['7h3/0.1', 'TASK', 'PING', 'RESULT', 'HS256', 'ED25519', '"sender"', '"body"']
|
|
90
|
-
const replacements = ['aip/0.2', 'INVALID', '', '0', 'NONE', 'RSA', '"SENDER"', '"Body"']
|
|
91
|
-
const i = Math.floor(r() * tokens.length)
|
|
92
|
-
return s.split(tokens[i]).join(replacements[i])
|
|
93
|
-
},
|
|
94
|
-
]
|
|
95
|
-
|
|
96
|
-
// --- runner ---
|
|
97
|
-
let crashes = 0
|
|
98
|
-
let okFalse = 0
|
|
99
|
-
let okTrue = 0
|
|
100
|
-
|
|
101
|
-
function rand(): number {
|
|
102
|
-
return Math.random()
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
let current = corpus[0] as string
|
|
106
|
-
|
|
107
|
-
for (let i = 0; i < ROUNDS; i++) {
|
|
108
|
-
// pick a mutator and apply it
|
|
109
|
-
const mutator = mutators[Math.floor(rand() * mutators.length)]
|
|
110
|
-
current = mutator(current, rand)
|
|
111
|
-
|
|
112
|
-
// occasionally reset to a fresh corpus item
|
|
113
|
-
if (i % 500 === 0) {
|
|
114
|
-
current = corpus[Math.floor(rand() * corpus.length)] as string
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
const result = decodeEnvelope(current)
|
|
119
|
-
if (result.ok) {
|
|
120
|
-
okTrue++
|
|
121
|
-
} else {
|
|
122
|
-
okFalse++
|
|
123
|
-
}
|
|
124
|
-
} catch (err) {
|
|
125
|
-
crashes++
|
|
126
|
-
console.error(`\nCRASH at round ${i}:`)
|
|
127
|
-
console.error(' Input (first 200 chars):', JSON.stringify(current.slice(0, 200)))
|
|
128
|
-
console.error(' Error:', err)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
console.log(`[harness-decode] rounds=${ROUNDS} ok=${okTrue} ok:false=${okFalse} crashes=${crashes}`)
|
|
133
|
-
if (crashes > 0) {
|
|
134
|
-
console.error(`FAIL: ${crashes} crash(es) detected`)
|
|
135
|
-
process.exit(1)
|
|
136
|
-
}
|