
| Audited | helmetjs/helmet at commit 876101e394f4936cdd1304a2e37b2509d52ed5c7 |
|---|---|
| Date | 11 October 2026 (audited again; first audit 11 October 2026) |
| How it ran | local run on our workstation, full audit, Standard review |
| Verdict after review | Pass with notes (Fail if a High finding remains after review, otherwise Pass with notes) |
Compared with the first audit
Same commit as the first audit: the project's default branch has no later commits (checked 11 October 2026), so nothing could have been fixed upstream in between. Each finding of the first audit (11 October 2026) was checked again against the code audited now. 3 findings in the first audit; 3 still open (3 found again, 0 not reported again but still present). This audit has 7 findings after review, 4 of them new.
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. 2 findings were first rated Medium or High; 0 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. Code locations link to the file and line at the audited commit.
Low after review (5)
index.ts:187 (same pattern at lines 206, 228, 247, 268, 286, 311, 332; the warning branch at 168, 221, 261, 325, 346)From the report
if ("strictTransportSecurity" in options && "hsts" in options) {
throw new Error(
"Strict-Transport-Security option was specified twice. Remove the `hsts` option to fix this error.",
the "specified twice" check is pasted by hand for eight option pairs, and the "does not take options" warning branch for five middlewares, each with its own message and its own switch on undefined/true/false/default. Today they behave the same, but each new header or alias means another hand-copied block. Messages and default handling can drift apart, and a missed case only shows up as wrong behaviour.
drive the parser from one table of entries (header name, primary key, legacy key, default on or off, whether it takes options). Use one helper that resolves the alias, throws on a conflict, warns on unexpected options and creates the middleware. A new header then needs one table row.
build/build-package.ts:44From the report
if (middlewareToBuild) {
const middlewareDir = path.join(rootDir, "middlewares", middlewareToBuild);
entry = path.join(middlewareDir, "index.ts");
the build has a separate path for the thirteen standalone packages. That path is CommonJS only, emits only index.d.cts, merges package-overrides.json over the generated manifest, and ships different README/CHANGELOG files. The only packaging test, test/project-setups.test.ts, runs npm run build with no argument, so it only builds and installs the main package. A broken manifest, export map or type file in a standalone package would only be found after publishing.
add a test or CI step that builds each directory under middlewares/, installs each tarball into a clean project, then requires and calls the middleware. The main package already gets this check.
.github/workflows/nodejs.yml:14From the report
node-version: [22.x, 24.x, 26.x]
the main package declares "node": ">=18.0.0" and most standalone packages declare "node": ">=10.0.0", but CI only runs Node 22 and later. The current source of the Node-10 packages only uses syntax that Node 10 supports, but nothing enforces that. A newer language feature or built-in added to one of them would break users on older runtimes the package still claims to support.
add the oldest declared Node version to the matrix, running at least the built-package smoke tests. Or raise the engines fields to the oldest version actually tested.
middlewares/content-security-policy/index.ts:186 (consumed again at line 235)From the report
for (const element of directiveValue) {
if (typeof element !== "string") continue;
throwErrorIfExists(
the public option type accepts any Iterable as a directive value. At setup, the middleware walks the value once to validate it and then stores the same object. Arrays and Sets are turned into a fixed string, but any other iterable, such as a generator, takes the per-request path and gets walked again at line 235. By then a one-shot iterator is already used up, so every response sends the directive with no sources (for example a bare script-src). The policy is then silently different from the one configured: either far stricter, breaking the site, or not what was intended. No error is raised.
turn each directive value into an array once at setup (Array.from(rawDirectiveValue)), then validate and serve from that array. Or narrow the accepted type to arrays and Sets and reject other iterables with a clear error.
build/helpers.ts:8From the report
const proc = childProcess.spawn("npm", args, {
cwd,
stdio: ["inherit", "ignore", "inherit"],
the promise wrapper only listens for close. If the process cannot be started, the child process emits an error event that nothing handles, and it throws as an uncaught exception instead of rejecting the promise. This happens on Windows, where npm is a .cmd shim that spawn cannot launch without a shell, or wherever npm is not on the PATH. So npm run build (packing step) and the project-setup tests crash with an unhelpful error for contributors on Windows, and the callers' error handling never runs.
add proc.on("error", reject). Resolve the command per platform: use npm.cmd on win32, or pass shell: true there with fixed arguments.
Info after review (2)
middlewares/cross-origin-embedder-policy/index.ts:16 (same shape in cross-origin-opener-policy, cross-origin-resource-policy, x-permitted-cross-domain-policies)From the report
if (ALLOWED_POLICIES.has(policy)) {
return policy;
} else {
four copies of the same validate-or-throw logic. The copies are probably on purpose, because each middleware also ships as its own package with no shared runtime dependency. But the reason is not written down, so a later contributor may "fix" one copy and not the others.
record the decision in one short note (for example in CONTRIBUTING). Or keep a shared helper that the build inlines into each package.
build/build-package.ts:345From the report
await pipe(readOriginal, gunzip, gzip, writeCrushed);
after npm pack, the tarball is decompressed and re-compressed with a different compressor. The new file is published whenever it is smaller. Nothing checks that its content matches the packed original, so a truncated or corrupted output would look like a bigger saving and be the file handed to the publisher.
after re-compressing, decompress both files and compare the bytes, or compare their SHA-256. Print the final tarball's digest and size as the last line of output, so the file that gets published is the one that was checked.