Sample audits · Workstation audits, October 2026

Node.js API documentation, part 2 of 2

The second half of the Node.js v24 API reference, modules to zlib.

Summary card for this audit: 34 findings after review, 0 High, 10 Medium, 17 Low, 7 Info

Corrected 16 November 2026: on re-checking, finding 17 was shown wrong and moved to excluded. Before: 0 High, 11 Medium, 17 Low, 7 Info, 0 excluded on review. Now: 0 High, 10 Medium, 17 Low, 7 Info, 1 excluded on review. Only these moves change the figures above; the re-check of the other findings is in the section below.

AuditedNode.js API reference v24.22.1, modules to zlib (36 pages), pages fetched 21 October 2026
Date22 October 2026
How it ranlocal run on our workstation, full audit, Standard review
Verdict after reviewPass with notes (Fail if a High finding remains after review, otherwise Pass with notes)

Related: Node.js API documentation, part 1 of 2 (October 2026) · cloudflare/security-audit-skill (October 2026)

0
High after review
10
Medium after review
17
Low after review
7
Info after review
1
excluded on review

Re-checked 16 November 2026

Every finding of this audit was checked again against today's documentation. Status: Still present = the error is in the current v24 documentation and on main; Fixed on main only = corrected on main, still in the v24 documentation; Already in an open Node.js pull request = still present, and an open pull request makes the fix; Wrong at audit (excluded) = the finding was wrong when we made it and is now listed as excluded; Could not check = the page could not be compared.

Examples were run on Node v24.15.0; documentation compared on v24.22.3 and main.

#FindingStatus todayRating at audit → now
1HTTP server sample echoes a parse error without setting a content typeStill presentLow → Low
2URL-building sample trusts forwarded-host headersStill presentInfo → Info
3Legacy URL escaping example names the wrong encoding for the slashStill presentLow → Low
4Handle-scope loop sample leaves the scope open on its error exitStill presentLow → Low
5HTTP server sample buffers the whole request body with no size limitStill presentInfo → Info
6Streamed decompression sample has no output capStill presentInfo → Info
7Header-parsing sample grows its buffer without a limitStill presentInfo → Info
8Example writes helper files into the script directory without checking for existing filesStill presentInfo → Info
9NAPI_MODULE_INIT example does not compileStill presentMedium → Medium
10napi_define_properties walkthrough does not compileStill presentMedium → Medium
11REPL examples open an unauthenticated code-execution socket on every interfaceStill presentLow → Low
12REPL client example throws on every normal exitStill presentMedium → Medium
13Single-executable tutorial builds one file name and then signs and runs anotherFixed on main onlyMedium → Medium
14Readable.filter, map, forEach and toArray examples destructure an array result as an objectStill presentMedium → Medium
15Whole-file read example joins Buffer chunks as stringsStill presentMedium → Medium
16stream/iter duplex() echo example reads the wrong end of the pairFixed on main onlyMedium → Medium
17Dependency-timing examples print 'undefined' as the module nameWrong at audit (excluded)Medium → excluded
18Microtask-queue fix snippet uses names the example does not defineStill presentLow → Low
19TLS setup commands produce PKCS#12 files that the samples read as PEM, and the two samples overwrite each other's filesStill presentMedium → Medium
20Custom test reporter never completes the transform for event types it does not listStill presentMedium → Medium
21KmacParams documents its algorithm member as 'algorithm' while every sibling class uses 'name'Still presentMedium → Medium
22TLS client example turns hostname verification offStill presentLow → Low
23TLS session-resumption sample stores sessions in an object that is never prunedStill presentLow → Low
24BlockList.PRIVATE_RANGES is described as covering all non-routable rangesStill presentLow → Low
25Native API signature uses a finalizer type that the page never definesStill presentLow → Info
26Windows build step installs a deprecated packageStill presentLow → Low
27Key-derivation sample defaults to 1000 PBKDF2 iterationsStill presentLow → Low
28addAbortSignal examples use names that are never importedStill presentLow → Low
29Mocked-timer interval example asserts values the iterator does not yieldStill presentLow → Medium
30quic.listen() example omits the sni option the page calls requiredCould not checkLow → not re-rated
31Malformed typedef in the error-info structure listingStill presentLow → Info
32package.json samples start with a // comment lineStill presentInfo → Info
33Parameter description gives the wrong unit for a UTF-8 string lengthStill presentLow → Low
34Stream consumer example prints 76 bytes for a 27-byte payloadStill presentInfo → Low
35Embedded-addon sample writes to a predictable shared path and loads itStill presentLow → Low

The full record of this re-check: github.com/ondrejdvorak78/nodejs-v24-api-docs-errors.

How to read this page

Each finding keeps the number it has in the audit report. The rating shown first is the one after review; the first automated rating is listed with it. 13 findings were first rated Medium or High; 10 of them are Medium or High after review. Text marked "From the report" is quoted from the audit report; fixes are suggestions and were not tested. Locations are paths inside the fetched copy of the documentation.

Medium after review (10)

9. Medium NAPI_MODULE_INIT example does not compile
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: n-api.md:2142
From the report
Evidence
napi_status result;

  status = napi_create_int64(env, 42, &answer);
Why it matters

The variable is declared as result but used as status. An addon author who copies the example from the module-registration section gets a compile error every time.

Suggested fix, not tested

Declare napi_status status;.

10. Medium napi_define_properties walkthrough does not compile
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: n-api.md:4548
From the report
Evidence
napi_status status = napi_status_generic_failure;
...
  { "bar", NULL, NULL, NULL, NULL, barValue, napi_writable | napi_configurable, NULL }
}
Why it matters

The enumerator is napi_generic_failure, so the first line fails, and the descriptor array at line 4566 has no closing semicolon. Anyone copying the multi-property example gets compile errors. The attributes also omit napi_enumerable although the JavaScript equivalent shown sets enumerable: true.

Suggested fix, not tested

Use napi_generic_failure, end the array with };, and add napi_enumerable to match the JavaScript counterpart.

12. Medium REPL client example throws on every normal exit
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: repl.md:1057
From the report
Evidence
sock.on('close', () => {
  process.stdin.setRawMode(false);
  process.stdin.pause();
  sock.removeListener('close', done);
Why it matters

done is not defined, so closing the socket (the .exit command, Ctrl+D, or server shutdown) raises a ReferenceError. The same code is at line 1089. Anyone who runs the documented client and ends a session sees the crash.

Suggested fix, not tested

Remove the removeListener line, or name the handler and pass that reference.

13. Medium Single-executable tutorial builds one file name and then signs and runs another
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: single-executable-applications.md:137
From the report
Evidence
cp $(command -v node) hello   ...   codesign --sign - sea   ...   $ ./sea world
Why it matters

Steps 4 to 6 create and inject into hello or hello.exe. Steps 7 and 8 sign and run sea or sea.exe, which do not exist, so signing and running fail on a normal path. Step 6 also says the blob was created in step 1 (line 98), but step 3 creates it.

Suggested fix, not tested

Use one name through steps 7 and 8 (hello, hello.exe) and correct the step reference.

14. Medium Readable.filter, map, forEach and toArray examples destructure an array result as an object
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: stream.md:2276
From the report
Evidence
const { address } = await resolver.resolve4(domain, { ttl: true });
  return address.ttl > 60;
Why it matters

With ttl: true, resolve4 resolves to an array of { address, ttl } records, so address is undefined and address.ttl throws a TypeError on the first element. The map, forEach and toArray examples (lines 2336 and 2383) repeat the destructuring and return undefined. Anyone running the examples gets a failing stream or empty output.

Suggested fix, not tested

Read the array, for example const [{ ttl }] = await resolver.resolve4(domain, { ttl: true }); return ttl > 60;, and return the records in the other examples.

15. Medium Whole-file read example joins Buffer chunks as strings
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: stream.md:1625
From the report
Evidence
chunks.push(chunk);
...
const content = chunks.join('');
Why it matters

Without setEncoding, the chunks are Buffers and join('') converts each one separately. A multi-byte UTF-8 character split across two chunks turns into replacement characters, so non-ASCII content longer than one chunk is silently corrupted. The page presents this as the way to read a whole file.

Suggested fix, not tested

Use Buffer.concat(chunks).toString('utf8') or call readable.setEncoding('utf8') first.

16. Medium stream/iter duplex() echo example reads the wrong end of the pair
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: stream_iter.md:879
From the report
Evidence
for await (const chunks of server.readable) { await server.writer.writev(chunks); }
...
console.log(await text(server.readable)); // handled by echo
Why it matters

The page says data written to one channel's writer appears in the other channel's readable. The echo loop already consumes server.readable, and its output goes to client.readable. The final line starts a second consumer on server.readable and never ends server.writer, so a developer who runs it gets an empty result, an error or a hang instead of the echoed text. The CommonJS copy has the same flaw.

Suggested fix, not tested

Read the echo with text(client.readable) and call await server.writer.end() after the loop.

19. Medium TLS setup commands produce PKCS#12 files that the samples read as PEM, and the two samples overwrite each other's files
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: tls.md:2354
From the report
Evidence
openssl pkcs12 -certpbe AES-256-CBC -export -out client-cert.pem \
  -inkey server-key.pem -in server-cert.pem
Why it matters

pkcs12 -export writes a binary PKCS#12 bundle, but the samples read the file with readFileSync and pass it as ca (PEM expected). The tls.connect() section repeats the pattern at line 1925. Both pages also write the same file names, so following one overwrites what the other needs. A developer who follows the commands cannot get the echo example to verify its peer.

Suggested fix, not tested

Generate every certificate once as PEM, pass the peer's PEM certificate as ca, use pfx only where a PKCS#12 file is consumed, and use distinct file names per example.

20. Medium Custom test reporter never completes the transform for event types it does not list
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: test.md:1443
From the report
Evidence
transform(event, encoding, callback) {
    switch (event.type) {
      case 'test:dequeue':
        callback(null, `test ${event.data.name} dequeued`);
Why it matters

The switch (lines 1443 to 1478, with the CommonJS copy below) has no default branch. The page documents further event types such as test:complete, test:log, test:summary and test:interrupted. For those, callback is never called, the Transform waits forever, and later events produce no output. A developer who copies the reporter loses test output after the first unlisted event.

Suggested fix, not tested

Add a default: callback(); branch so every event completes.

21. Medium KmacParams documents its algorithm member as 'algorithm' while every sibling class uses 'name'
First rating: Medium · Reviewed rating: Medium · Review: confirmed
Location: webcrypto.md:2404
From the report
Evidence
#### `kmacParams.algorithm`
* Type: {string} Must be `'KMAC128'` or `'KMAC256'`.
Why it matters

kmacImportParams.name (line 2336) and kmacKeyGenParams.name (line 2386) use name, and sign() and verify() take an Algorithm dictionary whose identifying member is name. A developer who passes { algorithm: 'KMAC128', ... } as documented supplies no name, and the call is rejected.

Suggested fix, not tested

Document the member as kmacParams.name.

Low after review (17)

1. Low HTTP server sample echoes a parse error without setting a content type
First rating: Low · Reviewed rating: Low · Review: confirmed
Location: stream.md:439
From the report
Evidence
res.statusCode = 400;
return res.end(`error: ${er.message}`);
Why it matters

The JSON.parse error message quotes part of the request body, and the response carries no Content-Type, so a browser may sniff it as HTML. Whoever copies the sample into a public endpoint reflects attacker-chosen text.

Suggested fix, not tested

Set Content-Type: text/plain; charset=utf-8 and X-Content-Type-Options: nosniff before writing the message, or return a fixed message.

3. Low Legacy URL escaping example names the wrong encoding for the slash
First rating: Low · Reviewed rating: Low · Review: confirmed
Location: url.md:2037
From the report
Evidence
The ASCII
forward slash (`/`) character is encoded as `%3C`.
Why it matters

%3C is the encoding of <, and / is not in the escaped set listed just above, so the sentence is false. A reader who relies on it expects a slash to be rewritten when it is left alone.

Suggested fix, not tested

Replace the example with a character that is in the listed set (for instance < becomes %3C) or delete the slash sentence.

4. Low Handle-scope loop sample leaves the scope open on its error exit
First rating: Low · Reviewed rating: Low · Review: confirmed
Location: n-api.md:1587
From the report
Evidence
status = napi_get_element(env, object, i, &result);
  if (status != napi_ok) {
    break;
  }
Why it matters

The break skips napi_close_handle_scope, while the same page says every scope must be closed before the native method returns. A native addon author who copies the loop leaks the scope on the error path.

Suggested fix, not tested

Close the scope before each break or move the close into a common exit path.

11. Low REPL examples open an unauthenticated code-execution socket on every interface
First rating: Medium · Reviewed rating: Low · Review: rated too high
Location: repl.md:927
From the report
Evidence
net.createServer((socket) => { ... repl.start({ prompt: 'Node.js via TCP socket> ', useGlobal: true, input: socket, output: socket }) ... }).listen(5001);
Why it matters

The same pattern appears at lines 971, 1011 (.listen(1337)) and 1033. listen is given no host, so the server accepts connections from any network, and each connection gets a REPL with the process's full privileges. The only security warning on the page belongs to the later curl example. A developer who copies an example into a long-running service (the page suggests exactly that) exposes remote code execution.

Suggested fix, not tested

Bind the examples to 127.0.0.1 or to a Unix socket in a private directory, and put the same production warning next to each network REPL example.

18. Low Microtask-queue fix snippet uses names the example does not define
First rating: Medium · Reviewed rating: Low · Review: rated too high
Location: vm.md:2330
From the report
Evidence
setImmediate(() => {
  vm.runInContext('', context);
});
Why it matters

The example above it imports only createContext and runInContext and names the context inner_context. The corrective snippet uses vm and context, so a developer who pastes it gets an uncaught ReferenceError inside the callback and the described hang is not fixed.

Suggested fix, not tested

Write runInContext('', inner_context) and show the snippet inside the complete example.

22. Low TLS client example turns hostname verification off
First rating: Low · Reviewed rating: Low · Review: confirmed
Location: tls.md:1865
From the report
Evidence
// Necessary only if the server's cert isn't for "localhost".
  checkServerIdentity: () => { return null; },
Why it matters

The same code is at line 1897. The example's certificate is for localhost, so the override is not needed, and the pinned ca limits the damage. A reader who copies the client and swaps in public CAs ends up with a client that accepts any valid certificate for any host.

Suggested fix, not tested

Remove the override from the sample, or show it wrapping tls.checkServerIdentity and say it is for local demos only.

23. Low TLS session-resumption sample stores sessions in an object that is never pruned
First rating: Low+ (potentially higher) · Reviewed rating: Low · Review: confirmed
Location: tls.md:745
From the report
Evidence
const tlsSessionStore = {};
server.on('newSession', (id, data, cb) => {
  tlsSessionStore[id.toString('hex')] = data;
Why it matters

Entries are added for every new session and never removed, even after the documented session timeout. The surrounding text points to a shared cache for clusters but does not warn that this store is unbounded.

Could be higher if: the page presents the sample as production-ready: the store then grows with every full handshake and a remote client can drive memory use.

Suggested fix, not tested

Show a store with expiry or a size bound, or label the object as illustrative only.

24. Low BlockList.PRIVATE_RANGES is described as covering all non-routable ranges
First rating: Low+ (potentially higher) · Reviewed rating: Low · Review: confirmed
Location: net.md:253
From the report
Evidence
populate a blocklist with all non-routable address ranges.
Why it matters

The page then lists the included ranges, so the exact set is visible, but the sentence overstates it for security use.

Could be higher if: readers build an outbound filter from it: ranges such as 0.0.0.0/8, 100.64.0.0/10 and the IPv6 unspecified address are not in the list that follows, so a filter built from it is not a complete denylist.

Suggested fix, not tested

Reword to 'the RFC 1918, loopback and link-local ranges listed below' and note that it is not a complete denylist.

25. Low Native API signature uses a finalizer type that the page never defines
First rating: Low+ (potentially higher) · Reviewed rating: Low · Review: confirmed
Location: n-api.md:2586
From the report
Evidence
node_api_noenv_finalize finalize_cb,
Why it matters

The page documents napi_finalize and node_api_basic_finalize only; this name appears once.

Could be higher if: the real header has no such type: copying the signature would then fail to compile.

Suggested fix, not tested

Define the type or use a documented one.

26. Low Windows build step installs a deprecated package
First rating: Low+ (potentially higher) · Reviewed rating: Low · Review: confirmed
Location: n-api.md:183
From the report
Evidence
npm install --global windows-build-tools
Why it matters

The recommended toolchain package is deprecated; readers may get stale tooling.

Could be higher if: the package no longer installs on current Windows and Node.js versions, which would make the step fail for every Windows reader.

Suggested fix, not tested

Point to the Visual Studio Build Tools workload or the Node.js installer's optional tools.

27. Low Key-derivation sample defaults to 1000 PBKDF2 iterations
First rating: Low · Reviewed rating: Low · Review: confirmed
Location: webcrypto.md:399
From the report
Evidence
async function pbkdf2(pass, salt, iterations = 1000, length = 256) {
Why it matters

The same page's other sample uses 100_000 iterations. A reader who copies the helper and relies on its default derives keys that are cheap to guess offline.

Suggested fix, not tested

Raise the default to current guidance or remove it so callers must choose, with a note on cost.

28. Low addAbortSignal examples use names that are never imported
First rating: Low · Reviewed rating: Low · Review: confirmed
Location: stream.md:3553
From the report
Evidence
const read = addAbortSignal(
  controller.signal,
  fs.createReadStream(('object.json')),
Why it matters

The three samples call addAbortSignal and finished without importing them, and the third uses ReadableStream without an import, so they raise a ReferenceError as written. The section heading makes the intent clear, so this is an omission.

Suggested fix, not tested

Add the require or import lines to each sample.

29. Low Mocked-timer interval example asserts values the iterator does not yield
First rating: Low+ (potentially higher) · Reviewed rating: Low · Review: could not be settled
Location: test.md:3240
From the report
Evidence
for await (const time of nodeTimersPromises.setInterval(interval, startedAt)) { times.push(time); ...
assert.strictEqual(timeResults[it - 1], startedAt + (interval * it));
Why it matters

The iterator yields the value it was given, not an advancing time, and only setInterval is mocked. The test title also says 'five times' while three iterations run.

Could be higher if: the mocked setInterval yields the supplied start value on every iteration, as the timers page documents for the real one: the assertion at line 3240 then fails on its first comparison.

Suggested fix, not tested

Assert the yielded values as they are, or mock Date as well, and fix the title.

30. Low quic.listen() example omits the sni option the page calls required
First rating: Low · Reviewed rating: Low · Review: confirmed
Location: quic.md:510
From the report
Evidence
const endpoint = await listen((session) => {
  // ... handle the session
});
Why it matters

The page says (line 3348) that sni is required for server sessions. The snippet is minimal and the requirement is stated on the same page, so this is an omission.

Suggested fix, not tested

Add an sni entry to the example or mark it as incomplete.

31. Low Malformed typedef in the error-info structure listing
First rating: Low · Reviewed rating: Low · Review: confirmed
Location: n-api.md:1075
From the report
Evidence
typedef struct napi_extended_error_info {
  ...
};
Why it matters

The typedef has no type name after the closing brace, so it declares nothing usable as napi_extended_error_info.

Suggested fix, not tested

End the declaration with } napi_extended_error_info;.

33. Low Parameter description gives the wrong unit for a UTF-8 string length
First rating: Low+ (potentially higher) · Reviewed rating: Low · Review: confirmed
Location: n-api.md:3349
From the report
Evidence
* `[in] length`: The length of the string in two-byte code units, or
  `NAPI_AUTO_LENGTH` if it is null-terminated.
Why it matters

The parameter belongs to the UTF-8 variant, where the length is in bytes.

Could be higher if: A caller who passes a UTF-16 code-unit count for non-ASCII text would get a truncated key; that would raise this to MEDIUM.

Suggested fix, not tested

Say 'length of the string in bytes'.

35. Low Embedded-addon sample writes to a predictable shared path and loads it
First rating: Low+ (potentially higher) · Reviewed rating: Low · Review: confirmed
Location: single-executable-applications.md:503
From the report
Evidence
const addonPath = path.join(os.tmpdir(), 'myaddon.node');
fs.writeFileSync(addonPath, new Uint8Array(getRawAsset('myaddon.node')));
Why it matters

The file name in the shared temp directory is fixed and the file is then loaded as native code.

Could be higher if: on multi-user hosts: another local user can pre-create or link the fixed path and obtain code execution as the application user.

Suggested fix, not tested

Create a private directory with fs.mkdtempSync and write the addon there.

Info after review (7)

2. Info URL-building sample trusts forwarded-host headers
First rating: Low · Reviewed rating: Info · Review: rated too high
Location: url.md:1930
From the report
Evidence
const host = req.headers['x-forwarded-host'] || req.headers.host || 'example.com';
return new URL(`${proto}://${host}${req.url || '/'}`);
Why it matters

The sample builds an absolute URL from client-controllable headers. The following paragraph says it assumes a trusting reverse proxy, so the risk is limited to readers who copy the code without that assumption.

Suggested fix, not tested

Take the host from configuration or an allowlist in the sample, and show the forwarded-header form only next to a check of the scheme and host values.

5. Info HTTP server sample buffers the whole request body with no size limit
First rating: Low · Reviewed rating: Info · Review: rated too high
Location: stream.md:425
From the report
Evidence
req.on('data', (chunk) => {
    body += chunk;
  });
Why it matters

The sample is the page's main HTTP server example. Node applies no body limit, so a copied endpoint lets any client send a body as large as memory allows before JSON.parse runs.

Suggested fix, not tested

Track the received length, answer 413 and destroy the request past a limit, and say in the text that the sample has no cap.

6. Info Streamed decompression sample has no output cap
First rating: Low · Reviewed rating: Info · Review: rated too high
Location: zlib.md:300
From the report
Evidence
case 'br':
  pipeline(response, zlib.createBrotliDecompress(), output, onError);
Why it matters

The client sample decompresses a network response into output with no limit on decompressed size. A hostile server can send a small compressed body that expands enormously. The maxOutputLength option protects only the convenience methods.

Suggested fix, not tested

Show a counting transform that aborts the pipeline past a limit, or state that the sample is unbounded.

7. Info Header-parsing sample grows its buffer without a limit
First rating: Low · Reviewed rating: Info · Review: rated too high
Location: stream.md:1919
From the report
Evidence
// Still reading the header.
      header += str;
Why it matters

If the delimiter never arrives, the sample keeps appending untrusted input to header. A reader who copies it into a server parses arbitrarily long input.

Suggested fix, not tested

Cap the header length, call the callback with an error and destroy the stream when no delimiter is found within the cap.

8. Info Example writes helper files into the script directory without checking for existing files
First rating: Low · Reviewed rating: Info · Review: rated too high
Location: vm.md:2412
From the report
Evidence
writeFileSync(resolve(import.meta.dirname, 'test.mjs'),
              'export const filename = "./test.json";');
Why it matters

Running the sample silently overwrites any existing test.mjs or test.json next to the script.

Suggested fix, not tested

Write the helper files into a fresh directory from fs.mkdtempSync, or use the wx flag.

32. Info package.json samples start with a // comment line
First rating: Low · Reviewed rating: Info · Review: rated too high
Location: packages.md:458
From the report
Evidence
// package.json
{
  "name": "my-package",
Why it matters

Pasted into a real package.json, the comment makes the file invalid JSON.

Suggested fix, not tested

Move the file name into the code fence label or a heading.

34. Info Stream consumer example prints 76 bytes for a 27-byte payload
First rating: Low · Reviewed rating: Info · Review: rated too high
Location: webstreams.md:1636
From the report
Evidence
const readable = Readable.from(dataArray);
...
// Prints: from readable: 76
Why it matters

Readable.from iterates a Uint8Array element by element, so the printed 76 is the length of the decimal digits of each byte, not the data size. The sibling examples print 27. The printed value is accurate, but the example looks like a correct way to turn bytes into a stream and teaches a pattern that corrupts data.

Suggested fix, not tested

Use Readable.from([dataArray]) or a Buffer and print 27.

Excluded on review (1)

Findings the review showed to be wrong or a repeat of another finding. They are not counted above.

Want this for your code?

Upload a ZIP or link a public GitHub repo, pick the areas and the depth, and get findings by severity with fixes.