@blamejs/core 0.15.57 → 0.15.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/lib/file-upload.js +54 -18
- package/lib/network-tls.js +97 -5
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,10 @@ upgrading across more than a few patches at a time.
|
|
|
8
8
|
|
|
9
9
|
## v0.15.x
|
|
10
10
|
|
|
11
|
+
- v0.15.59 (2026-06-29) — **OCSP response validation binds the response to the certificate's issuer (issuerNameHash + issuerKeyHash), not the serial number alone, refusing a wrong-issuer "good".** An OCSP SingleResponse identifies the certificate it covers by a CertID of (hashAlgorithm, issuerNameHash, issuerKeyHash, serialNumber) — RFC 6960 §4.1.1. b.network.tls.ocsp.evaluate matched a response to the certificate under validation by the serial number alone and never compared the CertID's issuer hashes. Because a serial number is unique only within one issuer, a responder key that serves more than one issuer identity — a delegated OCSP responder, or a CA key spanning issuers — could have a signed "good" response for serial-S under issuer-Y accepted as proof for the serial-S certificate under issuer-X. The evaluator now recomputes the expected issuerNameHash and issuerKeyHash from the issuer certificate and refuses a response whose CertID issuer hashes do not match. b.network.tls.ocsp.fetch supplies the issuer certificate automatically (its issuerPem is the leaf's issuer); ocsp.requireGood and direct ocsp.evaluate callers pass the issuer cert explicitly as the new issuerCertDer (requireGood's issuerPem may be a delegated OCSP responder rather than the issuer, so it is not used as the issuer), and a response with no issuer certificate available stays bound on serial plus signature as before. **Security:** *OCSP evaluate binds the response CertID to the issuer, not the serial alone (RFC 6960 §4.1.1)* — b.network.tls.ocsp.evaluate selected the matching SingleResponse by normalized serial number only, ignoring the CertID's issuerNameHash and issuerKeyHash. Since serials are unique only per issuer, a "good" response signed by a key that also serves a different issuer (a delegated id-kp-OCSPSigning responder, or a shared CA key) could be replayed as proof for a same-serial certificate under another issuer. evaluate now recomputes the expected issuerNameHash = Hash(issuer DN) and issuerKeyHash = Hash(issuer public key) under the CertID's own hash algorithm and refuses the response if either differs ("wrong-issuer response"). b.network.tls.ocsp.fetch forwards the issuer certificate automatically (its issuerPem is the leaf's issuer); ocsp.requireGood and a direct ocsp.evaluate caller enable the binding by passing issuerCertDer (the issuer cert DER) — requireGood's issuerPem may be a delegated OCSP responder, so the issuer cert is taken explicitly rather than derived from it — and a call without an issuer certificate retains the prior serial-plus-signature binding.
|
|
12
|
+
|
|
13
|
+
- v0.15.58 (2026-06-29) — **File-upload content-safety scanning now also runs the gate for a file's magic-byte-detected type, so a mislabeled file can't dodge the scanner for its real type by choosing the extension.** b.fileUpload selected the per-extension content-safety gate purely from the upload's filename extension, which the uploader controls. A file whose magic bytes identify one type but whose name carries another extension (e.g. a PDF named photo.png) was therefore scanned by the gate for the named extension — or, when no gate was registered for that extension, not scanned at all — so an uploader could dodge the scanner configured for the file's real type by renaming it. When a fileType detector is wired, finalize now also runs the content-safety gate for the type the magic bytes identify, in addition to the filename-extension gate, so the scanner for the real type runs even under a mismatched name. Magic-byte-less text formats (HTML, SVG, CSV) cannot be classified this way; that residual is covered by serving uploads with an explicit Content-Type plus X-Content-Type-Options: nosniff and by registering a content-safety gate for every accepted extension. **Security:** *Content-safety gate selection follows the sniffed type, not just the filename extension* — finalize chose the content-safety gate from nodePath.extname(filename), so a file's real type could be hidden behind a chosen extension: a PDF named photo.png ran the .png gate (or, with no .png gate, skipped scanning) and never reached the .pdf scanner. When opts.fileType is wired, finalize now detects the magic-byte type and, if it differs from the filename extension and a gate is registered for it, runs that gate too (alongside the filename-extension gate), refusing or sanitizing per the gate's decision. Existing behavior is unchanged when no fileType detector is wired or the detected type matches the extension. Formats without magic bytes (HTML/SVG/CSV/plain text) remain undetectable by content sniffing — defend those by serving stored files with a fixed Content-Type and X-Content-Type-Options: nosniff, and by registering a content-safety gate for each accepted extension.
|
|
14
|
+
|
|
11
15
|
- v0.15.57 (2026-06-29) — **The RFC 9421 HTTP-message-signature verifier now enforces a required-coverage floor by default, refusing a signature whose covered set omits `@method` / `@target-uri` (and `content-digest` for bodied requests).** b.crypto.httpSig.verify built the signature base entirely from the covered-component list carried in the message's own Signature-Input header and never checked that the signature actually covered the security-relevant parts of the request (RFC 9421 §3.2). A signature covering only @authority therefore verified even after the method, target URI, or body were changed — so a captured signature could be replayed across a different method and path, or a request body swapped, under an otherwise-valid signature. verify now refuses a signature whose covered set omits a required component, returning { valid: false, reason: "missing-required-component", missing: [...] } before the cryptographic check. By default (security-on, not opt-in) it requires @method and @target-uri on every request, plus content-digest when the request carries a body; an operator can pass requiredComponents to assert an exact set, or requiredComponents: [] to waive the floor (the signature itself is still verified). **Security:** *httpSig.verify enforces a required-coverage floor (RFC 9421 §3.2)* — The verifier trusted the covered-component list from the message's Signature-Input header without requiring that any particular component be covered, so an under-covered signature (e.g. covering only @authority) verified while the method, target URI, and body were free to change — a captured signature replayed across method+path, or a swapped body, passed verification. verify now refuses a signature missing a required component with reason "missing-required-component" (and a missing[] list) before the crypto check. The default floor is @method + @target-uri on every request plus content-digest for bodied requests; requiredComponents overrides it explicitly, and requiredComponents: [] waives the floor for callers that intentionally sign a narrower set (the signature itself is still verified). **Migration:** *Signers must cover @method + @target-uri (and content-digest for bodied requests)* — If you verify HTTP message signatures with b.crypto.httpSig.verify, signatures whose covered set omits @method or @target-uri (or content-digest on a request with a body) now fail with reason "missing-required-component". Broaden the signer's covered set to include them (recommended), pass requiredComponents to assert the exact components your application requires, or pass requiredComponents: [] to keep the prior behavior of accepting whatever the signer covered. Verifying a fully-covered signature is unchanged.
|
|
12
16
|
|
|
13
17
|
- v0.15.56 (2026-06-29) — **Break-glass and dual-control wildcard scope matching is now segment-aware, and the JMAP cross-tenant gate validates every account-id argument (including `fromAccountId`), closing two authorization gaps.** Two authorization gates under-checked their input. b.breakGlass and b.dualControl matched a wildcard scope/role by stripping a trailing "*" and doing a raw string-prefix comparison (requireScope.indexOf(prefix) === 0), which ignores ":" segment boundaries — so a partial-segment grant like "phi:a*" satisfied a required "phi:admin", letting a holder break-glass-unseal or approve a flow they were not scoped for. Both now match through the canonical, segment-aware b.permissions.match, so only an exact scope or a whole-segment wildcard ("phi:*") satisfies the requirement. Separately, the JMAP server's cross-tenant gate validated only a method call's destination accountId, not the fromAccountId that /copy methods (Email/copy, CalendarEvent/copy — RFC 8620 §5.4) read their SOURCE account from — so an actor could name a foreign fromAccountId and copy another tenant's data. The gate now validates every account-id argument the call names. **Security:** *Break-glass / dual-control wildcard scope matching is segment-aware* — b.breakGlass grant (requireScope) and b.dualControl approval (approverRoles) matched a wildcard-shaped actor scope/role by stripping its trailing "*" and testing requireScope.indexOf(prefix) === 0 — a raw string prefix that ignores the ":" segment structure. A partial-segment grant therefore over-matched: "phi:a*" satisfied "phi:admin" (and "p*" satisfied any "phi:..."), so an actor with a narrower grant could break-glass-unseal sealed data or approve a dual-control flow they were not authorized for. Both sites now match through b.permissions.match, where "*" must occupy a whole ":"-delimited segment — "phi:*" still satisfies "phi:admin", but "phi:a*" does not. Actor scopes/roles flow from operator-trusted assignment, so this tightens a defense-in-depth gate rather than a request-controlled bypass. · *JMAP cross-tenant gate validates every account-id argument, not only the destination* — The JMAP server rejects a method call that names an accountId outside the actor's enumerated set (RFC 8620 §3.6.1). It checked only accountId, but /copy methods (Email/copy, CalendarEvent/copy — RFC 8620 §5.4) also carry fromAccountId, the SOURCE account they read from. An actor enumerated for their own destination account could therefore name a foreign fromAccountId and have the operator's copy handler read another tenant's messages. The gate now validates every account-id argument (any *AccountId) against the actor's enumerated accounts before the handler runs, so a foreign source account is refused with accountNotFound. **Detectors:** *Scope/role wildcard matching must use b.permissions.match* — A codebase-patterns detector flags the hand-rolled wildcard idiom (a trailing-"*" check plus a slice(0,-1) strip plus a raw indexOf(prefix)===0 prefix match), so a new authorization gate cannot reintroduce a segment-unaware scope match instead of routing through b.permissions.match.
|
package/lib/file-upload.js
CHANGED
|
@@ -1164,11 +1164,36 @@ function create(opts) {
|
|
|
1164
1164
|
}
|
|
1165
1165
|
if (contentSafety) {
|
|
1166
1166
|
var safetyExt = nodePath.extname(filename).toLowerCase();
|
|
1167
|
-
|
|
1168
|
-
|
|
1167
|
+
// Gates to run: the filename-extension gate, plus — when the magic bytes
|
|
1168
|
+
// confidently identify a DIFFERENT type — that type's gate too, so a
|
|
1169
|
+
// mislabeled magic-byte file (e.g. a PDF named .png) cannot dodge the
|
|
1170
|
+
// scanner for its real type by choosing the extension. Text formats with
|
|
1171
|
+
// no magic bytes (HTML/SVG/CSV) are not detectable here; that residual is
|
|
1172
|
+
// covered by the serving layer's Content-Type + X-Content-Type-Options:
|
|
1173
|
+
// nosniff and by registering a content gate for every accepted extension.
|
|
1174
|
+
var gateExts = [safetyExt];
|
|
1175
|
+
// Sniff from the reassembled body, or — for a streamed upload past
|
|
1176
|
+
// maxStreamReassemblyBytes (bodyBuffer null) — the first chunk already
|
|
1177
|
+
// read for the MIME-sniff gate. So a streamed mislabel still routes to its
|
|
1178
|
+
// real type's gate; and when that gate cannot scan the un-reassembled
|
|
1179
|
+
// body, the loop below surfaces it as a streamed-over-cap skip (not a
|
|
1180
|
+
// no-gate skip), so operators can alert rather than miss the bypass.
|
|
1181
|
+
var sniffBytes = bodyBuffer || firstChunk;
|
|
1182
|
+
if (fileType && sniffBytes) {
|
|
1183
|
+
var sniffed = fileType.detect(sniffBytes);
|
|
1184
|
+
if (sniffed && sniffed.extension) {
|
|
1185
|
+
var sniffedExt = "." + String(sniffed.extension).toLowerCase();
|
|
1186
|
+
if (sniffedExt !== safetyExt && gateExts.indexOf(sniffedExt) === -1) {
|
|
1187
|
+
gateExts.push(sniffedExt);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
// Run one gate; throws on refuse / gate-error, mutates bodyBuffer on
|
|
1192
|
+
// sanitize so a later gate sees the cleaned bytes.
|
|
1193
|
+
var _runContentSafetyGate = async function (gate, gateExt) {
|
|
1169
1194
|
var safetyDecision;
|
|
1170
1195
|
try {
|
|
1171
|
-
safetyDecision = await
|
|
1196
|
+
safetyDecision = await gate.check({
|
|
1172
1197
|
bytes: bodyBuffer,
|
|
1173
1198
|
filename: filename,
|
|
1174
1199
|
actor: actor,
|
|
@@ -1186,12 +1211,12 @@ function create(opts) {
|
|
|
1186
1211
|
"fileUpload.finalize: contentSafety gate threw: " + (gateErr && gateErr.message));
|
|
1187
1212
|
}
|
|
1188
1213
|
if (!safetyDecision.ok || safetyDecision.action === "refuse") {
|
|
1189
|
-
_emitObs("fileUpload.content_safety_refused", 1, { ext:
|
|
1214
|
+
_emitObs("fileUpload.content_safety_refused", 1, { ext: gateExt });
|
|
1190
1215
|
_emitAudit("fileUpload.finalize_failure", {
|
|
1191
1216
|
actor: requestHelpers.extractActorContext(actor),
|
|
1192
1217
|
outcome: "failure", reason: "content-safety-refused",
|
|
1193
1218
|
metadata: {
|
|
1194
|
-
uploadId: uploadId, ext:
|
|
1219
|
+
uploadId: uploadId, ext: gateExt,
|
|
1195
1220
|
issues: gateContract.summarizeIssues(safetyDecision.issues),
|
|
1196
1221
|
},
|
|
1197
1222
|
});
|
|
@@ -1200,26 +1225,37 @@ function create(opts) {
|
|
|
1200
1225
|
(safetyDecision.issues || []).map(function (i) { return i.kind; }).join(", ") + ")");
|
|
1201
1226
|
}
|
|
1202
1227
|
if (safetyDecision.action === "sanitize" && safetyDecision.sanitized) {
|
|
1203
|
-
// Replace the body buffer with the sanitized variant.
|
|
1204
1228
|
bodyBuffer = safetyDecision.sanitized;
|
|
1205
|
-
// Clear the streaming alias if present — sanitized fits in memory.
|
|
1206
1229
|
bodyStream = null;
|
|
1207
1230
|
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1231
|
+
};
|
|
1232
|
+
var ranAnyGate = false;
|
|
1233
|
+
var hasGateButNoBody = false;
|
|
1234
|
+
for (var ge = 0; ge < gateExts.length; ge += 1) {
|
|
1235
|
+
var gateForExt = contentSafety[gateExts[ge]];
|
|
1236
|
+
if (gateForExt && typeof gateForExt.check === "function") {
|
|
1237
|
+
if (bodyBuffer) {
|
|
1238
|
+
await _runContentSafetyGate(gateForExt, gateExts[ge]);
|
|
1239
|
+
ranAnyGate = true;
|
|
1240
|
+
} else {
|
|
1241
|
+
hasGateButNoBody = true;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
if (!ranAnyGate && hasGateButNoBody) {
|
|
1246
|
+
// A content-safety gate is configured, but the upload streamed past
|
|
1247
|
+
// maxStreamReassemblyBytes and was never reassembled into a buffer the
|
|
1248
|
+
// byte-level gate can inspect. The MIME-sniff and filename gates still
|
|
1249
|
+
// ran; the per-extension content gate did NOT. Audit the skip so
|
|
1250
|
+
// operators can alert, lower maxStreamReassemblyBytes, or cap
|
|
1215
1251
|
// maxFileBytes to force content-gating of this type.
|
|
1216
1252
|
_emitContentSafetySkipped(uploadId, actor, "streamed-over-reassembly-cap",
|
|
1217
1253
|
safetyExt, verified.totalBytes);
|
|
1218
|
-
} else {
|
|
1254
|
+
} else if (!ranAnyGate) {
|
|
1219
1255
|
// contentSafety is wired but no gate is registered for this file's
|
|
1220
|
-
// extension — the byte-level scan does not run.
|
|
1221
|
-
// a review can tell the upload bypassed content
|
|
1222
|
-
// register a gate for the extension if it should be
|
|
1256
|
+
// extension or its sniffed type — the byte-level scan does not run.
|
|
1257
|
+
// Audit the skip so a review can tell the upload bypassed content
|
|
1258
|
+
// scanning (and register a gate for the extension if it should be).
|
|
1223
1259
|
_emitContentSafetySkipped(uploadId, actor, "no-gate-for-extension",
|
|
1224
1260
|
safetyExt, verified.totalBytes);
|
|
1225
1261
|
}
|
package/lib/network-tls.js
CHANGED
|
@@ -857,6 +857,16 @@ var OID_BASIC_OCSP_RESPONSE = "1.3.6.1.5.5.7.48.1.1";
|
|
|
857
857
|
// OCSP nonce extension — id-pkix-ocsp-nonce.
|
|
858
858
|
var OID_OCSP_NONCE = "1.3.6.1.5.5.7.48.1.2";
|
|
859
859
|
var OID_SHA1 = "1.3.14.3.2.26"; // SHA-1 algorithm OID arc
|
|
860
|
+
// RFC 6960 §4.1.1 CertID hashAlgorithm OIDs → node hash name. SHA-1 is the
|
|
861
|
+
// universally-supported default (buildOcspRequest emits it); the SHA-2 family is
|
|
862
|
+
// §4.3-optional but accepted when a responder uses it. An unknown OID is refused
|
|
863
|
+
// (fail closed) rather than skipping the issuer binding.
|
|
864
|
+
var OCSP_CERTID_HASH_OID_TO_NODE = {
|
|
865
|
+
"1.3.14.3.2.26": "sha1", // id-sha1
|
|
866
|
+
"2.16.840.1.101.3.4.2.1": "sha256", // id-sha256
|
|
867
|
+
"2.16.840.1.101.3.4.2.2": "sha384", // id-sha384
|
|
868
|
+
"2.16.840.1.101.3.4.2.3": "sha512", // id-sha512
|
|
869
|
+
};
|
|
860
870
|
var OID_RSA_SHA256 = "1.2.840.113549.1.1.11";
|
|
861
871
|
var OID_RSA_SHA384 = "1.2.840.113549.1.1.12";
|
|
862
872
|
var OID_RSA_SHA512 = "1.2.840.113549.1.1.13";
|
|
@@ -1032,7 +1042,20 @@ function parseOcspResponse(der) {
|
|
|
1032
1042
|
if (sr.length < 3) continue; // minimum SingleResponse fields
|
|
1033
1043
|
// sr[0] = certID SEQUENCE, sr[1] = certStatus CHOICE, sr[2] = thisUpdate.
|
|
1034
1044
|
var certIdChildren = asn1.readSequence(sr[0].value);
|
|
1035
|
-
// certID = SEQUENCE { hashAlgorithm, issuerNameHash
|
|
1045
|
+
// certID = SEQUENCE { hashAlgorithm AlgorithmIdentifier, issuerNameHash
|
|
1046
|
+
// OCTET STRING, issuerKeyHash OCTET STRING,
|
|
1047
|
+
// serialNumber INTEGER } (RFC 6960 §4.1.1)
|
|
1048
|
+
// Capture ALL FOUR fields. A response binds to the cert under validation by
|
|
1049
|
+
// (issuerNameHash, issuerKeyHash, serialNumber): a serial is unique only
|
|
1050
|
+
// PER ISSUER, so a "good" for serial-S under a different issuer (a delegated
|
|
1051
|
+
// responder, or a CA key spanning issuer identities) must not be accepted as
|
|
1052
|
+
// proof for serial-S under the issuer we actually asked about.
|
|
1053
|
+
var certIdHashAlgOid = certIdChildren.length >= 1
|
|
1054
|
+
? asn1.readOid(asn1.readSequence(certIdChildren[0].value)[0]) : null;
|
|
1055
|
+
var issuerNameHash = certIdChildren.length >= 2
|
|
1056
|
+
? asn1.readOctetString(certIdChildren[1]) : null;
|
|
1057
|
+
var issuerKeyHash = certIdChildren.length >= 3
|
|
1058
|
+
? asn1.readOctetString(certIdChildren[2]) : null;
|
|
1036
1059
|
var serialHex = certIdChildren.length >= 4
|
|
1037
1060
|
? certIdChildren[3].value.toString("hex")
|
|
1038
1061
|
: null;
|
|
@@ -1053,10 +1076,13 @@ function parseOcspResponse(der) {
|
|
|
1053
1076
|
nextUpdate = _parseTime(asn1.readNode(sr[3].value, 0));
|
|
1054
1077
|
}
|
|
1055
1078
|
responses.push({
|
|
1056
|
-
certIdSerialHex:
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1079
|
+
certIdSerialHex: serialHex,
|
|
1080
|
+
certIdHashAlgOid: certIdHashAlgOid,
|
|
1081
|
+
issuerNameHash: issuerNameHash,
|
|
1082
|
+
issuerKeyHash: issuerKeyHash,
|
|
1083
|
+
certStatus: certStatus,
|
|
1084
|
+
thisUpdate: thisUpdate,
|
|
1085
|
+
nextUpdate: nextUpdate,
|
|
1060
1086
|
});
|
|
1061
1087
|
}
|
|
1062
1088
|
|
|
@@ -1169,6 +1195,40 @@ function evaluateOcspResponse(ocspDer, opts) {
|
|
|
1169
1195
|
return { ok: false, status: parsed.status, signatureValid: true,
|
|
1170
1196
|
errors: ["OCSP response has no entry for the requested cert serial"] };
|
|
1171
1197
|
}
|
|
1198
|
+
// Bind the matched SingleResponse to the ISSUER of the cert under validation,
|
|
1199
|
+
// not the serial alone. RFC 6960 §4.1.1: CertID is (hashAlgorithm,
|
|
1200
|
+
// issuerNameHash, issuerKeyHash, serialNumber); a serial is unique only per
|
|
1201
|
+
// issuer. Without this, a "good" for serial-S signed by a key that also serves
|
|
1202
|
+
// a DIFFERENT issuer (delegated responder, or a CA key spanning issuer
|
|
1203
|
+
// identities) is accepted as proof for serial-S under the issuer we asked
|
|
1204
|
+
// about. opts.issuerCertDer is the issuer cert (DER) whose DN + SPKI we hash;
|
|
1205
|
+
// both built-in consumer paths forward it from the issuer cert they hold.
|
|
1206
|
+
if (opts.issuerCertDer) {
|
|
1207
|
+
if (!Buffer.isBuffer(opts.issuerCertDer)) {
|
|
1208
|
+
return { ok: false, status: parsed.status, signatureValid: true,
|
|
1209
|
+
errors: ["evaluateOcspResponse: opts.issuerCertDer must be a Buffer (issuer cert DER)"] };
|
|
1210
|
+
}
|
|
1211
|
+
if (!match.issuerNameHash || !match.issuerKeyHash) {
|
|
1212
|
+
return { ok: false, status: parsed.status, signatureValid: true,
|
|
1213
|
+
errors: ["OCSP CertID is missing issuerNameHash/issuerKeyHash — cannot bind the response to the issuer"] };
|
|
1214
|
+
}
|
|
1215
|
+
var expected;
|
|
1216
|
+
try { expected = _expectedOcspCertIdHashes(opts.issuerCertDer, match.certIdHashAlgOid); }
|
|
1217
|
+
catch (e) {
|
|
1218
|
+
return { ok: false, status: parsed.status, signatureValid: true,
|
|
1219
|
+
errors: [(e && e.message) || String(e)] };
|
|
1220
|
+
}
|
|
1221
|
+
if (expected.nameHash.length !== match.issuerNameHash.length ||
|
|
1222
|
+
!bCrypto.timingSafeEqual(expected.nameHash, match.issuerNameHash)) {
|
|
1223
|
+
return { ok: false, status: parsed.status, signatureValid: true,
|
|
1224
|
+
errors: ["OCSP CertID issuerNameHash does not match the issuer of the cert under validation (RFC 6960 §4.1.1 — wrong-issuer response)"] };
|
|
1225
|
+
}
|
|
1226
|
+
if (expected.keyHash.length !== match.issuerKeyHash.length ||
|
|
1227
|
+
!bCrypto.timingSafeEqual(expected.keyHash, match.issuerKeyHash)) {
|
|
1228
|
+
return { ok: false, status: parsed.status, signatureValid: true,
|
|
1229
|
+
errors: ["OCSP CertID issuerKeyHash does not match the issuer of the cert under validation (RFC 6960 §4.1.1 — wrong-issuer response)"] };
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1172
1232
|
// Optional nonce echo verification (RFC 8954 / RFC 6960 §4.4.1).
|
|
1173
1233
|
// When opts.expectedNonce is supplied, the response MUST carry an
|
|
1174
1234
|
// OCSP nonce extension equal to the expected bytes — defends against
|
|
@@ -1321,6 +1381,27 @@ function _extractIssuerNameDerAndKeyBitString(certDer) {
|
|
|
1321
1381
|
};
|
|
1322
1382
|
}
|
|
1323
1383
|
|
|
1384
|
+
// Compute the EXPECTED CertID issuerNameHash + issuerKeyHash for an issuer cert
|
|
1385
|
+
// (DER), under the hash algorithm the responder used. RFC 6960 §4.1.1:
|
|
1386
|
+
// issuerNameHash = Hash(issuer DN, DER); issuerKeyHash = Hash(issuer
|
|
1387
|
+
// subjectPublicKey BIT STRING contents — the key bytes, not the SPKI SEQUENCE).
|
|
1388
|
+
// Reuses _extractIssuerNameDerAndKeyBitString (the same inputs buildOcspRequest
|
|
1389
|
+
// hashes) so the request-build and the response-bind hash IDENTICAL bytes.
|
|
1390
|
+
function _expectedOcspCertIdHashes(issuerCertDer, certIdHashAlgOid) {
|
|
1391
|
+
var nodeHash = OCSP_CERTID_HASH_OID_TO_NODE[certIdHashAlgOid];
|
|
1392
|
+
if (!nodeHash) {
|
|
1393
|
+
throw new TlsTrustError("tls/ocsp-bad-certid-hash-alg",
|
|
1394
|
+
"OCSP CertID hashAlgorithm OID '" + certIdHashAlgOid +
|
|
1395
|
+
"' is not a recognized hash (RFC 6960 §4.1.1)");
|
|
1396
|
+
}
|
|
1397
|
+
var iss = _extractIssuerNameDerAndKeyBitString(issuerCertDer);
|
|
1398
|
+
// lgtm[js/weak-cryptographic-algorithm] — RFC 6960 §4.1.1 CertID lookup hash over the PUBLIC issuer name; a name/key lookup, not an integrity or secrecy operation.
|
|
1399
|
+
var nameHash = nodeCrypto.createHash(nodeHash).update(iss.issuerNameDer).digest(); // lgtm[js/weak-cryptographic-algorithm]
|
|
1400
|
+
// lgtm[js/weak-cryptographic-algorithm] — RFC 6960 §4.1.1 CertID lookup hash over the PUBLIC issuer key; a name/key lookup, not an integrity or secrecy operation.
|
|
1401
|
+
var keyHash = nodeCrypto.createHash(nodeHash).update(iss.issuerKey).digest(); // lgtm[js/weak-cryptographic-algorithm]
|
|
1402
|
+
return { nameHash: nameHash, keyHash: keyHash };
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1324
1405
|
function _extractLeafSerial(leafCertDer) {
|
|
1325
1406
|
var top = asn1.readNode(leafCertDer);
|
|
1326
1407
|
if (top.tag !== asn1.TAG.SEQUENCE) {
|
|
@@ -1470,6 +1551,9 @@ async function fetchOcspResponse(opts) {
|
|
|
1470
1551
|
}
|
|
1471
1552
|
var evald = evaluateOcspResponse(res.body, {
|
|
1472
1553
|
issuerPem: opts.issuerPem,
|
|
1554
|
+
// Bind the response's CertID to the actual issuer (RFC 6960 §4.1.1), not
|
|
1555
|
+
// the serial alone — issuerX is the issuer cert we already parsed.
|
|
1556
|
+
issuerCertDer: issuerX.raw,
|
|
1473
1557
|
// Bind to the leaf being checked (its serial), not whatever the response
|
|
1474
1558
|
// happens to carry — defaults to leafX.serialNumber when not overridden.
|
|
1475
1559
|
serialHex: opts.serialHex || leafX.serialNumber,
|
|
@@ -1510,8 +1594,16 @@ var ocsp = Object.freeze({
|
|
|
1510
1594
|
throw new TlsTrustError("tls/ocsp-empty",
|
|
1511
1595
|
"OCSP response was empty");
|
|
1512
1596
|
}
|
|
1597
|
+
// opts.issuerPem is the OCSP-SIGNING cert, which may be a DELEGATED responder
|
|
1598
|
+
// (not the leaf's issuing CA). The CertID issuer hashes are computed over the
|
|
1599
|
+
// leaf's issuer, so the RFC 6960 §4.1.1 binding needs the actual issuer cert,
|
|
1600
|
+
// supplied explicitly as opts.issuerCertDer. Deriving it from issuerPem would
|
|
1601
|
+
// hash the responder and wrongly reject valid delegated-responder staples, so
|
|
1602
|
+
// when issuerCertDer is absent the bind stays on serial + signature only.
|
|
1603
|
+
var rgIssuerCertDer = Buffer.isBuffer(opts.issuerCertDer) ? opts.issuerCertDer : null;
|
|
1513
1604
|
var evald = evaluateOcspResponse(rv.ocspBytes, {
|
|
1514
1605
|
issuerPem: opts.issuerPem,
|
|
1606
|
+
issuerCertDer: rgIssuerCertDer,
|
|
1515
1607
|
// Bind to the connected peer's certificate serial (not the response's own
|
|
1516
1608
|
// entry) — without it evaluateOcspResponse fails closed.
|
|
1517
1609
|
serialHex: opts.serialHex || (rv.peerCert && rv.peerCert.serialNumber) || null,
|
package/package.json
CHANGED
package/sbom.cdx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.5",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:81180df0-93d0-4b26-b1a8-ac46819c5783",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-06-
|
|
8
|
+
"timestamp": "2026-06-29T14:03:52.612Z",
|
|
9
9
|
"lifecycles": [
|
|
10
10
|
{
|
|
11
11
|
"phase": "build"
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"component": {
|
|
22
|
-
"bom-ref": "@blamejs/core@0.15.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.15.59",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.15.
|
|
25
|
+
"version": "0.15.59",
|
|
26
26
|
"scope": "required",
|
|
27
27
|
"author": "blamejs contributors",
|
|
28
28
|
"description": "The Node framework that owns its stack.",
|
|
29
|
-
"purl": "pkg:npm/%40blamejs/core@0.15.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/core@0.15.59",
|
|
30
30
|
"properties": [],
|
|
31
31
|
"externalReferences": [
|
|
32
32
|
{
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"components": [],
|
|
55
55
|
"dependencies": [
|
|
56
56
|
{
|
|
57
|
-
"ref": "@blamejs/core@0.15.
|
|
57
|
+
"ref": "@blamejs/core@0.15.59",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|