Repository navigation
Pin Node to the releases that block the eMudhra intermediates #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7cafb89
build: require Node.js >=22, dropping end-of-life 18 and 20
coder9io a44c7d8
ci: test on Node 22/24/26, release on 24, always latest patch
coder9io f2d864f
Merge remote-tracking branch 'origin/main' into coder9io/issue-8
coder9io b9a70a5
test: require Node releases with the eMudhra blocklist
coder9io 0e9d7f6
build: floor Node at 22.23.4, 24.22.1 and 26.12.1
coder9io e183347
build: add TLS probe for the eMudhra SPKI blocklist
coder9io ea06ecc
ci: pin CI and release to the patched Node releases
coder9io 347e617
test: reproduce TLS probe hanging on a stalled endpoint
coder9io 48078ea
build: bound each TLS probe request with a 15 s deadline
coder9io File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Checks that this Node.js rejects certificate chains through the compromised | ||
| // eMudhra intermediates (nodejs/node#66871) while still trusting a normal host. | ||
| // Uses default TLS verification; exits non-zero if either expectation fails. | ||
| import https from 'node:https'; | ||
|
|
||
| const BLOCKED = 'https://dv-g3b-emudhra.we-have-a-problem.com/'; | ||
| const TRUSTED = 'https://nodejs.org/'; | ||
| // Overall per-request deadline, so a host that accepts the connection and then | ||
| // goes silent fails the probe instead of holding the CI/release job open. | ||
| const DEADLINE_MS = 15_000; | ||
|
|
||
| function get(url) { | ||
| return new Promise((resolve) => { | ||
| const req = https | ||
| .get(url, (res) => { | ||
| clearTimeout(deadline); | ||
| res.resume(); | ||
| resolve({ status: res.statusCode }); | ||
| }) | ||
| .on('error', (err) => { | ||
| clearTimeout(deadline); | ||
| resolve({ code: err.code, message: err.message }); | ||
| }); | ||
| const deadline = setTimeout(() => { | ||
| req.destroy( | ||
| Object.assign(new Error(`no response within ${DEADLINE_MS} ms`), { code: 'ETIMEDOUT' }), | ||
| ); | ||
| }, DEADLINE_MS); | ||
| }); | ||
| } | ||
|
|
||
| console.log(`process.version ${process.version}`); | ||
|
|
||
| const blocked = await get(BLOCKED); | ||
| const trusted = await get(TRUSTED); | ||
| console.log(BLOCKED, JSON.stringify(blocked)); | ||
| console.log(TRUSTED, JSON.stringify(trusted)); | ||
|
|
||
| let failed = false; | ||
| if (blocked.code !== 'CERT_REVOKED') { | ||
| console.error(`expected ${BLOCKED} to fail with CERT_REVOKED`); | ||
| failed = true; | ||
| } | ||
| if (trusted.status === undefined) { | ||
| console.error(`expected ${TRUSTED} to connect`); | ||
| failed = true; | ||
| } | ||
| process.exit(failed ? 1 : 0); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { readFileSync } from 'fs'; | ||
| import { join } from 'path'; | ||
|
|
||
| // First release on each supported line that rejects the compromised eMudhra | ||
| // intermediates (SPKI blocklist, nodejs/node#66871). Odd lines 23/25 are | ||
| // end-of-life and never got the fix, so they stay excluded. | ||
| const PATCHED_NODE = ['22.23.4', '24.22.1', '26.12.1']; | ||
| const ENGINES = '^22.23.4 || ^24.22.1 || >=26.12.1'; | ||
|
|
||
| const root = join(__dirname, '..'); | ||
| const read = (file: string) => readFileSync(join(root, file), 'utf8'); | ||
|
|
||
| describe('supported Node.js versions', () => { | ||
| it('floors engines.node at the patched release of each line', () => { | ||
| expect(JSON.parse(read('package.json')).engines.node).toBe(ENGINES); | ||
| expect(ENGINES.match(/\d+\.\d+\.\d+/g)).toEqual(PATCHED_NODE); | ||
| }); | ||
|
|
||
| it('keeps package-lock.json in step with package.json', () => { | ||
| expect(JSON.parse(read('package-lock.json')).packages[''].engines.node).toBe(ENGINES); | ||
| }); | ||
|
|
||
| it('documents every patched floor in the README', () => { | ||
| const readme = read('README.md'); | ||
| for (const version of PATCHED_NODE) { | ||
| expect(readme).toContain(`v${version}`); | ||
| } | ||
| }); | ||
|
|
||
| it('tests every patched floor in CI', () => { | ||
| const matrix = read('.github/workflows/ci.yml').match(/^\s*node: \[(.*)\]$/m); | ||
| expect(matrix?.[1].split(/,\s*/)).toEqual(PATCHED_NODE.map((v) => `'${v}'`)); | ||
| }); | ||
|
|
||
| it('releases on a Node version CI tests', () => { | ||
| const versions = read('.github/workflows/release.yml').match(/node-version: (.*)$/gm); | ||
| expect(versions).toEqual([`node-version: '${PATCHED_NODE[1]}'`]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { spawnSync } from 'child_process'; | ||
| import { join } from 'path'; | ||
|
|
||
| type Outcome = number | string | 'stall'; | ||
|
|
||
| const PROBE = join(__dirname, '..', 'scripts', 'tls-probe.mjs'); | ||
|
|
||
| // Runs the real probe with https.get replaced: each request in turn answers | ||
| // with a status code, fails with an error code, or ('stall') never settles | ||
| // while holding the event loop open like a live socket. Timers are capped at | ||
| // 20 ms so the probe's own deadline fires well inside the 2 s watchdog. | ||
| function runProbe(blocked: Outcome, trusted: Outcome) { | ||
| const preload = ` | ||
| import https from 'node:https'; | ||
| import { EventEmitter } from 'node:events'; | ||
| const realSetTimeout = globalThis.setTimeout; | ||
| globalThis.setTimeout = (fn, ms, ...args) => realSetTimeout(fn, Math.min(ms, 20), ...args); | ||
| const outcomes = ${JSON.stringify([blocked, trusted])}; | ||
| https.get = (_url, options, callback) => { | ||
| if (typeof options === 'function') callback = options; | ||
| const outcome = outcomes.shift(); | ||
| const req = new EventEmitter(); | ||
| const liveSocket = setInterval(() => {}, 1000); | ||
| req.destroy = (error) => { | ||
| clearInterval(liveSocket); | ||
| queueMicrotask(() => req.emit('error', error ?? new Error('aborted'))); | ||
| return req; | ||
| }; | ||
| queueMicrotask(() => { | ||
| if (outcome === 'stall') return; | ||
| clearInterval(liveSocket); | ||
| if (typeof outcome === 'number') callback({ statusCode: outcome, resume() {} }); | ||
| else req.emit('error', Object.assign(new Error(outcome), { code: outcome })); | ||
| }); | ||
| return req; | ||
| }; | ||
| `; | ||
| return spawnSync( | ||
| process.execPath, | ||
| ['--import', 'data:text/javascript,' + encodeURIComponent(preload), PROBE], | ||
| { encoding: 'utf8', timeout: 2000, killSignal: 'SIGKILL' }, | ||
| ); | ||
| } | ||
|
|
||
| describe('scripts/tls-probe.mjs', () => { | ||
| it.each<[string, Outcome, Outcome, number]>([ | ||
| ['passes when the eMudhra host is revoked and the trusted host answers', 'CERT_REVOKED', 307, 0], | ||
| ['fails on a Node that still trusts the eMudhra chain', 200, 200, 1], | ||
| ['fails when the eMudhra host fails for another reason', 'ENOTFOUND', 200, 1], | ||
| ['fails when the trusted host does not connect', 'CERT_REVOKED', 'CERT_HAS_EXPIRED', 1], | ||
| ])('%s', (_name, blocked, trusted, status) => { | ||
| const result = runProbe(blocked, trusted); | ||
| expect(result.error).toBeUndefined(); | ||
| expect(result.status).toBe(status); | ||
| }); | ||
|
|
||
| it.each<[string, Outcome, Outcome]>([ | ||
| ['eMudhra host', 'stall', 200], | ||
| ['trusted host', 'CERT_REVOKED', 'stall'], | ||
| ])('fails within its deadline when the %s stalls', (_name, blocked, trusted) => { | ||
| const result = runProbe(blocked, trusted); | ||
| expect(result.error).toBeUndefined(); | ||
| expect(result.status).toBe(1); | ||
| expect(result.stdout).toContain('"code":"ETIMEDOUT"'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.