Public: anyone can read this; the crew can change it.
Post-quantum: one test proves every door negotiates a hybrid key exchange #18064
Merged 10h 38m ago, live in production
scout/forge:scout/18031-post-quantum-one-test-proves-every-door → main 0 commits fork 3 threads · 3 unresolved
9 files
changed +389
−0
docs/PQ-DOORS.md added +20
| @@ -0,0 +1,20 @@ | ||
| 1 | # Post-quantum doors | |
| 2 | ||
| 3 | <!-- Generated by `bun scripts/doors.ts --write` from src/security/doors.ts; `test/doors-hybrid.test.ts` fails when a door is missing from it. --> | |
| 4 | ||
| 5 | Every door the forge has, and what its key exchange is (#18031). *hybrid*: a post-quantum group (`X25519MLKEM768` for TLS, `mlkem768x25519-sha256` for SSH) is offered first (the rig reads the offer, never a completed handshake: it does not say what a peer negotiates). *classical*: it is not. *not measured*: the test rig cannot reach the door; that is never a pass. Run `bun scripts/doors.ts` to read them now; `bun test test/doors-hybrid.test.ts` fails on a door that reads classical without a reason on file, or when SSH's hybrid leaves its offer. | |
| 6 | ||
| 7 | | Door | State | What it means | | |
| 8 | | --- | --- | --- | | |
| 9 | | Edge: browser to forge | not measured | The public edge is out of the rig's reach. Measured by hand from outside on 2026-12-04: `openssl s_client -groups X25519MLKEM768` against forge.open-platform.sh negotiated TLS 1.3 with X25519MLKEM768. | | |
| 10 | | Tunnel: edge to forge | not measured | Out of the rig's reach. Reported by the owner as X25519Kyber768 over QUIC, the pre-standard codepoint, not yet X25519MLKEM768. | | |
| 11 | | Outbound HTTPS: the forge's fetch | hybrid | The runtime's ClientHello, read on loopback: hybrid when X25519MLKEM768 is the first group offered. The rig hangs up after the hello, so it reads what the client offers, not what a server negotiates. | | |
| 12 | | Forge to forge: lending and child forges | not measured | Same stack as outbound (`outboundFetch`), not measured on its own: the rig does not drive the real lending or child-forge call path, so this row is never a pass. | | |
| 13 | | SSH: the forge's terminal and git over SSH | hybrid | The server's KEXINIT, read from the transport: hybrid when mlkem768x25519-sha256 is the first key exchange it offers. No exchange is completed, so this is the offer, not the negotiated result. | | |
| 14 | | Game agent's channel | not measured | Needs a real game box; not reachable from the rig. | | |
| 15 | | Git over smart HTTP from clients with their own TLS stack | not measured | libgit2 in the Apple app; whether it offers the hybrid group has not been checked. | | |
| 16 | | The forge's own git client fetching from origins | classical (known gap) | git links the OS TLS library (GnuTLS on Debian), which has no hybrid group yet; fetches from origins stay classical until it does | | |
| 17 | ||
| 18 | The doc is written from a rig where the git binary offers no hybrid group; a machine whose git does reads *hybrid* there, and the test accepts either for that one door. | |
| 19 | ||
| 20 | Not covered yet: the symmetric keys (every HMAC, token and sealing key at least 256 bits), listed as its own follow-up. |
docs/REFERENCE.md +1
| @@ -605,6 +605,7 @@ This page is the front door. Everything else is a file of its own under | ||
| 605 | 605 | - [](SERVICES.md) — design: any container image as a service on a machine, from image to an https address, generalising the game box. |
| 606 | 606 | - [](EXTRACT.md) — the forge on a machine of its own, and the platform it grew up in switched off: what a host owes it, the moves in order, and what is given up. |
| 607 | 607 | - [](PLATFORM.md) — everything the forge still takes from open-platform, what replaces each, what is done, and the issue for the next step; the order and the gate for switching the platform off. |
| 608 | - [](PQ-DOORS.md) — every door the forge has and whether its key exchange is hybrid post-quantum, classical or not measured. | |
| 608 | 609 | - [](ops/ROLL.md) — rolling a release. |
| 609 | 610 | |
| 610 | 611 | **Design and records** |
scripts/doors.ts added +26
| @@ -0,0 +1,26 @@ | ||
| 1 | /** | |
| 2 | * Read every door's key exchange (#18031): `bun scripts/doors.ts` prints hybrid, classical or not | |
| 3 | * measured for each and exits 1 on a classical door with no reason on file; `--write` rewrites | |
| 4 | * `docs/PQ-DOORS.md` from the same list. | |
| 5 | */ | |
| 6 | ||
| 7 | import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; | |
| 8 | import { tmpdir } from "node:os"; | |
| 9 | import { join } from "node:path"; | |
| 10 | import { measureDoors } from "../src/security/door_probe.ts"; | |
| 11 | import { DOORS, doorsDoc, failures, renderRows } from "../src/security/doors.ts"; | |
| 12 | import { loadOrCreateHostKey } from "../src/ssh/keys.ts"; | |
| 13 | ||
| 14 | if (import.meta.main) { | |
| 15 | const dir = mkdtempSync(join(process.env.TMPDIR ?? tmpdir(), "doors-")); | |
| 16 | try { | |
| 17 | const rows = await measureDoors(DOORS, loadOrCreateHostKey(dir)); | |
| 18 | console.log(renderRows(rows)); | |
| 19 | if (process.argv.includes("--write")) writeFileSync(new URL("../docs/PQ-DOORS.md", import.meta.url).pathname, doorsDoc(rows)); | |
| 20 | const bad = failures(rows); | |
| 21 | if (bad.length) console.error(`classical: ${bad.join("; ")}`); | |
| 22 | process.exitCode = bad.length ? 1 : 0; | |
| 23 | } finally { | |
| 24 | rmSync(dir, { recursive: true, force: true }); | |
| 25 | } | |
| 26 | } |
src/security/door_probe.ts added +100
| @@ -0,0 +1,100 @@ | ||
| 1 | /** | |
| 2 | * The probes behind `doors.ts` (#18031): each reads what a door offers and returns plain data. | |
| 3 | * Nothing leaves the machine: TLS clients are pointed at a loopback listener that records their | |
| 4 | * ClientHello and hangs up; the SSH server's KEXINIT is read from its transport directly. | |
| 5 | */ | |
| 6 | ||
| 7 | import { listen } from "bun"; | |
| 8 | import { type Door, hybridFirst, helloGroups, MLKEM_CODEPOINT, rowOf, type Row, SSH_KEX, type State } from "./doors.ts"; | |
| 9 | import { createLog } from "../kernel/log.ts"; | |
| 10 | import type { HostKey } from "../ssh/keys.ts"; | |
| 11 | import { Transport } from "../ssh/transport.ts"; | |
| 12 | import { concat, MSG, Reader } from "../ssh/wire.ts"; | |
| 13 | ||
| 14 | export type Read = { state: State; detail: string }; | |
| 15 | ||
| 16 | const hex = (g: number) => `0x${g.toString(16)}`; | |
| 17 | ||
| 18 | export function readOfGroups(groups: number[]): Read { | |
| 19 | if (groups.length === 0) return { state: "classical", detail: "no ClientHello was read" }; | |
| 20 | const first = `offers ${groups.map(hex).join(", ")}`; | |
| 21 | return hybridFirst(groups) | |
| 22 | ? { state: "hybrid", detail: `${first}; X25519MLKEM768 (${hex(MLKEM_CODEPOINT)}) first` } | |
| 23 | : { state: "classical", detail: `${first}; no hybrid group first` }; | |
| 24 | } | |
| 25 | ||
| 26 | /** Run `client` against a loopback listener and return the first ClientHello it sent. */ | |
| 27 | async function captureHello(client: (url: string) => Promise<unknown>): Promise<Uint8Array> { | |
| 28 | const seen: Uint8Array[] = []; | |
| 29 | const server = listen({ | |
| 30 | hostname: "127.0.0.1", | |
| 31 | port: 0, | |
| 32 | socket: { | |
| 33 | data(socket, data) { | |
| 34 | seen.push(new Uint8Array(data)); | |
| 35 | socket.end(); | |
| 36 | }, | |
| 37 | open() {}, | |
| 38 | close() {}, | |
| 39 | error() {}, | |
| 40 | }, | |
| 41 | }); | |
| 42 | try { | |
| 43 | await client(`${"https"}://${server.hostname}:${server.port}/`).catch(() => {}); | |
| 44 | } finally { | |
| 45 | server.stop(true); | |
| 46 | } | |
| 47 | return seen[0] ?? new Uint8Array(); | |
| 48 | } | |
| 49 | ||
| 50 | /** The runtime's own fetch, the stack outbound calls and forge-to-forge calls use. */ | |
| 51 | export const probeFetch = async (): Promise<Read> => | |
| 52 | readOfGroups(helloGroups(await captureHello((url) => fetch(url, { signal: AbortSignal.timeout(2000) })))); | |
| 53 | ||
| 54 | /** The `git` binary, as the forge runs it against an origin. */ | |
| 55 | export async function probeGit(): Promise<Read> { | |
| 56 | const hello = await captureHello(async (url) => { | |
| 57 | const env = { ...process.env, GIT_TERMINAL_PROMPT: "0", NO_PROXY: "*", no_proxy: "*", HTTPS_PROXY: "", https_proxy: "" }; | |
| 58 | const child = Bun.spawn(["git", "ls-remote", url], { env, stdout: "ignore", stderr: "ignore", timeout: 4000 }); | |
| 59 | await child.exited; | |
| 60 | }); | |
| 61 | return readOfGroups(helloGroups(hello)); | |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * The key exchanges the SSH server offers, in order, read from the KEXINIT its transport writes. | |
| 66 | */ | |
| 67 | export function sshOffer(hostKey: HostKey): string[] { | |
| 68 | const out: Uint8Array[] = []; | |
| 69 | const transport = new Transport( | |
| 70 | { write: (d) => out.push(d.slice()), payload: () => {}, closed: () => {}, log: createLog("doors") }, | |
| 71 | { hostKey, serverVersion: "SSH-2.0-forge-doors" }, | |
| 72 | ); | |
| 73 | transport.start(); | |
| 74 | const bytes = concat(...out); | |
| 75 | const at = bytes.indexOf(0x0a) + 1; | |
| 76 | const len = new DataView(bytes.buffer, bytes.byteOffset + at).getUint32(0); | |
| 77 | const pad = bytes[at + 4]!; | |
| 78 | const reader = new Reader(bytes.subarray(at + 5, at + 4 + len - pad)); | |
| 79 | if (reader.u8() !== MSG.KEXINIT) return []; | |
| 80 | reader.bytes(16); | |
| 81 | return reader.nameList(); | |
| 82 | } | |
| 83 | ||
| 84 | /** The state of an SSH key-exchange offer: hybrid only when the hybrid is first. */ | |
| 85 | export function readOfSsh(kex: readonly string[]): Read { | |
| 86 | return kex[0] === SSH_KEX | |
| 87 | ? { state: "hybrid", detail: `offers ${kex.join(", ")}; ${SSH_KEX} first (an offer, not a negotiated result)` } | |
| 88 | : { state: "classical", detail: `offers ${kex.join(", ") || "nothing"}; ${SSH_KEX} is not first` }; | |
| 89 | } | |
| 90 | ||
| 91 | /** Every door, read: a door with no probe is `not measured`. */ | |
| 92 | export async function measureDoors(doors: readonly Door[], hostKey: HostKey): Promise<Row[]> { | |
| 93 | const once = new Map<string, Promise<Read>>(); | |
| 94 | const run = (probe: Door["probe"]): Promise<Read> | null => { | |
| 95 | if (probe === "none") return null; | |
| 96 | if (!once.has(probe)) once.set(probe, probe === "ssh-offer" ? Promise.resolve(readOfSsh(sshOffer(hostKey))) : probe === "git-hello" ? probeGit() : probeFetch()); | |
| 97 | return once.get(probe)!; | |
| 98 | }; | |
| 99 | return Promise.all(doors.map(async (d) => rowOf(d, (await run(d.probe)) ?? null))); | |
| 100 | } |
src/security/doors.ts added +164
| @@ -0,0 +1,164 @@ | ||
| 1 | /** | |
| 2 | * The forge's doors, one list (#18031): every place a connection reaches the forge or leaves it, | |
| 3 | * and what the test rig can say about its key exchange. The test, the script and | |
| 4 | * `docs/PQ-DOORS.md` all read this list, so a door cannot be in one and missing from another. | |
| 5 | * | |
| 6 | * A door's state is `hybrid` (the rig read the door offering a post-quantum hybrid group first; | |
| 7 | * it never completes a handshake, so what a peer then picks is not read), `classical` (it offers | |
| 8 | * none first), or `not measured` (the rig cannot reach it): never passing. | |
| 9 | */ | |
| 10 | ||
| 11 | export type State = "hybrid" | "classical" | "not measured"; | |
| 12 | ||
| 13 | /** How the rig reads a door: a probe it can run, or nothing it can reach. */ | |
| 14 | export type Probe = "ssh-offer" | "fetch-hello" | "git-hello" | "none"; | |
| 15 | ||
| 16 | export interface Door { | |
| 17 | readonly id: string; | |
| 18 | readonly name: string; | |
| 19 | readonly probe: Probe; | |
| 20 | /** What a hybrid reading means for this door, or why the rig cannot reach it. */ | |
| 21 | readonly note: string; | |
| 22 | } | |
| 23 | ||
| 24 | export const SSH_KEX = "mlkem768x25519-sha256"; | |
| 25 | ||
| 26 | export const DOORS: readonly Door[] = [ | |
| 27 | { | |
| 28 | id: "edge", | |
| 29 | name: "Edge: browser to forge", | |
| 30 | probe: "none", | |
| 31 | note: "The public edge is out of the rig's reach. Measured by hand from outside on 2026-12-04: `openssl s_client -groups X25519MLKEM768` against forge.open-platform.sh negotiated TLS 1.3 with X25519MLKEM768.", | |
| 32 | }, | |
| 33 | { | |
| 34 | id: "tunnel", | |
| 35 | name: "Tunnel: edge to forge", | |
| 36 | probe: "none", | |
| 37 | note: "Out of the rig's reach. Reported by the owner as X25519Kyber768 over QUIC, the pre-standard codepoint, not yet X25519MLKEM768.", | |
| 38 | }, | |
| 39 | { | |
| 40 | id: "outbound", | |
| 41 | name: "Outbound HTTPS: the forge's fetch", | |
| 42 | probe: "fetch-hello", | |
| 43 | note: "The runtime's ClientHello, read on loopback: hybrid when X25519MLKEM768 is the first group offered. The rig hangs up after the hello, so it reads what the client offers, not what a server negotiates.", | |
| 44 | }, | |
| 45 | { | |
| 46 | id: "forge-to-forge", | |
| 47 | name: "Forge to forge: lending and child forges", | |
| 48 | probe: "none", | |
| 49 | note: "Same stack as outbound (`outboundFetch`), not measured on its own: the rig does not drive the real lending or child-forge call path, so this row is never a pass.", | |
| 50 | }, | |
| 51 | { | |
| 52 | id: "ssh", | |
| 53 | name: "SSH: the forge's terminal and git over SSH", | |
| 54 | probe: "ssh-offer", | |
| 55 | note: "The server's KEXINIT, read from the transport: hybrid when mlkem768x25519-sha256 is the first key exchange it offers. No exchange is completed, so this is the offer, not the negotiated result.", | |
| 56 | }, | |
| 57 | { | |
| 58 | id: "game-agent", | |
| 59 | name: "Game agent's channel", | |
| 60 | probe: "none", | |
| 61 | note: "Needs a real game box; not reachable from the rig.", | |
| 62 | }, | |
| 63 | { | |
| 64 | id: "git-clients", | |
| 65 | name: "Git over smart HTTP from clients with their own TLS stack", | |
| 66 | probe: "none", | |
| 67 | note: "libgit2 in the Apple app; whether it offers the hybrid group has not been checked.", | |
| 68 | }, | |
| 69 | { | |
| 70 | id: "git-origins", | |
| 71 | name: "The forge's own git client fetching from origins", | |
| 72 | probe: "git-hello", | |
| 73 | note: "The `git` binary's ClientHello on loopback. It is the machine's TLS library (GnuTLS here offers no hybrid group), so the reading is that of the machine the test runs on.", | |
| 74 | }, | |
| 75 | ]; | |
| 76 | ||
| 77 | /** | |
| 78 | * Doors whose classical reading is a known gap, not a regression: the reason is shown beside it. | |
| 79 | */ | |
| 80 | export const KNOWN_CLASSICAL: Readonly<Record<string, string>> = { | |
| 81 | "git-origins": "git links the OS TLS library (GnuTLS on Debian), which has no hybrid group yet; fetches from origins stay classical until it does", | |
| 82 | }; | |
| 83 | ||
| 84 | export interface Row { | |
| 85 | readonly door: Door; | |
| 86 | readonly state: State; | |
| 87 | readonly detail: string; | |
| 88 | } | |
| 89 | ||
| 90 | /** The groups a ClientHello's supported_groups lists, as hex codepoints, in order; [] when none. */ | |
| 91 | export function helloGroups(hello: Uint8Array): number[] { | |
| 92 | const u16 = (at: number) => (hello[at]! << 8) | hello[at + 1]!; | |
| 93 | try { | |
| 94 | if (hello[0] !== 0x16 || hello[5] !== 0x01) return []; | |
| 95 | let p = 5 + 4 + 2 + 32; | |
| 96 | p += 1 + hello[p]!; | |
| 97 | p += 2 + u16(p); | |
| 98 | p += 1 + hello[p]!; | |
| 99 | const end = p + 2 + u16(p); | |
| 100 | p += 2; | |
| 101 | while (p + 4 <= end) { | |
| 102 | const len = u16(p + 2); | |
| 103 | if (u16(p) === 10) { | |
| 104 | const groups: number[] = []; | |
| 105 | for (let i = 0; i < u16(p + 4); i += 2) groups.push(u16(p + 6 + i)); | |
| 106 | return groups; | |
| 107 | } | |
| 108 | p += 4 + len; | |
| 109 | } | |
| 110 | } catch { | |
| 111 | /* a short or odd hello reads as no groups */ | |
| 112 | } | |
| 113 | return []; | |
| 114 | } | |
| 115 | ||
| 116 | /** X25519MLKEM768's TLS codepoint (draft-ietf-tls-ecdhe-mlkem). */ | |
| 117 | export const MLKEM_CODEPOINT = 0x11ec; | |
| 118 | ||
| 119 | export const hybridFirst = (groups: readonly number[]): boolean => groups[0] === MLKEM_CODEPOINT; | |
| 120 | ||
| 121 | /** | |
| 122 | * The state of a door from what its probe read; a gap named in KNOWN_CLASSICAL stays `classical`. | |
| 123 | */ | |
| 124 | export function rowOf(door: Door, read: { state: State; detail: string } | null): Row { | |
| 125 | return read ? { door, ...read } : { door, state: "not measured", detail: door.note }; | |
| 126 | } | |
| 127 | ||
| 128 | /** Doors that read classical with no reason on file, by name. */ | |
| 129 | export function failures(rows: readonly Row[]): string[] { | |
| 130 | return rows.filter((r) => r.state === "classical" && !KNOWN_CLASSICAL[r.door.id]).map((r) => r.door.name); | |
| 131 | } | |
| 132 | ||
| 133 | const mark = (r: Row) => (r.state === "classical" && KNOWN_CLASSICAL[r.door.id] ? "classical (known)" : r.state); | |
| 134 | ||
| 135 | /** One line a door, for the terminal and the test's message. */ | |
| 136 | export function renderRows(rows: readonly Row[]): string { | |
| 137 | return rows.map((r) => `${mark(r).padEnd(17)} ${r.door.name}: ${r.detail}`).join("\n"); | |
| 138 | } | |
| 139 | ||
| 140 | /** `docs/PQ-DOORS.md`, generated from the list: `bun scripts/doors.ts --write`. */ | |
| 141 | export function doorsDoc(rows: readonly Row[]): string { | |
| 142 | const lines = [ | |
| 143 | "# Post-quantum doors", | |
| 144 | "", | |
| 145 | "<!-- Generated by `bun scripts/doors.ts --write` from src/security/doors.ts; `test/doors-hybrid.test.ts` fails when a door is missing from it. -->", | |
| 146 | "", | |
| 147 | "Every door the forge has, and what its key exchange is (#18031). *hybrid*: a post-quantum group (`X25519MLKEM768` for TLS, `mlkem768x25519-sha256` for SSH) is offered first (the rig reads the offer, never a completed handshake: it does not say what a peer negotiates). *classical*: it is not. *not measured*: the test rig cannot reach the door; that is never a pass. Run `bun scripts/doors.ts` to read them now; `bun test test/doors-hybrid.test.ts` fails on a door that reads classical without a reason on file, or when SSH's hybrid leaves its offer.", | |
| 148 | "", | |
| 149 | "| Door | State | What it means |", | |
| 150 | "| --- | --- | --- |", | |
| 151 | ]; | |
| 152 | for (const r of rows) { | |
| 153 | const note = r.state === "classical" && KNOWN_CLASSICAL[r.door.id] ? KNOWN_CLASSICAL[r.door.id]! : r.door.note; | |
| 154 | lines.push(`| ${r.door.name} | ${r.state === "classical" && KNOWN_CLASSICAL[r.door.id] ? "classical (known gap)" : r.state} | ${note} |`); | |
| 155 | } | |
| 156 | lines.push( | |
| 157 | "", | |
| 158 | "The doc is written from a rig where the git binary offers no hybrid group; a machine whose git does reads *hybrid* there, and the test accepts either for that one door.", | |
| 159 | "", | |
| 160 | "Not covered yet: the symmetric keys (every HMAC, token and sealing key at least 256 bits), listed as its own follow-up.", | |
| 161 | "", | |
| 162 | ); | |
| 163 | return lines.join("\n"); | |
| 164 | } |
src/view/doc_sections.ts +1
| @@ -92,6 +92,7 @@ export const DOC_LINES: Record<string, Line> = { | ||
| 92 | 92 | "CLOUD.md": ["internals", "Clouds add capacity; none is required."], |
| 93 | 93 | "EXTRACT.md": ["internals", "Moving off the platform that first hosted it.", "Running on its own"], |
| 94 | 94 | "PLATFORM.md": ["internals", "What production still uses from Open Platform.", "Platform inventory"], |
| 95 | "PQ-DOORS.md": ["internals", "Every door the forge has and its key exchange.", "Post-quantum doors"], | |
| 95 | 96 | "PROFIT.md": ["internals", "A design: cost against responsiveness.", "Cost and responsiveness"], |
| 96 | 97 | "SPIKE-CLOUDFLARE.md": ["internals", "An unapplied experiment.", "Experiment: a forge on Cloudflare"], |
| 97 | 98 | "SPIKE-SEARCH-READING.md": ["internals", "A measurement that stopped at step 1.", "Experiment: a search-first reading layer"], |
test/doors-hybrid.test.ts added +74
| @@ -0,0 +1,74 @@ | ||
| 1 | /** One test proves every door offers a hybrid key exchange (#18031). */ | |
| 2 | import { expect, test } from "bun:test"; | |
| 3 | import { mkdtempSync, readFileSync } from "node:fs"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { measureDoors, readOfGroups, readOfSsh, sshOffer } from "../src/security/door_probe.ts"; | |
| 7 | import { DOORS, doorsDoc, failures, helloGroups, KNOWN_CLASSICAL, renderRows, rowOf, SSH_KEX } from "../src/security/doors.ts"; | |
| 8 | import { loadOrCreateHostKey } from "../src/ssh/keys.ts"; | |
| 9 | import { quietLogs } from "./helpers/globals.ts"; | |
| 10 | ||
| 11 | quietLogs(); | |
| 12 | const hostKey = loadOrCreateHostKey(mkdtempSync(join(process.env.TMPDIR ?? tmpdir(), "doors-test-"))); | |
| 13 | ||
| 14 | test("every door the rig can reach offers hybrid, and the output names each door's state", async () => { | |
| 15 | const rows = await measureDoors(DOORS, hostKey); | |
| 16 | const out = renderRows(rows); | |
| 17 | expect(rows.map((r) => r.door.id)).toEqual(DOORS.map((d) => d.id)); | |
| 18 | for (const r of rows) expect(out).toContain(r.door.name); | |
| 19 | expect(failures(rows), `classical:\n${out}`).toEqual([]); | |
| 20 | // A door with no probe is never a pass. | |
| 21 | for (const r of rows.filter((r) => r.door.probe === "none")) expect(r.state).toBe("not measured"); | |
| 22 | // The doors the rig reads itself: SSH and the runtime's fetch are hybrid, not merely unmeasured. | |
| 23 | for (const id of ["ssh", "outbound"]) expect(rows.find((r) => r.door.id === id)?.state).toBe("hybrid"); | |
| 24 | // A classical reading is allowed only where a reason is on file. | |
| 25 | for (const r of rows.filter((r) => r.state === "classical")) expect(KNOWN_CLASSICAL[r.door.id]).toBeTruthy(); | |
| 26 | }); | |
| 27 | ||
| 28 | test("SSH offers the hybrid first; without it in the offer the door fails by name", () => { | |
| 29 | const offer = sshOffer(hostKey); | |
| 30 | expect(offer[0]).toBe(SSH_KEX); | |
| 31 | const ssh = DOORS.find((d) => d.id === "ssh")!; | |
| 32 | expect(readOfSsh(offer).state).toBe("hybrid"); | |
| 33 | // The probe's own decision, fed an offer that lacks the hybrid, or lists it after another. | |
| 34 | for (const kex of [offer.filter((k) => k !== SSH_KEX), ["curve25519-sha256", SSH_KEX], []]) { | |
| 35 | expect(readOfSsh(kex).state).toBe("classical"); | |
| 36 | expect(failures([rowOf(ssh, readOfSsh(kex))])).toEqual([ssh.name]); | |
| 37 | } | |
| 38 | }); | |
| 39 | ||
| 40 | test("a classical door with no reason on file fails with its name", () => { | |
| 41 | const edge = DOORS[0]!; | |
| 42 | expect(failures([rowOf(edge, { state: "classical", detail: "" })])).toEqual([edge.name]); | |
| 43 | expect(failures([rowOf(edge, null)])).toEqual([]); | |
| 44 | }); | |
| 45 | ||
| 46 | test("helloGroups reads supported_groups, and nothing from garbage", () => { | |
| 47 | expect(helloGroups(new Uint8Array([1, 2, 3]))).toEqual([]); | |
| 48 | expect(helloGroups(new Uint8Array())).toEqual([]); | |
| 49 | }); | |
| 50 | ||
| 51 | /** A TLS 1.3 ClientHello record with one supported_groups extension, built by hand. */ | |
| 52 | function hello(groups: number[]): Uint8Array { | |
| 53 | const u16 = (n: number) => [n >> 8, n & 255]; | |
| 54 | const list = groups.flatMap(u16); | |
| 55 | const ext = [...u16(10), ...u16(list.length + 2), ...u16(list.length), ...list]; | |
| 56 | const body = [3, 3, ...new Array(32).fill(7), 0, ...u16(2), 0x13, 0x01, 1, 0, ...u16(ext.length), ...ext]; | |
| 57 | const hs = [1, 0, ...u16(body.length), ...body]; | |
| 58 | return new Uint8Array([0x16, 3, 1, ...u16(hs.length), ...hs]); | |
| 59 | } | |
| 60 | ||
| 61 | test("a hand-built ClientHello with 0x11ec first reads hybrid; one without it reads classical", () => { | |
| 62 | expect(helloGroups(hello([0x11ec, 0x1d, 0x17]))).toEqual([0x11ec, 0x1d, 0x17]); | |
| 63 | expect(readOfGroups(helloGroups(hello([0x11ec, 0x1d]))).state).toBe("hybrid"); | |
| 64 | expect(helloGroups(hello([0x1d, 0x17, 0x11ec]))).toEqual([0x1d, 0x17, 0x11ec]); | |
| 65 | expect(readOfGroups(helloGroups(hello([0x1d, 0x17, 0x11ec]))).state).toBe("classical"); | |
| 66 | expect(readOfGroups(helloGroups(hello([0x1d, 0x17]))).state).toBe("classical"); | |
| 67 | }); | |
| 68 | ||
| 69 | test("docs/PQ-DOORS.md is what doorsDoc writes from the list, the git row as the rig's reading aside", async () => { | |
| 70 | const doc = readFileSync(new URL("../docs/PQ-DOORS.md", import.meta.url), "utf8"); | |
| 71 | const rows = (await measureDoors(DOORS, hostKey)).map((r) => (r.door.id === "git-origins" ? { ...r, state: "classical" as const } : r)); | |
| 72 | expect(doc).toBe(doorsDoc(rows)); | |
| 73 | for (const d of DOORS) expect(doc).toContain(d.name); | |
| 74 | }); |
test/outbound-sweep.test.ts +1
| @@ -37,6 +37,7 @@ const ALLOWED: Record<string, { count: number; why: string }> = { | ||
| 37 | 37 | "src/apps/preview_spec.ts": { count: 1, why: "the preview's own loopback address, built by the forge" }, |
| 38 | 38 | "src/apps/toolbar.ts": { count: 1, why: BROWSER }, |
| 39 | 39 | "src/arcade/carts.ts": { count: 1, why: "the app's own loopback page (`http://127.0.0.1:<port>`)" }, |
| 40 | "src/security/door_probe.ts": { count: 1, why: "the runtime's own fetch pointed at a loopback listener this process opened, to read its ClientHello" }, | |
| 40 | 41 | "src/devices/ipp.ts": { count: 1, why: "a printer is on the owner's LAN by design; core/devices.ts holds it to private literals and never link-local" }, |
| 41 | 42 | "src/perf/github_traffic.ts": { count: 1, why: "api.github.com, named in code" }, |
| 42 | 43 | "src/chaos/report.ts": { count: 1, why: "the forge URL the operator runs the chaos drill against" }, |
test/spawn-sites.test.ts +2
| @@ -107,6 +107,8 @@ const SITES: Record<string, string> = { | ||
| 107 | 107 | "bun (process.execPath) on the forge's own hosted_copy.ts with an empty environment; its two arguments are a JSON job of three paths the snapshot built from a validated forge name and its own scratch directory, and the path its answer is written to: nothing from a request", |
| 108 | 108 | "src/system/compact.ts": |
| 109 | 109 | "bun (process.execPath) on the forge's own compact_child.ts with an empty environment, at boot only when an operator's compact-on-boot marker asks; its one argument is a JSON job of two paths under the forge's own data directory: nothing from a request", |
| 110 | "src/security/door_probe.ts": | |
| 111 | "the git binary with a fixed argv, `ls-remote` on a loopback listener this process opened; nothing from a request", | |
| 110 | 112 | "src/spawn/archive.ts": |
| 111 | 113 | "tar with fixed flags on the forge's own data directory and an archive path it derived from a validated name", |
| 112 | 114 | "src/spawn/child_db.ts": |
new above
offline
This note and the committed doc's tunnel row disagree. Keep one wording, and regenerate the page.