diff --git a/.github/scripts/origin-tls-client.cjs b/.github/scripts/origin-tls-client.cjs index 893bc6c43..4c812cf6f 100644 --- a/.github/scripts/origin-tls-client.cjs +++ b/.github/scripts/origin-tls-client.cjs @@ -118,16 +118,19 @@ function peerRefusal(stdout, stderr, cipher) { } function classify(result, version, cipher, negative = false) { - if (result.error || result.signal) return "inconclusive"; const output = result.stdout + result.stderr; const negotiated = /New, (TLSv1\.[23]), Cipher is ([^\s]+)/.exec(output); if (negative) { if (/certificate verify failed|Verification error|verify error|no cipher match|unexpected eof|reset by peer|connect:errno/i.test(output)) return "inconclusive"; - if (negotiated && negotiated[2] !== "(NONE)" && negotiated[2] !== "0000") return "accepted"; + const deadline = result.error === "ETIMEDOUT" && result.status === null && (!result.signal || result.signal === "SIGKILL"); + if (negotiated && negotiated[2] !== "(NONE)" && negotiated[2] !== "0000" && + ((!result.error && !result.signal) || deadline)) return "accepted"; + if (result.error || result.signal) return "inconclusive"; return result.status === 1 && peerRefusal(result.stdout || "", result.stderr || "", cipher) && !/-----BEGIN CERTIFICATE-----/.test(output) && /no peer certificate available/.test(output) && /New, \(NONE\), Cipher is \(NONE\)/.test(output) ? "refused" : "inconclusive"; } + if (result.error || result.signal) return "inconclusive"; return result.status === 0 && negotiated?.[1] === version && negotiated[2] === cipher && /Verify return code: 0 \(ok\)/.test(output) && /-----BEGIN CERTIFICATE-----/.test(output) ? "trusted" : "inconclusive"; } diff --git a/.github/scripts/origin-tls-client.test.cjs b/.github/scripts/origin-tls-client.test.cjs index af1816667..95b514d9c 100644 --- a/.github/scripts/origin-tls-client.test.cjs +++ b/.github/scripts/origin-tls-client.test.cjs @@ -48,6 +48,27 @@ function fixture(change = () => {}) { return { rows, run }; } +test("completed negative negotiations retain their outcome at the process deadline", () => { + for (const cipher of CBC) { + const negotiated = { ...trusted(cipher), status: null, error: "ETIMEDOUT", signal: "SIGKILL" }; + assert.equal(classify(negotiated, "TLSv1.2", cipher, true), "accepted"); + assert.equal(classify({ ...negotiated, signal: null }, "TLSv1.2", cipher, true), "accepted"); + for (const altered of [ + { ...negotiated, error: "ENOBUFS" }, { ...negotiated, error: "EIO" }, + { ...negotiated, error: null }, { ...negotiated, signal: "SIGTERM" }, { ...negotiated, status: 0 }, + { ...negotiated, stderr: "certificate verify failed" }, + { ...negotiated, stdout: refused(cipher).stdout }, + ]) assert.equal(classify(altered, "TLSv1.2", cipher, true), "inconclusive"); + assert.equal(classify(negotiated, "TLSv1.2", cipher), "inconclusive"); + } + const f = fixture((row, index) => { + if (index === 4) Object.assign(row, trusted(CBC[0]), { status: null, error: "ETIMEDOUT", signal: "SIGKILL" }); + }); + assert.equal(probe(["10.42.0.85", "10.42.1.12"], f.run, (row) => f.rows.push(row)), false); + assert.equal(f.rows.find((row) => row.kind === "handshake" && row.negative).outcome, "accepted"); + assert.equal(f.rows.at(-1).success, false); +}); + test("every private target has fresh trusted positives around both explicit CBC offers", () => { const f = fixture(); assert.equal(probe(["10.42.0.85", "10.42.1.12"], f.run, (row) => f.rows.push(row)), true); @@ -206,14 +227,17 @@ test("loopback TLS and alert peers preserve strict refusal and trusted positive assert.equal(generated.status, 0, generated.stderr); const f = fixture(); probe(["10.42.0.85", "10.42.1.12"], f.run, (row) => f.rows.push(row)); - for (const mode of ["tls", "fatal", "close_notify", "eof", "reset", "silent"]) { + for (const mode of ["tls", "tls_held", "fatal", "close_notify", "eof", "reset", "silent"]) { await t.test(mode, async () => { const worker = new Worker(` const { parentPort, workerData: d } = require("node:worker_threads"); const net = require("node:net"); const tls = require("node:tls"); - const server = d.mode === "tls" ? tls.createServer({ key: d.key, cert: d.cert, - minVersion: "TLSv1.2", maxVersion: "TLSv1.2", ciphers: d.cipher }, (s) => s.end()) : net.createServer((s) => { + const server = d.mode.startsWith("tls") ? tls.createServer({ key: d.key, cert: d.cert, + minVersion: "TLSv1.2", maxVersion: "TLSv1.2", ciphers: d.cipher }, (s) => { + s.on("error", () => {}); + if (d.mode === "tls") s.end(); + }) : net.createServer((s) => { let input = Buffer.alloc(0); s.on("error", () => {}); s.on("data", (b) => { @@ -227,7 +251,7 @@ test("loopback TLS and alert peers preserve strict refusal and trusted positive }); server.on("tlsClientError", () => {}); server.listen(0, "127.0.0.1", () => parentPort.postMessage(server.address().port)); - `, { eval: true, workerData: { mode, key: readFileSync(key), cert: readFileSync(cert), cipher: GCM[0] } }); + `, { eval: true, workerData: { mode, key: readFileSync(key), cert: readFileSync(cert), cipher: mode === "tls_held" ? CBC.join(":") : GCM[0] } }); try { const port = await new Promise((resolve, reject) => { worker.once("message", resolve); worker.once("error", reject); }); const localArgs = (cipher) => { @@ -238,9 +262,15 @@ test("loopback TLS and alert peers preserve strict refusal and trusted positive }; for (const cipher of CBC) { const result = invoke(localArgs(cipher), (command, args, options) => spawnSync(command, args, - { ...options, timeout: mode === "silent" ? 300 : options.timeout })); - assert.equal(classify(result, "TLSv1.2", cipher, true), ["tls", "fatal"].includes(mode) ? "refused" : "inconclusive", + { ...options, timeout: mode === "tls_held" ? 500 : mode === "silent" ? 300 : options.timeout })); + assert.equal(classify(result, "TLSv1.2", cipher, true), mode === "tls_held" ? "accepted" : ["tls", "fatal"].includes(mode) ? "refused" : "inconclusive", JSON.stringify(result)); + if (mode === "tls_held") { + assert.equal(result.error, "ETIMEDOUT"); + assert.equal(result.signal, "SIGKILL"); + assert.ok(result.stdout.includes(`New, TLSv1.2, Cipher is ${cipher}`)); + assert.match(result.stdout, /Verify return code: 0 \(ok\)/); + } if (mode === "close_notify") { assert.match(result.stdout, /<<< TLS 1.2, Alert \[length 0002\], warning close_notify\n\s+01 00/); const summaryOnly = invoke(localArgs(cipher).filter((arg) => !["-ign_eof", "-state", "-msg"].includes(arg))); diff --git a/deploy/terraform/aws/runtime/README.md b/deploy/terraform/aws/runtime/README.md index de7b09dbb..31021c37e 100644 --- a/deploy/terraform/aws/runtime/README.md +++ b/deploy/terraform/aws/runtime/README.md @@ -290,7 +290,9 @@ ALB, never the public API DNS address. The SNI and verified hostname stay both TLS 1.2 RSA AES-GCM positives and a TLS 1.3 AES-GCM positive, then separate CBC-only TLS 1.2 offers, then fresh TLS 1.2 and TLS 1.3 positives. Only explicit peer handshake-failure alerts without a negotiated cipher, bracketed by those -trusted positives, establish refusal. Timeout, reset alone, unavailable local +trusted positives, establish refusal. A negative connection that negotiates a +cipher remains accepted if its peer keeps it open until the process deadline; +that outcome fails the diagnostic. Timeout without negotiation, reset alone, unavailable local ciphers, missing CA, certificate errors or incomplete evidence are inconclusive. Negative offers ignore stdin EOF and retain bounded OpenSSL state and message traces. Refusal requires the transmitted TLS 1.2 ClientHello to contain only the