
| Audited | auth0/node-jsonwebtoken at commit b924272f29192e12926b5414546f7c5bfcc9579d |
|---|---|
| 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. 6 findings in the first audit; 6 still open (6 found again, 0 not reported again but still present). This audit has 11 findings after review, 5 of them new.
| First audit | Finding | Reviewed rating then | Now | In this audit |
|---|---|---|---|---|
| #1 | No size limit on untrusted token parse | Info | Still open | #1 |
| #2 | Algorithm lists in three files | Low | Still open | #3 |
| #3 | Key conversion duplicated | Info | Still open | #4 |
| #4 | Unsigned token + missing key -> raw TypeError | Low | Still open | #7 |
| #5 | Callback-mode sign calls callback twice | Low | Still open | #6 |
| note | release.yml:41 unquoted >= (What-not-covered note) | Info | Still open | #11 |
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. 6 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 (7)
.github/workflows/release.yml:55From the report
- name: Release
...
run: npx semantic-release
Tests run only on pull requests (test.yml). The release job publishes the merged commit on master without running npm test on that commit or on the packed tarball. A broken merge result, for example two pull requests that are each green but conflict when combined, would be published to npm untested.
Run npm test in the release job before semantic-release. Ideally also install the npm pack tarball into a scratch directory and require it as a smoke test.
Review: test.yml triggers only on pull_request, and release.yml runs only npx semantic-release. .releaserc.json has no test step; its exec verifyReleaseCmd only packs and scans. Mitigation the report omits: the release is triggered by a merged chore(release): PR, and prepare-release.yml only bumps package.json and CHANGELOG.md. So the tests-per-PR gap is real but narrow.
From the report
const PUB_KEY_ALGS = ['RS256', 'RS384', 'RS512'];
const EC_KEY_ALGS = ['ES256', 'ES384', 'ES512'];
const RSA_KEY_ALGS = ['RS256', 'RS384', 'RS512'];
The supported algorithms and the algorithms allowed for each key type are written out three times: in sign.js (SUPPORTED_ALGS plus the PS insertion), in verify.js (four lists plus the PS insertion) and in lib/validateAsymmetricKey.js. The copies agree today. A future algorithm, or a change to how PS algorithms are enabled, has to be made in all three places, and missing one makes signing, verification and key validation disagree.
Keep one algorithm table in lib/, keyed by algorithm with its key type and curve, and derive the sign, verify and validation lists from it.
Review: verify.js:11-14 has four lists plus a PS splice at :16-19. sign.js:14 has SUPPORTED_ALGS plus a splice at :15-17. validateAsymmetricKey.js:4-8 has its own table. The "copies agree today" claim holds, with one nuance: validateAsymmetricKey.js lists PS algorithms unconditionally while sign and verify gate them on PS_SUPPORTED.
sign calls the callback twice when an option duplicates a payload claimsign.js:221From the report
if (typeof payload[claim] !== 'undefined') {
return failure(new Error('Bad "options.' + key + '" option. The payload already has an "' + claim + '" property.'));
}
This return sits inside a forEach callback, so it only ends that callback, not sign. With a callback, failure delivers the error and signing continues. The callback is only wrapped in once later (line 230), after this first call, so it fires a second time with a signed token. Callers that react to both calls may answer an HTTP request twice ("headers already sent") or issue a token after logging a failure. The synchronous form is not affected, because there failure throws.
Replace the forEach with a for...of loop and return failure(...) from sign itself. Alternatively, record the conflicting key and return after the loop. Wrap the callback in once at the top of the function.
Review: return failure(...) at sign.js:221 returns only from the forEach callback. In callback mode failure calls callback(err) (:103-105). Signing then continues, once wraps the callback at :230 (after the first call), and :243 calls it again with a token. Sync mode throws at :107 and is not affected, as the report says. The trigger is a developer error (same claim in payload and options), not attacker input. The blast radius is contained.
verify throw a TypeErrorverify.js:148From the report
if (header.alg.startsWith('HS') && secretOrPublicKey.type !== 'secret') {
Consider a token with an empty signature and a header algorithm such as HS256. The application passes an algorithms list containing that algorithm, and its key callback resolves to null or undefined (a common answer for an unknown kid). Every earlier guard lets this through: the token is unsigned, there is no key, and algorithms is set. Line 148 or 150 then reads .type of null. Instead of the documented JsonWebTokenError, a TypeError is thrown. When the key callback answers asynchronously, the throw happens inside the application's own key-lookup code and can surface as an uncaught exception or an unhandled rejection. Any client can trigger it with a crafted token.
Before lines 148-152, return done(new JsonWebTokenError('secret or public key must be provided')) whenever the key is null or undefined and the token's algorithm is not none.
Review: Trace: empty signature, key null/undefined, algorithms set to include the alg. :108 and :112 do not fire, :116 passes, :120 and :132 are skipped, :144 passes, and :148 (or :150) reads .type of null. The report says this is thrown outside the documented error type. It needs a falsy key returned without an error, plus an alg in algorithms that is not none. In the sync path the TypeError leaves verify() through the same channel as every other invalid token. Process-level damage needs an async resolver or a promise wrapper without a catch.
verify.js:210From the report
const invalid_issuer =
(typeof options.issuer === 'string' && payload.iss !== options.issuer) ||
(Array.isArray(options.issuer) && options.issuer.indexOf(payload.iss) === -1);
If options.issuer is anything other than a string or an array, invalid_issuer is false and every issuer is accepted without warning. A RegExp is the likely case, because the neighbouring audience option accepts regular expressions. The application believes the issuer is enforced when it is not.
Validate options.issuer up front, the way nonce and clockTimestamp already are. Accept only a string or an array of strings, and return a JsonWebTokenError for any other type.
Review: if (options.issuer) at :209 is true for a RegExp or object. :210-212 evaluate to false for non-string/non-array, so no issuer is enforced. The README (line 153) documents the option as string or array of strings, so this is fail-open on a type the docs exclude. The report is correct that audience accepts regex and issuer does not, which invites the mistake. There is no up-front type validation as for nonce/clockTimestamp (:45-55).
verify.js:196From the report
const target = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
...
return audience instanceof RegExp ? audience.test(targetAudience) : audience === targetAudience;
When the token has no aud claim, the target list is [undefined]. RegExp.test(undefined) tests the text "undefined". Permissive patterns such as /.*/, /^[a-z]+$/ or /def/ therefore match, and a token issued with no audience at all passes the audience check.
When options.audience is set, reject the token if payload.aud is missing or is not a string or an array of strings. Call .test only on string values.
Review: Mechanism confirmed: :196 gives [undefined] and :200 calls audience.test(undefined), which tests the string "undefined". So /def/, /.*/ or /^[a-z]+$/ match a token with no aud. Realistic anchored patterns (for example /^api\.example\.com$/) do not match. The token must also carry a valid signature from a trusted signer. The report's "a token issued with no audience at all passes" is true only for permissive patterns. Real but narrow, so LOW.
sign.js:248, and the same check at sign.js:240 for the asynchronous pathFrom the report
let signature = jws.sign({header: header, payload: payload, secret: secretOrPrivateKey, encoding: encoding});
// TODO: Remove in favor of the modulus length check before signing once node 15+ is the minimum supported version
if(!options.allowInsecureKeySizes && /^(?:RS|PS)/.test(header.alg) && signature.length < 256) {
On Node versions below 15.7, key details are not available, so the 2048-bit check at line 132 is skipped and this fallback is the only guard. However, signature here is the whole compact token (header.payload.signature), not the signature segment. Its length is above 256 characters for almost any payload, so tokens signed with 1024-bit RSA keys are accepted. package.json declares support for Node >=12, while the CI matrix (test.yml:18) starts at Node 16, so this path is never run in tests.
Measure only the signature segment: the decoded length of split('.')[2] must be at least 256 bytes. Alternatively, raise engines.node to >=15.7, or add the older versions to the CI matrix.
Review: defect CONFIRMED. The fallback at sign.js:248 tests signature.length < 256, but signature is the whole header.payload.signature string returned by jws.sign. For a 1024-bit key the signature segment alone is about 171 characters, so a token with a payload JSON of about 35 bytes or more passes the check. A very small payload such as {foo:'bar'} stays under 256 and is caught, which is why the repo tests pass; the report's "almost any payload" is slightly strong. The primary check at :132-137 relies on asymmetricKeyDetails, which only exists from Node 15.7, so on Node 12-14 the broken fallback is the only guard. package.json:68-70 declares node >=12 and test.yml:18 starts at Node 16, so the path is untested. Applies only to EOL Node, and only to the developer's own chosen key.
Info after review (4)
verify.js:67From the report
const parts = jwtString.split('.');
...
decodedToken = decode(jwtString, { complete: true });
verify accepts a token string of any length. It splits it, base64-decodes it and JSON-parses the header and payload before checking any size. It then walks an aud array of any length chosen by the token's author. A service that passes request headers straight into verify therefore does work in proportion to whatever an unauthenticated client sends. Most deployments are protected by an upstream header-size limit, so this is a hardening point, not a demonstrated outage.
Add an option such as maxTokenLength with a sensible default, for example 8 KB, and reject longer tokens before splitting or decoding. Also cap the number of audience entries that are examined. Reject anything over the cap instead of truncating it.
Review: The absence of a limit is factual (only parts.length !== 3 at verify.js:69, no length checks in verify.js or decode.js). The report itself says upstream header limits usually cover it, "a hardening point, not a demonstrated outage".
sign.js:114, with verify.js:120From the report
if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) {
try {
secretOrPrivateKey = createPrivateKey(secretOrPrivateKey)
Two parts of the code are written twice with the same structure:
- the "try an asymmetric key, then fall back to a secret key" conversion (
sign.js:114-124,verify.js:120-130) - the check that the key type matches the algorithm family (
sign.js:126-130,verify.js:148-152)
Security fixes to key handling have to be applied to both copies.
Move the conversion into a shared helper that takes createPrivateKey or createPublicKey as a parameter, and put the type-versus-algorithm check in that helper too.
Review: sign.js:114-124 and verify.js:120-130 are the same cascade (private/public key, then secret key). sign.js:126-130 and verify.js:148-152 are the same type-versus-algorithm check.
From the report
const clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1000);
This is not a defect. It is a small inconsistency risk: a future change to how "now" is taken (a clock option, a different rounding) would have to be repeated in three files.
Optionally, add one nowSeconds() helper in lib/ and use it in all three places.
Review: verify.js:57, sign.js:185 and lib/timespan.js:4 each compute Math.floor(Date.now() / 1000). The report states it is not a defect.
.github/workflows/release.yml:41From the report
run: pip install boto3>=1.34.159 requests>=2.32.3 rl-deploy>=2.2.3.0 pip-system-certs>=4.0
The specifiers are unquoted, so bash reads each >=… as an output redirection. pip installs whatever versions are current, without the intended minimums. Its output goes into stray files named =1.34.159 and so on, which hides install errors from the log. This happens in the job that holds the AWS role, the npm publishing path and id-token: write.
Quote every specifier, for example pip install "boto3>=1.34.159" "requests>=2.32.3" "rl-deploy>=2.2.3.0" "pip-system-certs>=4.0". Better still, use a pinned requirements file with hashes. The same job also runs npm install with package-lock.json ignored (.gitignore:5). Committing the lockfile and using npm ci would make release-time dependencies reproducible as well.
Review: defect CONFIRMED. With shell: bash, boto3>=1.34.159 parses as boto3 plus stdout redirected to a file named =1.34.159. The floors are dropped and stray files are created. But pip then installs the latest versions, which satisfy any "at least" floor, so there is no practical downgrade risk. The stdout loss hides pip progress, while errors on stderr still show. The report's remark that the lockfile is gitignored is correct (.gitignore:5), and the job does hold id-token: write and the AWS role.