@blamejs/pki 0.6.45 → 0.6.46
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 +8 -0
- package/README.md +1 -1
- package/lib/sigstore.js +110 -4
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to `@blamejs/pki` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## v0.6.46 — 2026-09-06
|
|
8
|
+
|
|
9
|
+
A Sigstore bundle can be checked against the certificate-transparency logs that recorded the signing certificate.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- pki.sigstore.verifyBundle accepts opts.ctLogs, an array of { keyId, spki, validFor? } in the same shape it takes for the Rekor keys, so an operator builds both from the one trusted-root document. When supplied, the certificate-transparency receipt Fulcio embeds in the signing certificate (RFC 6962 section 3.2) is verified: the logged entry is reconstructed from the certificate as it stood before the receipt was added, bound to the key hash of the certificate that issued it, and checked under the key of the pinned log the receipt names. At least one receipt must verify against a pinned log, which is the RFC 6962 section 3.3 floor. A log's validFor window is read at the instant the receipt was signed, since that is when the key was the log's rather than when the artifact was later logged, and a receipt dated after the instant being validated at is not counted (section 5.2); with no opts.time that instant is the end of the Rekor entry's own second, which allows for the entry recording whole seconds while a receipt carries milliseconds and accepts nothing beyond it. The verdict gains sctChecked, saying whether the check ran, and validScts, counting the receipts that verified. A receipt that verifies against no pinned log, and a certificate carrying no receipt at all, are each refused with sigstore/sct-unverified or sigstore/sct-missing rather than passing quietly. The check is opt-in: a caller that supplies no ctLogs verifies exactly as before and reads sctChecked false, while an empty array is refused with sigstore/bad-input rather than read as a policy that checks nothing.
|
|
14
|
+
|
|
7
15
|
## v0.6.45 — 2026-09-06
|
|
8
16
|
|
|
9
17
|
A certification path reaching a certificate signed with a stateful hash-based key validates without a separate call.
|
package/README.md
CHANGED
|
@@ -249,7 +249,7 @@ comment blocks, is at [pkijs.com](https://pkijs.com).
|
|
|
249
249
|
| `pki.shbs` | Stateful hash-based signature verification: HSS/LMS (RFC 8554), carried in X.509 by RFC 9802 and in CMS by RFC 9708, profiled by NIST SP 800-208 for CNSA 2.0 firmware signing. `verify` checks an HSS signature, where every level must pass, and `verifyLms` a single-tree LMS, over the raw public-key and signature blobs the parsers already surface. Pure public-input SHA-256 and SHAKE256 hashing, a data-driven typecode registry, and bounds-before-slice reads; a malformed blob throws a typed `ShbsError` while a well-formed but wrong signature returns `false`. Verification only by design, since stateful signing needs atomic one-time-key state that belongs in an HSM. `pki.path.validate` verifies an HSS-signed certificate on its own, so a chain reaching one needs no separate call: the signature covers the whole tbsCertificate rather than a digest of it (RFC 9802 §7.1), and a CertificateList naming the algorithm takes the same route. It is proven against the self-signed certificate RFC 9802 Appendix A publishes — `verify`, `verifyLms` |
|
|
250
250
|
| `pki.hpke` | Hybrid Public Key Encryption (RFC 9180), the encrypt-to-a-public-key primitive behind TLS ECH, MLS, and OHTTP. `setupS` and `setupR` establish a sender or recipient context (KEM encapsulation plus the HKDF key schedule); the context's `seal` and `open` AEAD-encrypt with a sequence-counter nonce, and `export` derives further secrets; the module-level `seal` and `open` are single-shot wrappers. DHKEM (P-256, P-521, X25519, X448) by HKDF-SHA256/SHA512 by AES-GCM / ChaCha20Poly1305 / export-only, across all four modes, proven against the RFC 9180 Appendix A vectors. DHKEM(P-384) and HKDF-SHA384 are RFC-registered but Appendix A ships no vector for them, so they fail closed until an authoritative KAT exists. Pure composition over `node:crypto`; ML-KEM and X-Wing are a registry data-row extension pending stable drafts — `suites`, `setupS`, `setupR`, `seal`, `open` |
|
|
251
251
|
| `pki.kem` | Composite ML-KEM key establishment (draft-ietf-lamps-pq-composite-kem), a post-quantum ML-KEM hybridized with a traditional RSA-OAEP, ECDH, X25519, or X448 so the established secret holds if either component is later broken. `encapsulate` turns a recipient's composite `SubjectPublicKeyInfo` into a 256-bit shared secret and a ciphertext; `decapsulate` recovers the same secret from the ciphertext and the composite PKCS#8 private key. Each component KEM runs independently and the two secrets are mixed through a SHA3-256 combiner that binds the traditional ciphertext, the traditional public key, and a per-algorithm label. The twelve algorithms pair ML-KEM-768 and ML-KEM-1024 with RSA-OAEP 2048/3072/4096, ECDH over P-256/P-384/P-521 and brainpoolP256r1/P384r1, X25519, and X448, each verified against the draft Appendix G known-answer vectors; a malformed key or ciphertext, an unsupported algorithm, or a component decapsulation failure throws a typed `KemError` — `encapsulate`, `decapsulate` |
|
|
252
|
-
| `pki.sigstore` | Offline verifier for a Sigstore bundle, the artifact `npm publish --provenance` produces and the registry serves. `verifyBundle` composes five fail-closed legs against caller-pinned trust (Fulcio CA roots and Rekor log keys, never trusted from the bundle): the DSSE signature over its PAE preimage under the Fulcio leaf key, the ephemeral Fulcio certificate chain validated as of the Rekor log time, the RFC 9162 inclusion proof folded to a Rekor-signed tree root, the log entry bound to this exact signature, and the in-toto SLSA subject digest the caller confirms against the published artifact. It reuses the X.509 parser, the RFC 5280 path validator, and the Merkle verifier; the net-new codecs are the DSSE PAE byte-builder and a fail-closed JSON reader. `verified: true` says the artifact was signed and logged, not that a party you trust signed it — Fulcio issues to anyone who completes an OIDC flow, so who signed is decided only by `opts.identity`, and `identityChecked` reports which of its fields were compared. An identity policy naming no field, or a field name that is not one of the three, is refused rather than satisfied — either would accept every signer while reading as a policy in force — `pae`, `parseBundle`, `verifyBundle` |
|
|
252
|
+
| `pki.sigstore` | Offline verifier for a Sigstore bundle, the artifact `npm publish --provenance` produces and the registry serves. `verifyBundle` composes five fail-closed legs against caller-pinned trust (Fulcio CA roots and Rekor log keys, never trusted from the bundle): the DSSE signature over its PAE preimage under the Fulcio leaf key, the ephemeral Fulcio certificate chain validated as of the Rekor log time, the RFC 9162 inclusion proof folded to a Rekor-signed tree root, the log entry bound to this exact signature, and the in-toto SLSA subject digest the caller confirms against the published artifact. It reuses the X.509 parser, the RFC 5280 path validator, and the Merkle verifier; the net-new codecs are the DSSE PAE byte-builder and a fail-closed JSON reader. `verified: true` says the artifact was signed and logged, not that a party you trust signed it — Fulcio issues to anyone who completes an OIDC flow, so who signed is decided only by `opts.identity`, and `identityChecked` reports which of its fields were compared. An identity policy naming no field, or a field name that is not one of the three, is refused rather than satisfied — either would accept every signer while reading as a policy in force. A sixth leg is opt-in: pinning the certificate-transparency logs in `opts.ctLogs` checks the receipt Fulcio embeds in the certificate it issues (RFC 6962 §3.2), verified over the certificate as it stood before the receipt was added and under the key of the log that issued it, so the verdict says the signing certificate was public when it was issued rather than handed out quietly. At least one receipt must verify against a pinned log, the verdict reports `sctChecked` and `validScts`, and an empty log set is refused rather than read as a policy that checks nothing — `pae`, `parseBundle`, `verifyBundle` |
|
|
253
253
|
| `pki.inspect` | Human-readable inspection, the pure-JS equivalent of `openssl x509/crl/req/cms -text`. `certificate(pem \| der \| parsed)` renders an OpenSSL-style report: version, serial, signature algorithm, issuer and subject distinguished names, validity, public-key details (curve or modulus size plus the raw point or modulus), every decoded extension with its critical flag, and the signature. `crl`, `csr`, and `cms` render the other formats the same way — a CRL like `openssl crl -text`, a CSR like `openssl req -text`, and a CMS message like `openssl cms -cmsout -print`, with a stable summary for a non-SignedData ContentInfo — and `any(input)` detects the format and routes to the right report. Built over the strict parsers and the two-way OID registry with one set of field renderers, it names extension and algorithm OIDs an OpenSSL build shows only as raw bytes. No OpenSSL dependency, and the format is stable and OpenSSL-familiar rather than pinned to one OpenSSL version. A certificate policy's user notice renders as text, both its explicit text and a notice reference with the notice numbers that identify it, rather than hex, and a malformed part falls back to a hex dump rather than throwing — `certificate`, `crl`, `csr`, `cms`, `any` |
|
|
254
254
|
| `pki.webauthn` | WebAuthn and passkey verification, both halves: offline trust evaluation of a W3C WebAuthn (Level 3) registration, and signature verification of the assertion every login returns. `parseAttestationObject(bytes)` decodes the CBOR attestation object, authenticatorData, and COSE credential key over the strict `pki.cbor` codec; `parseAuthenticatorData(bytes)` reads the bare form an assertion carries through the same parser; `parseClientData(bytes, opts)` decodes the `clientDataJSON` no signature check looks inside, through the shared JSON guard since these are attacker-chosen bytes, returning the challenge decoded so a caller compares bytes rather than spellings, and checking the ceremony type, challenge, and origin when the relying party supplies what it issued. `verifyAssertion(input)` verifies an assertion signature over `authenticatorData \|\| SHA-256(clientDataJSON)` — raw bytes, no COSE_Sign1, an ES256 signature in ASN.1 DER — and applies the §7.2 step 21 counter rule when a stored `previousSignCount` is given, so a counter that fails to advance is refused as a cloned authenticator. `verify(attestationObject, clientDataHash, opts)` checks the attestation-statement signature and each format's structural bindings for packed, tpm, android-key, apple, fido-u2f, and none: the x5c leaf key, the apple nonce, the tpm `certInfo` Name and `extraData` over the `pubArea`, the android `KeyDescription`, and the fido-u2f `verificationData`. It binds the credential public key to each attestation, through the signed authenticatorData for packed and fido-u2f or a cert or `pubArea`-key equality check for android-key, apple, and tpm, and enforces each leaf's certificate requirements. The credential-key check covers the full WebAuthn COSE algorithm set — ES256/384/512, RS256/384/512, PS256/384/512, EdDSA (Ed25519), and the RFC 9864 fully-specified identifiers ESP256/384/512, Ed25519, and Ed448 — validating the public-key point on its curve, rejecting the compressed EC point form, and enforcing a minimally encoded DER ECDSA signature. The verdict field is `attestationVerified`, and `signatureVerified` for an assertion, rather than a bare `verified`, because a sound statement is a different claim from an acceptable ceremony: an attestation naming another origin's RP ID with user presence clear is perfectly sound and must not be registered. Pass `expectedRpId`, `requireUserPresence`, `requireUserVerification`, or `allowedAlgorithms` and those are checked, with `bindingChecked` reporting which ran, so a check that passed can be told from one that never happened. Pass `opts.clientDataJSON` instead of the digest and the client data is read here too: the ceremony type is checked unconditionally, since a login response replayed into a registration is what that rule stops, and the challenge, origin, and top-level origin are checked against what the relying party issued, with `clientData.checked` reporting which comparisons ran. A registration verdict also carries the `credentialId`, `credentialPublicKey`, and initial `signCount` a later login needs. A credential key declaring COSE algorithm `-65535` (RSASSA-PKCS1-v1_5 with SHA-1) is refused unless `allowedAlgorithms` names it, since every signature that credential ever makes would use SHA-1. Anchoring the trust path has two routes: `opts.metadata` resolves the roots the authenticator's own model registered, and `opts.rootCertificates` pins roots directly, which is what anchors the formats FIDO MDS does not cover, Apple's authenticators and the Google hardware-attestation roots among them. `metadata` governs when both are given, and `anchoredTo` names every route that anchored the path, joined with `+` when more than one did: `"metadata"`, `"rootCertificates"`, and `"safetyNetRoots"` for the android-safetynet chain, which anchors through the roots that format requires whether or not either other route was asked for. It is `null` only when nothing anchored the path. `verifyMetadataBlob(blob, opts)` reads a FIDO Metadata Service (MDS v3) BLOB, the signed catalogue of registered authenticator models, verifying its JWS and chaining its signer to an operator-supplied FIDO root before the payload is parsed, with sequence-number rollback and `nextUpdate` freshness checks. Passing the result as `opts.metadata` to `verify` resolves the authenticator's registered attestation roots from its identifier and requires the trust path to fully validate to one of them, refusing an unlisted or revoked model. `metadataAnchors(entry, opts)` applies the same status gate for a caller anchoring the path themselves: a model the catalogue has disqualified registers no anchors. Both of the catalogue's key spaces are covered: an aaguid, and the attestation-certificate key identifiers a U2F authenticator is listed under instead. No FIDO root is bundled, there is no trust-on-first-use, and retrieving the BLOB is out of scope. Fail-closed with typed `webauthn/*` errors — `parseAttestationObject`, `verify`, `verifyMetadataBlob`, `metadataFor`, `metadataAnchors` |
|
|
255
255
|
| `pki.lint` | Certificate linting, the zlint or pkilint of JavaScript. `certificate(pem \| der \| parsed, opts)` walks a parsed certificate and emits graded advisory findings, each with a stable id, a severity (`fatal`, `error`, `warn`, `notice`), a source, a spec-clause citation, and a message, against the RFC 5280 profile plus a representative CA/Browser Forum TLS BR subset: serial sign and size, validity ordering and the SC081v3 reducing validity schedule, keyCertSign coherence, extension criticality (basicConstraints, nameConstraints, policyConstraints and inhibitAnyPolicy must be critical, and keyUsage should be), nameConstraints CA-scope, unknown critical extensions, empty-subject SAN, SKI and AKI presence including the end-entity subjectKeyIdentifier, SAN required and CN-in-SAN, dNSName syntax, serverAuth EKU, weak keys, and the §4.2.1.4 certificate-policy user-notice rules (a VisibleString or BMPString explicitText, a notice past 200 characters, an empty notice, control characters, and a non-NFC UTF8String notice, each at the strength the clause states). Alone among these entries the data path never throws: hostile bytes return a `fatal` `lint/unparseable` finding carrying the strict parser's code, so a whole directory lints without a try/catch, and only config-time misuse throws a typed `LintError` — `certificate`, `rules`, `profiles` |
|
package/lib/sigstore.js
CHANGED
|
@@ -35,6 +35,7 @@ var pkix = require("./schema-pkix");
|
|
|
35
35
|
var pathValidate = require("./path-validate");
|
|
36
36
|
var merkle = require("./merkle");
|
|
37
37
|
var oid = require("./oid");
|
|
38
|
+
var ct = require("./ct");
|
|
38
39
|
var edwardsPoint = require("./edwards-point");
|
|
39
40
|
|
|
40
41
|
var C = constants;
|
|
@@ -387,6 +388,81 @@ function _pathToAnchor(leaf, anchor, intBySubject) {
|
|
|
387
388
|
return null;
|
|
388
389
|
}
|
|
389
390
|
|
|
391
|
+
var OID_SCT_LIST = oid.byName("signedCertificateTimestampList");
|
|
392
|
+
|
|
393
|
+
/** @internal The certificate-transparency logs a caller pins, in the shape the Rekor keys take: an
|
|
394
|
+
* operator builds both from the one trusted-root document. An empty array is refused rather than read
|
|
395
|
+
* as "no logs to check against", which would turn an opted-in check into a silent pass. */
|
|
396
|
+
function _normCtLogs(ctLogs) {
|
|
397
|
+
if (!Array.isArray(ctLogs)) throw _err("sigstore/bad-input", "ctLogs must be an array of { keyId, spki, validFor? }");
|
|
398
|
+
if (ctLogs.length === 0) throw _err("sigstore/bad-input", "ctLogs is empty; omit the option to skip the certificate-transparency check rather than supplying no logs");
|
|
399
|
+
return ctLogs.map(function (l, i) {
|
|
400
|
+
if (l === null || typeof l !== "object") throw _err("sigstore/bad-input", "ctLogs[" + i + "] must be { keyId, spki, validFor? }");
|
|
401
|
+
if (!Buffer.isBuffer(l.keyId)) throw _err("sigstore/bad-input", "ctLogs[" + i + "].keyId must be the log id as a Buffer");
|
|
402
|
+
if (!Buffer.isBuffer(l.spki)) throw _err("sigstore/bad-input", "ctLogs[" + i + "].spki must be the log's SubjectPublicKeyInfo DER");
|
|
403
|
+
return { keyId: l.keyId, spki: l.spki, validFor: l.validFor || null };
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** @internal RFC 6962 sec. 3.2: Fulcio logs the certificate as it issues it and embeds the log's
|
|
408
|
+
* receipt, so the receipt covers the certificate WITHOUT that extension, under the issuer's key hash.
|
|
409
|
+
* `pki.ct.x509CertEntry` reconstructs exactly that entry from the final certificate, and each receipt
|
|
410
|
+
* is checked against the log the caller pinned for it. At least one must verify, which is the sec. 3.3
|
|
411
|
+
* floor; a receipt from a log the caller did not pin counts for nothing. */
|
|
412
|
+
async function _verifyEmbeddedScts(leaf, leafDer, issuer, ctLogs, timeMs, atMs) {
|
|
413
|
+
if (ctLogs === undefined || ctLogs === null) return { checked: false, validScts: 0 };
|
|
414
|
+
var logs = _normCtLogs(ctLogs);
|
|
415
|
+
var ext = null;
|
|
416
|
+
var exts = leaf.extensions || [];
|
|
417
|
+
for (var i = 0; i < exts.length; i++) { if (exts[i].oid === OID_SCT_LIST) { ext = exts[i]; break; } }
|
|
418
|
+
if (!ext) {
|
|
419
|
+
throw _err("sigstore/sct-missing", "ctLogs was supplied but the Fulcio certificate carries no signedCertificateTimestampList extension (RFC 6962 sec. 3.3)");
|
|
420
|
+
}
|
|
421
|
+
var entry, list;
|
|
422
|
+
try {
|
|
423
|
+
entry = ct.x509CertEntry(leafDer, issuer);
|
|
424
|
+
list = ct.parseSctList(ext.value);
|
|
425
|
+
} catch (e) { throw _err("sigstore/sct-unverified", "the embedded certificate-transparency receipt could not be read: " + e.message, e); }
|
|
426
|
+
var valid = 0;
|
|
427
|
+
for (var s = 0; s < list.scts.length; s++) {
|
|
428
|
+
var sct = list.scts[s];
|
|
429
|
+
/** @internal A log key's window says when that key was the log's, so the receipt is held to the
|
|
430
|
+
* window as it stood when the receipt was signed, not when the artifact was later logged. */
|
|
431
|
+
var log = _ctLogFor(logs, sct.logId, _sctMs(sct));
|
|
432
|
+
if (!log) continue;
|
|
433
|
+
/** @internal RFC 6962 sec. 5.2: a client rejects a receipt dated after the instant it is checking
|
|
434
|
+
* at, which a log cannot have issued yet. The reference is the caller's own `opts.time` and never
|
|
435
|
+
* the Rekor entry time, which records whole seconds while a receipt carries milliseconds, so a
|
|
436
|
+
* receipt issued in the same second as the entry would read as dated after it. The bound is the end
|
|
437
|
+
* of that second instead, so the granularity is allowed for and nothing later is. The timestamp is a
|
|
438
|
+
* BigInt and a relational comparison against a Number is exact for both. */
|
|
439
|
+
if (sct.timestamp != null && sct.timestamp > atMs) continue;
|
|
440
|
+
if (await _sctVerifies(entry, sct, log.spki)) valid += 1;
|
|
441
|
+
}
|
|
442
|
+
if (valid < 1) {
|
|
443
|
+
throw _err("sigstore/sct-unverified", "no embedded certificate-transparency receipt verified against a pinned log (RFC 6962 sec. 3.3)");
|
|
444
|
+
}
|
|
445
|
+
return { checked: true, validScts: valid };
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** @internal A receipt the verifier refuses structurally counted as verified would be the whole leg
|
|
449
|
+
* lost, so a fault is an unverified receipt and the next one is still tried. */
|
|
450
|
+
function _sctVerifies(entry, sct, spki) {
|
|
451
|
+
return ct.verifySct(entry, sct, spki).then(function (ok) { return ok === true; }, function () { return false; });
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** @internal A receipt's own instant, in milliseconds. The parser's `timestampMs` is this same value
|
|
455
|
+
* wherever it is representable, and above 2^53 there is no reachable instant either way. */
|
|
456
|
+
function _sctMs(sct) { return Number(sct.timestamp || 0); }
|
|
457
|
+
|
|
458
|
+
function _ctLogFor(logs, logIdBytes, timeMs) {
|
|
459
|
+
var want = Buffer.isBuffer(logIdBytes) ? logIdBytes : Buffer.from(logIdBytes || []);
|
|
460
|
+
for (var i = 0; i < logs.length; i++) {
|
|
461
|
+
if (logs[i].keyId.equals(want) && _inWindow(timeMs, logs[i].validFor)) return logs[i];
|
|
462
|
+
}
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
|
|
390
466
|
async function _verifyChain(leaf, chainDers, fulcioRoots, timeMs) {
|
|
391
467
|
var roots = _normRoots(fulcioRoots);
|
|
392
468
|
var bundleLinks = chainDers.slice(1).map(function (d, i) { return _parseCert(d, "bundle intermediate [" + i + "]"); });
|
|
@@ -408,7 +484,11 @@ async function _verifyChain(leaf, chainDers, fulcioRoots, timeMs) {
|
|
|
408
484
|
trustAnchors: { name: anchor.subject, publicKey: spki.bytes, algorithm: spki.algorithm.oid, parameters: spki.algorithm.parameters },
|
|
409
485
|
requiredEku: ["codeSigning"],
|
|
410
486
|
});
|
|
411
|
-
|
|
487
|
+
/** @internal The path is anchor-proximal first and leaf last, so the certificate directly above
|
|
488
|
+
* the leaf issued it, and the anchor did when the leaf sits alone. Returning it here is what lets
|
|
489
|
+
* the certificate-transparency leg reconstruct the logged entry without resolving the issuer a
|
|
490
|
+
* second time, from a chain this leg has already validated. */
|
|
491
|
+
if (res.valid) return { issuer: path.length > 1 ? path[path.length - 2] : anchor };
|
|
412
492
|
lastErr = _err("sigstore/chain-invalid", "the Fulcio certificate chain is not valid as of the log time");
|
|
413
493
|
} catch (e) {
|
|
414
494
|
lastErr = _err("sigstore/chain-invalid", "the Fulcio certificate chain failed validation: " + e.message, e);
|
|
@@ -468,7 +548,7 @@ function _fulcioExtValue(ext, leafArc) {
|
|
|
468
548
|
|
|
469
549
|
var IDENTITY_FIELDS = ["san", "issuer", "sourceRepositoryURI"];
|
|
470
550
|
var IDENTITY_KEYS = Object.assign(Object.create(null), { san: 1, issuer: 1, sourceRepositoryURI: 1 });
|
|
471
|
-
var _VERIFY_BUNDLE_OPTS = Object.assign(Object.create(null), { fulcioRoots: 1, rekorKeys: 1, identity: 1, predicateType: 1, time: 1 });
|
|
551
|
+
var _VERIFY_BUNDLE_OPTS = Object.assign(Object.create(null), { fulcioRoots: 1, rekorKeys: 1, ctLogs: 1, identity: 1, predicateType: 1, time: 1 });
|
|
472
552
|
|
|
473
553
|
function _checkIdentity(id, policy) {
|
|
474
554
|
// allow:registry-table-inherits-object-prototype -- the identityChecked record an operator reads by field name, whose three keys are the fixed IDENTITY_FIELDS rather than anything the bundle supplies
|
|
@@ -525,13 +605,31 @@ function _statement(payload, payloadType, expectedPredicate) {
|
|
|
525
605
|
* the log entry bound to this exact signature; and the in-toto SLSA statement.
|
|
526
606
|
* Any leg failing throws a typed `sigstore/*` error. On success returns
|
|
527
607
|
* `{ valid: true, verified: true, payload, statement, subjects, predicateType, predicate,
|
|
528
|
-
* identity, identityChecked, predicateTypeChecked, integratedTime, logIndex, logId }` (`valid` is the
|
|
608
|
+
* identity, identityChecked, predicateTypeChecked, sctChecked, validScts, integratedTime, logIndex, logId }` (`valid` is the
|
|
529
609
|
* canonical toolkit-wide verdict alias of `verified`, `predicateTypeChecked` says whether a pinned
|
|
530
610
|
* `opts.predicateType` was checked, and `logIndex` / `logId` identify the attested Rekor log entry).
|
|
531
611
|
* `payload` is the raw verified
|
|
532
612
|
* envelope bytes (never a re-serialization), and the caller confirms a
|
|
533
613
|
* `subjects[].digest` matches the published artifact.
|
|
534
614
|
*
|
|
615
|
+
* Fulcio logs every certificate it issues to a certificate-transparency log and
|
|
616
|
+
* embeds the log's receipt in the certificate (RFC 6962 sec. 3.2). Supplying
|
|
617
|
+
* `opts.ctLogs` checks it: the receipt is verified over the certificate as it
|
|
618
|
+
* stood before the receipt was added, under the key of the log that issued it,
|
|
619
|
+
* and at least one receipt must verify against a pinned log (sec. 3.3). It is
|
|
620
|
+
* what says the signing certificate was public when it was issued rather than
|
|
621
|
+
* handed out quietly. The option is opt-in, so a caller that pins no log is
|
|
622
|
+
* unaffected and `sctChecked` reports `false`; supplying an empty array is
|
|
623
|
+
* refused rather than read as a policy that checks nothing. `validScts` counts
|
|
624
|
+
* the receipts that verified.
|
|
625
|
+
*
|
|
626
|
+
* A log's `validFor` window is read at the instant the receipt was signed, since
|
|
627
|
+
* that is when the key was the log's, not at the time the artifact was later
|
|
628
|
+
* logged. A receipt dated after the instant being validated at is not counted
|
|
629
|
+
* (RFC 6962 sec. 5.2); with no `opts.time` that instant is the end of the Rekor
|
|
630
|
+
* entry's own second, which allows for the entry recording whole seconds while a
|
|
631
|
+
* receipt carries milliseconds, and accepts nothing beyond it.
|
|
632
|
+
*
|
|
535
633
|
* `verified: true` says the artifact was signed and logged; it says nothing about
|
|
536
634
|
* who. Fulcio issues a certificate to anyone who completes an OIDC flow, so who
|
|
537
635
|
* signed is decided only by `opts.identity`, and `identityChecked` reports which of
|
|
@@ -543,6 +641,7 @@ function _statement(payload, payloadType, expectedPredicate) {
|
|
|
543
641
|
* @opts
|
|
544
642
|
* fulcioRoots: Array, // the Fulcio CA anchors: a DER Buffer or { der, validFor } each
|
|
545
643
|
* rekorKeys: Array, // [{ keyId, spki, validFor? }] the Rekor log public keys
|
|
644
|
+
* ctLogs: Array, // optional [{ keyId, spki, validFor? }] certificate-transparency logs; when given, the certificate's embedded receipt is checked
|
|
546
645
|
* identity: object, // optional policy: { san, issuer, sourceRepositoryURI }; at least one required when present
|
|
547
646
|
* predicateType: string, // optional: require this in-toto predicateType (e.g. the SLSA URI)
|
|
548
647
|
* time: Date, // optional check-date override (default: the Rekor integratedTime)
|
|
@@ -586,7 +685,12 @@ async function verifyBundle(bundle, opts) {
|
|
|
586
685
|
var integratedTime = rekor.integratedTime;
|
|
587
686
|
|
|
588
687
|
var checkTime = guard.time.isDate(opts.time) ? guard.time.instantOf(opts.time) : C.TIME.seconds(integratedTime);
|
|
589
|
-
await _verifyChain(leaf, _chainDers(vm), fulcioRoots, checkTime);
|
|
688
|
+
var chain = await _verifyChain(leaf, _chainDers(vm), fulcioRoots, checkTime);
|
|
689
|
+
/** @internal With no caller instant the reference is the authenticated log-entry time, whose whole
|
|
690
|
+
* second is inclusive: a certificate logged in the same second as its entry is not dated after it,
|
|
691
|
+
* and nothing beyond that second is accepted. */
|
|
692
|
+
var sctBound = guard.time.isDate(opts.time) ? checkTime : C.TIME.seconds(integratedTime) + 999;
|
|
693
|
+
var sctResult = await _verifyEmbeddedScts(leaf, leafDer, chain.issuer, opts.ctLogs, checkTime, sctBound);
|
|
590
694
|
var identity = _identity(leaf);
|
|
591
695
|
var identityChecked = _checkIdentity(identity, opts.identity);
|
|
592
696
|
|
|
@@ -603,6 +707,8 @@ async function verifyBundle(bundle, opts) {
|
|
|
603
707
|
identity: identity,
|
|
604
708
|
identityChecked: identityChecked,
|
|
605
709
|
predicateTypeChecked: opts.predicateType != null,
|
|
710
|
+
sctChecked: sctResult.checked,
|
|
711
|
+
validScts: sctResult.validScts,
|
|
606
712
|
integratedTime: integratedTime,
|
|
607
713
|
logIndex: rekor.logIndex,
|
|
608
714
|
logId: rekor.logId,
|
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:664841c0-3588-4832-8e40-6288506a791f",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-09-
|
|
8
|
+
"timestamp": "2026-09-06T10:18:22.726Z",
|
|
9
9
|
"lifecycles": [
|
|
10
10
|
{
|
|
11
11
|
"phase": "build"
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"component": {
|
|
22
|
-
"bom-ref": "@blamejs/pki@0.6.
|
|
22
|
+
"bom-ref": "@blamejs/pki@0.6.46",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.6.
|
|
25
|
+
"version": "0.6.46",
|
|
26
26
|
"scope": "required",
|
|
27
27
|
"author": "blamejs contributors",
|
|
28
28
|
"description": "Pure-JavaScript PKI toolkit that owns its stack — X.509, ASN.1/DER, CMS, PQC-first.",
|
|
29
|
-
"purl": "pkg:npm/%40blamejs/pki@0.6.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/pki@0.6.46",
|
|
30
30
|
"properties": [],
|
|
31
31
|
"externalReferences": [
|
|
32
32
|
{
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"components": [],
|
|
55
55
|
"dependencies": [
|
|
56
56
|
{
|
|
57
|
-
"ref": "@blamejs/pki@0.6.
|
|
57
|
+
"ref": "@blamejs/pki@0.6.46",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|