@blamejs/core 0.14.6 → 0.14.7
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 +2 -0
- package/README.md +3 -2
- package/lib/agent-event-bus.js +4 -4
- package/lib/agent-idempotency.js +6 -6
- package/lib/agent-orchestrator.js +9 -9
- package/lib/agent-posture-chain.js +10 -10
- package/lib/agent-saga.js +6 -7
- package/lib/agent-snapshot.js +8 -8
- package/lib/agent-stream.js +3 -3
- package/lib/agent-tenant.js +4 -4
- package/lib/agent-trace.js +5 -5
- package/lib/ai-disclosure.js +3 -3
- package/lib/app.js +2 -2
- package/lib/archive-read.js +1 -1
- package/lib/archive-tar-read.js +1 -1
- package/lib/archive-wrap.js +5 -5
- package/lib/audit-tools.js +65 -5
- package/lib/audit.js +2 -2
- package/lib/auth/ciba.js +1 -1
- package/lib/auth/dpop.js +1 -1
- package/lib/auth/fal.js +1 -1
- package/lib/auth/fido-mds3.js +2 -3
- package/lib/auth/jwt-external.js +2 -2
- package/lib/auth/oauth.js +9 -9
- package/lib/auth/oid4vci.js +7 -7
- package/lib/auth/oid4vp.js +1 -1
- package/lib/auth/openid-federation.js +5 -5
- package/lib/auth/passkey.js +6 -6
- package/lib/auth/saml.js +1 -1
- package/lib/auth/sd-jwt-vc.js +3 -6
- package/lib/backup/index.js +18 -18
- package/lib/cache.js +4 -4
- package/lib/calendar.js +5 -5
- package/lib/circuit-breaker.js +1 -1
- package/lib/cms-codec.js +2 -2
- package/lib/compliance.js +14 -14
- package/lib/crypto-field.js +58 -21
- package/lib/crypto.js +5 -6
- package/lib/db-query.js +131 -9
- package/lib/db.js +106 -22
- package/lib/external-db.js +64 -16
- package/lib/framework-schema.js +4 -4
- package/lib/guard-list-id.js +2 -2
- package/lib/guard-list-unsubscribe.js +1 -2
- package/lib/incident-report.js +150 -0
- package/lib/mail-crypto-smime.js +1 -1
- package/lib/mail-deploy.js +3 -3
- package/lib/mail-server-managesieve.js +2 -2
- package/lib/mail-server-pop3.js +2 -2
- package/lib/mail-store.js +1 -1
- package/lib/metrics.js +8 -8
- package/lib/middleware/csrf-protect.js +1 -1
- package/lib/middleware/dpop.js +5 -5
- package/lib/middleware/idempotency-key.js +21 -22
- package/lib/middleware/protected-resource-metadata.js +2 -2
- package/lib/network-dns-resolver.js +2 -2
- package/lib/network-dns.js +1 -2
- package/lib/network-tls.js +0 -1
- package/lib/outbox.js +1 -1
- package/lib/pqc-agent.js +1 -1
- package/lib/retention.js +1 -1
- package/lib/retry.js +1 -1
- package/lib/safe-archive.js +2 -2
- package/lib/safe-ical.js +2 -2
- package/lib/safe-mime.js +1 -1
- package/lib/self-update-standalone-verifier.js +1 -1
- package/lib/self-update.js +2 -2
- package/lib/static.js +1 -1
- package/lib/subject.js +2 -2
- package/lib/vault/index.js +64 -1
- package/lib/vault/rotate.js +19 -0
- package/lib/vendor-data.js +1 -1
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
|
@@ -175,7 +175,7 @@ function memoryStore(opts) {
|
|
|
175
175
|
* headers. Requires `b.vault.init(...)` to have run; falls back to
|
|
176
176
|
* plain-text with a one-shot audit warning when vault isn't ready,
|
|
177
177
|
* so test-fixture / boot-script callers still work.
|
|
178
|
-
* - `aad: true` (since 0.9.58
|
|
178
|
+
* - `aad: true` (since 0.9.58) — sealed columns are bound
|
|
179
179
|
* via Additional Authenticated Data to (table, k, column,
|
|
180
180
|
* schemaVersion) so a DB-write attacker can't copy a sealed
|
|
181
181
|
* header/body cell from one row to another (which previously
|
|
@@ -184,12 +184,12 @@ function memoryStore(opts) {
|
|
|
184
184
|
* detects the envelope shape; lazy re-seal on next `set()` upgrades
|
|
185
185
|
* each row to AAD form. Operators wanting a one-shot migration
|
|
186
186
|
* call `b.middleware.idempotencyKey.resealMigrate(store)`.
|
|
187
|
-
* - `fingerprintSeal: true` (since 0.9.58
|
|
187
|
+
* - `fingerprintSeal: true` (since 0.9.58) — the request
|
|
188
188
|
* `fingerprint` column carries an HMAC under a vault-derived
|
|
189
189
|
* secret instead of a bare SHA3-256 of method+path+body. The
|
|
190
190
|
* compare path is constant-time so the column doubles as a
|
|
191
191
|
* mismatch oracle without offline-brute-force exposure.
|
|
192
|
-
* - `bodyFingerprintFallback: "deny"` (since 0.9.58
|
|
192
|
+
* - `bodyFingerprintFallback: "deny"` (since 0.9.58) —
|
|
193
193
|
* when neither `bodyFingerprint` nor `req._rawBody`/`req.body` is
|
|
194
194
|
* populated for a body-bearing method, the middleware previously
|
|
195
195
|
* silently degraded the fingerprint to method+path. Set to
|
|
@@ -228,8 +228,8 @@ function memoryStore(opts) {
|
|
|
228
228
|
* init?: boolean, // default true — run CREATE TABLE IF NOT EXISTS at construction
|
|
229
229
|
* hashKeys?: boolean, // default true — store sha3-512 namespace-hash of the key, not the raw key
|
|
230
230
|
* seal?: boolean, // default true — seal headers + body via b.cryptoField when vault is ready
|
|
231
|
-
* aad?: boolean, // default true — AAD-bind seal to (table,k,column) so a DB-write attacker can't cross-row swap
|
|
232
|
-
* fingerprintSeal?: boolean, // default true — HMAC fingerprint under a vault-derived secret instead of bare sha3-256
|
|
231
|
+
* aad?: boolean, // default true — AAD-bind seal to (table,k,column) so a DB-write attacker can't cross-row swap
|
|
232
|
+
* fingerprintSeal?: boolean, // default true — HMAC fingerprint under a vault-derived secret instead of bare sha3-256
|
|
233
233
|
*
|
|
234
234
|
* @example
|
|
235
235
|
* // single-process daemon, framework's internal sqlite, both defaults on:
|
|
@@ -264,11 +264,11 @@ function dbStore(opts) {
|
|
|
264
264
|
var doInit = opts.init !== false;
|
|
265
265
|
var hashKeys = opts.hashKeys !== false;
|
|
266
266
|
var sealReq = opts.seal !== false;
|
|
267
|
-
//
|
|
267
|
+
// AAD-bind sealing to (table, k, column) by default.
|
|
268
268
|
// Forms a defense-in-depth pair with seal: cross-row swap fails
|
|
269
269
|
// Poly1305 even when the attacker controls the DB layer.
|
|
270
270
|
var aadOn = opts.aad !== false;
|
|
271
|
-
//
|
|
271
|
+
// HMAC the fingerprint under a vault-derived secret by
|
|
272
272
|
// default. Bare SHA3-256 of method+path+body is offline-brute-
|
|
273
273
|
// forceable for any DB-dump attacker; HMAC under a vault secret
|
|
274
274
|
// forces them to break the vault first.
|
|
@@ -297,7 +297,7 @@ function dbStore(opts) {
|
|
|
297
297
|
|
|
298
298
|
// Register the table with cryptoField. registerTable is idempotent
|
|
299
299
|
// — subsequent dbStore() calls with the same tableName re-declare
|
|
300
|
-
// the same sealedFields and no-op.
|
|
300
|
+
// the same sealedFields and no-op. When aad is on,
|
|
301
301
|
// (table, k, column) is threaded into the AEAD AAD so a DB-write
|
|
302
302
|
// attacker can't copy a sealed value between rows.
|
|
303
303
|
if (sealEnabled) {
|
|
@@ -309,7 +309,7 @@ function dbStore(opts) {
|
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
//
|
|
312
|
+
// Derive a per-vault HMAC secret for fingerprint sealing.
|
|
313
313
|
// The vault root key is the trust root; without it the secret is
|
|
314
314
|
// unrecoverable. Lazy: only derived when fpSealOn is enabled AND the
|
|
315
315
|
// vault is ready, so test fixtures that haven't initialized the
|
|
@@ -349,7 +349,7 @@ function dbStore(opts) {
|
|
|
349
349
|
// so audit/forensic SELECTs don't have to unseal-everything. The
|
|
350
350
|
// `k` column is selected even when not strictly needed for read
|
|
351
351
|
// because cryptoField.unsealRow uses it as the rowId in AAD when
|
|
352
|
-
// the table is AAD-bound
|
|
352
|
+
// the table is AAD-bound.
|
|
353
353
|
var stmtGet = db.prepare(
|
|
354
354
|
"SELECT k, fingerprint, status_code, headers, body, expires_at FROM " +
|
|
355
355
|
qTable + " WHERE k = ?");
|
|
@@ -372,7 +372,7 @@ function dbStore(opts) {
|
|
|
372
372
|
return bCrypto.namespaceHash("idempotency-key", rawKey);
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
//
|
|
375
|
+
// Emit / compare HMAC-shape fingerprints. The store
|
|
376
376
|
// round-trips the column as plain text (no transformation per-get);
|
|
377
377
|
// sealing happens at MINT time (when the middleware builds the
|
|
378
378
|
// fingerprint and hands it to set()). The store's responsibility is
|
|
@@ -391,7 +391,7 @@ function dbStore(opts) {
|
|
|
391
391
|
if (sealEnabled) {
|
|
392
392
|
try { liveRow = cryptoField.unsealRow(tableNameRaw, row); }
|
|
393
393
|
catch (_unsealErr) {
|
|
394
|
-
//
|
|
394
|
+
// Decryption failure used to delete the row,
|
|
395
395
|
// which let an attacker probe key presence via a "tamper +
|
|
396
396
|
// observe subsequent SELECT" oracle. The fix: emit audit,
|
|
397
397
|
// return null, do NOT delete. TTL sweeps stale rows out
|
|
@@ -407,7 +407,7 @@ function dbStore(opts) {
|
|
|
407
407
|
}
|
|
408
408
|
var headersObj;
|
|
409
409
|
try {
|
|
410
|
-
//
|
|
410
|
+
// Route through C.BYTES.mib(4); raw `4 * 1024 * 1024`
|
|
411
411
|
// was a drift smell flagged by codebase-patterns. 4 MiB ceiling
|
|
412
412
|
// unchanged.
|
|
413
413
|
headersObj = safeJson.parse(liveRow.headers, { maxBytes: C.BYTES.mib(4) });
|
|
@@ -421,7 +421,6 @@ function dbStore(opts) {
|
|
|
421
421
|
// DELETING it would clobber another process's cache and
|
|
422
422
|
// turn a hit into a miss with potential side-effect re-
|
|
423
423
|
// execution. Treat as miss + LEAVE the row in place.
|
|
424
|
-
// Per Codex P1 on PR #45.
|
|
425
424
|
var lookedSealed = typeof liveRow.headers === "string" &&
|
|
426
425
|
(liveRow.headers.indexOf("vault:") === 0 ||
|
|
427
426
|
liveRow.headers.indexOf("vault.aad:") === 0);
|
|
@@ -456,7 +455,7 @@ function dbStore(opts) {
|
|
|
456
455
|
delete: function (rawKey) {
|
|
457
456
|
stmtDelete.run(_k(rawKey));
|
|
458
457
|
},
|
|
459
|
-
//
|
|
458
|
+
// The middleware consults this hook to HMAC the
|
|
460
459
|
// method+path+body digest under a vault-derived secret before
|
|
461
460
|
// insert + compare. Returns null when fpSeal is disabled OR the
|
|
462
461
|
// vault wasn't ready at construction; the middleware then falls
|
|
@@ -466,7 +465,7 @@ function dbStore(opts) {
|
|
|
466
465
|
return nodeCrypto.createHmac("sha3-256", fpHmacSecret)
|
|
467
466
|
.update(preimageBytes).digest("hex");
|
|
468
467
|
},
|
|
469
|
-
//
|
|
468
|
+
// Operator helper: walk the table and reseal every row
|
|
470
469
|
// under the AAD form. Existing v0.9.15-v0.9.57 rows continue to
|
|
471
470
|
// read on a per-row basis (unsealRow auto-detects shape), but
|
|
472
471
|
// operators wanting an explicit migration step call this once.
|
|
@@ -526,7 +525,7 @@ function _fingerprintRequest(req, bodyBytes, store) {
|
|
|
526
525
|
// Fingerprint preimage = method + path + body. Per the draft §4.3,
|
|
527
526
|
// a key+body mismatch is a client-side mistake; our preimage covers
|
|
528
527
|
// method + path so a client reusing a key across different
|
|
529
|
-
// endpoints is also caught.
|
|
528
|
+
// endpoints is also caught. When the store exposes a
|
|
530
529
|
// `fingerprintHmac` hook (dbStore with fingerprintSeal:true + vault
|
|
531
530
|
// ready), the preimage is HMAC'd under a vault-derived secret so a
|
|
532
531
|
// DB dump leaks neither the preimage nor a brute-forceable digest.
|
|
@@ -602,7 +601,7 @@ function _emitAudit(action, metadata, outcome) {
|
|
|
602
601
|
* requireIdempotencyKey: boolean, // default: false — refuse missing-key
|
|
603
602
|
* bodyFingerprint: function, // (req) => Buffer|string|object|null — operator-supplied body extractor
|
|
604
603
|
* maxBodyBytes: number, // default: 1 MiB — replay-cache body cap
|
|
605
|
-
* bodyFingerprintFallback: string, // default "deny"
|
|
604
|
+
* bodyFingerprintFallback: string, // default "deny" — when neither
|
|
606
605
|
* // bodyFingerprint nor req._rawBody / req.body is
|
|
607
606
|
* // available for POST/PUT/PATCH, refuse with HTTP 400
|
|
608
607
|
* // idempotency/missing-body-fingerprint instead of
|
|
@@ -669,7 +668,7 @@ function create(opts) {
|
|
|
669
668
|
opts.bodyFingerprint, "idempotencyKey.bodyFingerprint",
|
|
670
669
|
IdempotencyError, "idempotency/bad-body-fingerprint"
|
|
671
670
|
) || null;
|
|
672
|
-
//
|
|
671
|
+
// Default "deny" refuses body-bearing requests that
|
|
673
672
|
// arrive with neither req._rawBody / req.body NOR an operator-
|
|
674
673
|
// supplied bodyFingerprint hook. The silent-degrade-to-method+path
|
|
675
674
|
// path was a §4.3 violation (same key + different body returned
|
|
@@ -762,7 +761,7 @@ function create(opts) {
|
|
|
762
761
|
// Misordered-mount detector — body-bearing method reached us
|
|
763
762
|
// with neither a parsed body nor a raw-body buffer. Most likely
|
|
764
763
|
// body-parser hasn't run yet, which used to silently degrade the
|
|
765
|
-
// fingerprint to method+path;
|
|
764
|
+
// fingerprint to method+path; v0.9.58 makes that
|
|
766
765
|
// case refuse with HTTP 400 by default. The audit emit fires in
|
|
767
766
|
// both fallback modes so operator review surfaces the
|
|
768
767
|
// misconfiguration regardless of the chosen fallback.
|
|
@@ -929,8 +928,8 @@ function _redactKey(key) {
|
|
|
929
928
|
* @related b.middleware.idempotencyKey.dbStore
|
|
930
929
|
*
|
|
931
930
|
* One-shot operator helper that walks a dbStore's table and reseals
|
|
932
|
-
* every row under the AAD-bound envelope shape introduced in v0.9.58
|
|
933
|
-
*
|
|
931
|
+
* every row under the AAD-bound envelope shape introduced in v0.9.58.
|
|
932
|
+
* Existing v0.9.15-v0.9.57 rows continue to read on a
|
|
934
933
|
* per-row basis (unsealRow auto-detects shape) so a deploy without
|
|
935
934
|
* this call is correct, but operators who want to upgrade in bulk
|
|
936
935
|
* call this once after upgrading.
|
|
@@ -94,7 +94,7 @@ function create(opts) {
|
|
|
94
94
|
"middleware/protected-resource-metadata/no-as",
|
|
95
95
|
"authorizationServers must be a non-empty array of issuer URLs");
|
|
96
96
|
}
|
|
97
|
-
//
|
|
97
|
+
// RFC 9728 §3 + RFC 8414 §3.1: authorizationServers entries
|
|
98
98
|
// are issuer URLs and MUST be https://. Pre-v0.9.x only required
|
|
99
99
|
// non-empty string, so an operator typo could ship `http://idp.test`
|
|
100
100
|
// (or, worse, `javascript:` / `data:`) to clients via the well-known
|
|
@@ -156,7 +156,7 @@ function create(opts) {
|
|
|
156
156
|
if (opts.dpopBoundAccessTokensRequired === true) doc.dpop_bound_access_tokens_required = true;
|
|
157
157
|
if (opts.mtlsBoundAccessTokensRequired === true) doc.tls_client_certificate_bound_access_tokens = true;
|
|
158
158
|
|
|
159
|
-
//
|
|
159
|
+
// RFC 9728 §3.2 signed_metadata. Operators with an
|
|
160
160
|
// anti-tamper requirement pass `signMetadata: { key, alg, kid }`;
|
|
161
161
|
// the middleware emits `application/jwt` carrying the JWS-signed
|
|
162
162
|
// metadata. Default output remains cleartext `application/json`.
|
|
@@ -126,7 +126,7 @@ var DEFAULT_MAX_TTL_MS = C.TIME.hours(24);
|
|
|
126
126
|
var DEFAULT_MIN_TTL_MS = C.TIME.seconds(60);
|
|
127
127
|
var DEFAULT_STALE_WINDOW = C.TIME.hours(6);
|
|
128
128
|
var DEFAULT_PROFILE = "strict";
|
|
129
|
-
//
|
|
129
|
+
// CWE-400/770. Bound the cache so a hostile peer
|
|
130
130
|
// that can drive query-name selection (e.g. inbound SMTP forwarding
|
|
131
131
|
// DKIM `s=` / `d=` tag-controlled lookups) cannot inflate the Map to
|
|
132
132
|
// OOM. Default 5000 entries: a parsed-response object ~100 bytes ×
|
|
@@ -216,7 +216,7 @@ function create(opts) {
|
|
|
216
216
|
|
|
217
217
|
var cache = new Map(); // key → { response, parsed, ttl, expiresAt, staleUntil }
|
|
218
218
|
|
|
219
|
-
// CWE-400/770
|
|
219
|
+
// CWE-400/770. LRU eviction on insert when the cache is at
|
|
220
220
|
// capacity. v8 Map preserves insertion order; oldest key is the
|
|
221
221
|
// first entry returned by Map.keys().next().
|
|
222
222
|
function _evictIfFull() {
|
package/lib/network-dns.js
CHANGED
|
@@ -39,8 +39,7 @@ var STATE = {
|
|
|
39
39
|
// Default-on secure DNS (DoH via Cloudflare) when neither doh nor dot
|
|
40
40
|
// is operator-configured AND no opt-out env var is set. Operators
|
|
41
41
|
// who explicitly want the system resolver call useSystemResolver()
|
|
42
|
-
// or set BLAMEJS_DNS_TRANSPORT=system. Default-on
|
|
43
|
-
// ("security defaults are not opt-in").
|
|
42
|
+
// or set BLAMEJS_DNS_TRANSPORT=system. Default-on (security defaults are not opt-in).
|
|
44
43
|
systemResolver: false,
|
|
45
44
|
};
|
|
46
45
|
|
package/lib/network-tls.js
CHANGED
|
@@ -1136,7 +1136,6 @@ function evaluateOcspResponse(ocspDer, opts) {
|
|
|
1136
1136
|
// length inputs but fast-paths on length mismatch; not security-
|
|
1137
1137
|
// critical here (the OCSP response is CA-signed and signature
|
|
1138
1138
|
// already verified) but matches the project discipline.
|
|
1139
|
-
// (Audit 2026-05-11.)
|
|
1140
1139
|
if (!bCrypto.timingSafeEqual(parsed.basic.nonce, opts.expectedNonce)) {
|
|
1141
1140
|
return { ok: false, status: parsed.status, signatureValid: true,
|
|
1142
1141
|
errors: ["OCSP nonce mismatch — possible replay or wrong responder"] };
|
package/lib/outbox.js
CHANGED
|
@@ -342,7 +342,7 @@ function create(opts) {
|
|
|
342
342
|
var stopping = false;
|
|
343
343
|
var inFlight = null;
|
|
344
344
|
|
|
345
|
-
//
|
|
345
|
+
// `FOR UPDATE SKIP LOCKED` is Postgres / MySQL 8+ only.
|
|
346
346
|
// SQLite (single-writer at the DB level, but WAL mode lets multiple
|
|
347
347
|
// processes share the file with concurrent SELECTs) doesn't support
|
|
348
348
|
// SKIP LOCKED — feeding it Postgres syntax silently double-publishes
|
package/lib/pqc-agent.js
CHANGED
|
@@ -322,7 +322,7 @@ function _getDefaultAgent() {
|
|
|
322
322
|
* logger.info("pqc-agent reloaded", res);
|
|
323
323
|
*/
|
|
324
324
|
function reload() {
|
|
325
|
-
//
|
|
325
|
+
// Null the cached agent BEFORE calling destroy. The
|
|
326
326
|
// previous order let a concurrent _getDefaultAgent() see the
|
|
327
327
|
// destroyed-not-null agent and hand it to a caller; the caller
|
|
328
328
|
// then tries to issue a request through a torn-down keep-alive
|
package/lib/retention.js
CHANGED
|
@@ -569,7 +569,7 @@ function complianceFloor(posture, candidateTtlMs) {
|
|
|
569
569
|
return candidateTtlMs > floor ? candidateTtlMs : floor;
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
-
// applyPosture —
|
|
572
|
+
// applyPosture — cascade hook. b.compliance.set(posture)
|
|
573
573
|
// calls this to merge posture defaults into retention's state. The
|
|
574
574
|
// retention module itself doesn't carry per-instance global defaults;
|
|
575
575
|
// the cascade's job here is to surface the posture's audit-log
|
package/lib/retry.js
CHANGED
|
@@ -275,7 +275,7 @@ function backoffDelay(attempt, opts) {
|
|
|
275
275
|
opts = opts || DEFAULT_RETRY;
|
|
276
276
|
var base = opts.baseDelayMs * Math.pow(2, attempt - 1);
|
|
277
277
|
var capped = Math.min(base, opts.maxDelayMs);
|
|
278
|
-
//
|
|
278
|
+
// Jitter exists to spread retry storms across the
|
|
279
279
|
// millisecond window so N peer clients waking from the same
|
|
280
280
|
// upstream outage don't all hit the recovering service at the same
|
|
281
281
|
// tick. The value is observable to every client by construction
|
package/lib/safe-archive.js
CHANGED
|
@@ -225,7 +225,7 @@ async function extract(opts) {
|
|
|
225
225
|
}
|
|
226
226
|
inner = await archiveWrap().unwrapWithPassphrase(sealedBytes, { passphrase: opts.passphrase });
|
|
227
227
|
}
|
|
228
|
-
//
|
|
228
|
+
// Close the original source
|
|
229
229
|
// adapter BEFORE replacing it. When opts.source was a string
|
|
230
230
|
// path, the fs adapter opened a file descriptor; overwriting
|
|
231
231
|
// `source` loses the close reference and the descriptor
|
|
@@ -236,7 +236,7 @@ async function extract(opts) {
|
|
|
236
236
|
if (typeof source.close === "function" && typeof opts.source === "string") {
|
|
237
237
|
try { source.close(); } catch (_e) { /* drop-silent */ }
|
|
238
238
|
}
|
|
239
|
-
//
|
|
239
|
+
// Forward opts.signal to the
|
|
240
240
|
// inner buffer adapter so abort propagation stays intact
|
|
241
241
|
// across the unwrap boundary. Without it, an abort raised
|
|
242
242
|
// after unwrapping would no longer cancel inner range()
|
package/lib/safe-ical.js
CHANGED
|
@@ -251,9 +251,9 @@ function parse(text, opts) {
|
|
|
251
251
|
var vcal = consumed.component;
|
|
252
252
|
// RFC 5545 §3.4 — a stream may carry multiple VCALENDAR objects.
|
|
253
253
|
// Walk the remainder so trailing objects are validated under the
|
|
254
|
-
// same caps + control-char + property allowlist
|
|
254
|
+
// same caps + control-char + property allowlist; without
|
|
255
255
|
// this, CalDAV ingest can pass validation on the first object while
|
|
256
|
-
// trailing malformed objects ride through untouched
|
|
256
|
+
// trailing malformed objects ride through untouched.
|
|
257
257
|
var vcalendars = [_shapeVcalendar(vcal)];
|
|
258
258
|
var cursor = consumed.nextIdx;
|
|
259
259
|
while (cursor < lines.length) {
|
package/lib/safe-mime.js
CHANGED
|
@@ -549,7 +549,7 @@ function _splitMultipart(buf, boundary) {
|
|
|
549
549
|
// Per RFC 2046 §5.1.1 a boundary delimiter is `--<value>` preceded
|
|
550
550
|
// by CRLF (or LF) — OR at the very start of the body. A boundary-
|
|
551
551
|
// shaped sequence elsewhere in a part's body MUST NOT be treated
|
|
552
|
-
// as a delimiter.
|
|
552
|
+
// as a delimiter.
|
|
553
553
|
var idx = _findBoundaryAtLineStart(buf, delimiter, pos);
|
|
554
554
|
if (idx < 0) break;
|
|
555
555
|
if (buf[idx + delimiter.length] === 0x2D && buf[idx + delimiter.length + 1] === 0x2D) {
|
|
@@ -208,7 +208,7 @@ function verify(assetPath, signaturePath, pubkeyPem) {
|
|
|
208
208
|
// produces. 64 KiB chunks match the framework's hash-while-streaming
|
|
209
209
|
// convention elsewhere.
|
|
210
210
|
//
|
|
211
|
-
//
|
|
211
|
+
// Hardening (v0.9.58): fstat the asset BEFORE the read loop
|
|
212
212
|
// for every alg path, clamp every readSync to (assetStat.size -
|
|
213
213
|
// fullOff), and reject if the final fullOff diverges from
|
|
214
214
|
// assetStat.size. A grow-during-read race (writer appends as we
|
package/lib/self-update.js
CHANGED
|
@@ -115,7 +115,7 @@ function _normalizeTag(tag) {
|
|
|
115
115
|
* Missing numeric components on either side are treated as `"0"` so
|
|
116
116
|
* `"1.0"` and `"1.0.0"` compare equal.
|
|
117
117
|
*
|
|
118
|
-
*
|
|
118
|
+
* Hardening (v0.9.58) — pre-v0.9.58 the pre-release segment fell back
|
|
119
119
|
* to lexicographic comparison, which silently misordered `"1.0.0-alpha.10"`
|
|
120
120
|
* (the strict-§11 LARGER pre-release) and `"1.0.0-alpha.9"`: as strings
|
|
121
121
|
* "10" < "9" so `alpha.10 < alpha.9`, and a downstream consumer polling
|
|
@@ -294,7 +294,7 @@ function _matchAsset(name, pattern, fallback) {
|
|
|
294
294
|
* timeoutMs: number, // request timeout (default 15s)
|
|
295
295
|
* headers: object, // additional request headers
|
|
296
296
|
* etag: string, // last-seen etag for If-None-Match
|
|
297
|
-
* // (
|
|
297
|
+
* // (etags are RFC 9110 §13.1.1
|
|
298
298
|
* // per-resource; an etag captured for
|
|
299
299
|
* // releasesUrl=A is meaningless against
|
|
300
300
|
* // releasesUrl=B. Operators rotating
|
package/lib/static.js
CHANGED
|
@@ -216,7 +216,7 @@ function _resolveSafe(root, requestedPath) {
|
|
|
216
216
|
// deposited disk content: shell-exec extensions (.exe / .bin / .so /
|
|
217
217
|
// legitimate `<name>.<hash>.js` bundler output) are valid here. The
|
|
218
218
|
// other balanced checks still reject the traversal + smuggling
|
|
219
|
-
// surface
|
|
219
|
+
// surface.
|
|
220
220
|
var fname = nodePath.basename(resolved);
|
|
221
221
|
var rv = guardFilename().validate(fname, {
|
|
222
222
|
profile: "balanced",
|
package/lib/subject.js
CHANGED
|
@@ -362,7 +362,7 @@ function erase(subjectId, opts) {
|
|
|
362
362
|
|
|
363
363
|
// ---- Crypto-shred erase (Art. 17 + WAL/replica residual closure) ----
|
|
364
364
|
//
|
|
365
|
-
//
|
|
365
|
+
// When a table opts into per-row keying via
|
|
366
366
|
// b.cryptoField.declarePerRowKey, this primitive deletes the
|
|
367
367
|
// per-row K_row entries from _blamejs_per_row_keys, leaving any
|
|
368
368
|
// residual ciphertext in WAL / replica / backup storage
|
|
@@ -477,7 +477,7 @@ function eraseHard(subjectId, opts) {
|
|
|
477
477
|
totalDeleted += deleted;
|
|
478
478
|
perTable[spec.name] = deleted;
|
|
479
479
|
// REINDEX the table so B-tree pages holding the deleted row's
|
|
480
|
-
// index entries are rebuilt — closes the
|
|
480
|
+
// index entries are rebuilt — closes the erase-vacuum residual class.
|
|
481
481
|
try { db().runSql('REINDEX "' + spec.name + '"'); } // table name comes from FRAMEWORK_SCHEMA
|
|
482
482
|
catch (_e) { /* cluster mode / unsupported dialect */ }
|
|
483
483
|
}
|
package/lib/vault/index.js
CHANGED
|
@@ -102,11 +102,12 @@ function resolvePaths(dataDir) {
|
|
|
102
102
|
plaintext: nodePath.join(dataDir, "vault.key"),
|
|
103
103
|
sealed: nodePath.join(dataDir, "vault.key.sealed"),
|
|
104
104
|
derivedHashSalt: nodePath.join(dataDir, "vault.derived-hash-salt"),
|
|
105
|
+
derivedHashMacKey: nodePath.join(dataDir, "vault.derived-hash-mac.sealed"),
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
// derivedHashSalt — per-deployment salt for crypto-field
|
|
109
|
-
// derivedHashes
|
|
110
|
+
// derivedHashes. Pre-v0.8.42 the deterministic
|
|
110
111
|
// sha3(namespace + plaintext) shape allowed cross-deployment
|
|
111
112
|
// rainbow + cross-table correlation; binding a 32-byte
|
|
112
113
|
// per-deployment salt closes that class without breaking
|
|
@@ -175,6 +176,66 @@ function getDerivedHashSalt() {
|
|
|
175
176
|
return _cachedDerivedHashSalt;
|
|
176
177
|
}
|
|
177
178
|
|
|
179
|
+
// derivedHashMacKey — per-deployment SECRET key for crypto-field's
|
|
180
|
+
// keyed (hmac-shake256) derived-hash mode. Unlike the salt, this is
|
|
181
|
+
// SEALED at rest (vault.derived-hash-mac.sealed), so an attacker with
|
|
182
|
+
// disk access alone cannot recompute the keyed digest and correlate
|
|
183
|
+
// low-entropy plaintexts. Like the salt, it is keypair-bound and
|
|
184
|
+
// survives a passphrase-only rotation; an ENVELOPE rotation re-seals it
|
|
185
|
+
// because it is registered in rotate's additionalSealed sweep.
|
|
186
|
+
function _readOrCreateDerivedHashMacKey() {
|
|
187
|
+
if (!paths) {
|
|
188
|
+
throw new VaultError("vault/not-initialized",
|
|
189
|
+
"vault.getDerivedHashMacKey() requires init()");
|
|
190
|
+
}
|
|
191
|
+
if (nodeFs.existsSync(paths.derivedHashMacKey)) {
|
|
192
|
+
var sealed = atomicFile.readSync(paths.derivedHashMacKey, { encoding: "utf8" }).trim();
|
|
193
|
+
var b64 = unseal(sealed);
|
|
194
|
+
var key = Buffer.from(b64, "base64");
|
|
195
|
+
if (key.length !== 32) { // 32-byte (256-bit) MAC key
|
|
196
|
+
throw new VaultError("vault/derived-hash-mac-key-corrupted",
|
|
197
|
+
"vault.derived-hash-mac key must unseal to exactly 32 bytes; got " + key.length);
|
|
198
|
+
}
|
|
199
|
+
return key;
|
|
200
|
+
}
|
|
201
|
+
var nodeCrypto = require("node:crypto");
|
|
202
|
+
var raw = nodeCrypto.randomBytes(32); // 32-byte MAC key
|
|
203
|
+
atomicFile.writeSync(paths.derivedHashMacKey, seal(raw.toString("base64")), { fileMode: 0o600 });
|
|
204
|
+
log("generated per-deployment derivedHash MAC key at " + paths.derivedHashMacKey);
|
|
205
|
+
return raw;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
var _cachedDerivedHashMacKey = null;
|
|
209
|
+
/**
|
|
210
|
+
* @primitive b.vault.getDerivedHashMacKey
|
|
211
|
+
* @signature b.vault.getDerivedHashMacKey()
|
|
212
|
+
* @since 0.14.7
|
|
213
|
+
* @related b.vault.getDerivedHashSalt, b.cryptoField.registerTable
|
|
214
|
+
*
|
|
215
|
+
* Returns the 32-byte per-deployment SECRET key that backs crypto-
|
|
216
|
+
* field's keyed (`hmac-shake256`) derived-hash mode. Generated once on
|
|
217
|
+
* first use, SEALED at rest (`vault.derived-hash-mac.sealed`, mode
|
|
218
|
+
* `0o600`) so disk access alone does not expose it, and re-sealed by an
|
|
219
|
+
* envelope vault rotation. Distinct from `getDerivedHashSalt`, which is
|
|
220
|
+
* a non-secret salt stored in plaintext.
|
|
221
|
+
*
|
|
222
|
+
* Throws `VaultError("vault/not-initialized")` before `init()`, or
|
|
223
|
+
* `vault/derived-hash-mac-key-corrupted` if the sealed file does not
|
|
224
|
+
* unseal to exactly 32 bytes.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* await b.vault.init({ dataDir: "/var/lib/blamejs", mode: "plaintext" });
|
|
228
|
+
* var k = b.vault.getDerivedHashMacKey();
|
|
229
|
+
* k.length; // → 32
|
|
230
|
+
* Buffer.isBuffer(k); // → true
|
|
231
|
+
*/
|
|
232
|
+
function getDerivedHashMacKey() {
|
|
233
|
+
if (_cachedDerivedHashMacKey === null) {
|
|
234
|
+
_cachedDerivedHashMacKey = _readOrCreateDerivedHashMacKey();
|
|
235
|
+
}
|
|
236
|
+
return _cachedDerivedHashMacKey;
|
|
237
|
+
}
|
|
238
|
+
|
|
178
239
|
// ---- Init dispatch ----
|
|
179
240
|
|
|
180
241
|
/**
|
|
@@ -620,6 +681,7 @@ module.exports = {
|
|
|
620
681
|
seal: seal,
|
|
621
682
|
unseal: unseal,
|
|
622
683
|
getDerivedHashSalt: getDerivedHashSalt,
|
|
684
|
+
getDerivedHashMacKey: getDerivedHashMacKey,
|
|
623
685
|
_zeroizeAndReplace: _zeroizeAndReplace,
|
|
624
686
|
aad: vaultAad,
|
|
625
687
|
getKeysJson: getKeysJson,
|
|
@@ -633,6 +695,7 @@ module.exports = {
|
|
|
633
695
|
_resetForTest: function () {
|
|
634
696
|
if (currentPassphrase) safeBuffer.secureZero(currentPassphrase);
|
|
635
697
|
keys = null; initialized = false; currentPassphrase = null; paths = null; currentMode = null;
|
|
698
|
+
_cachedDerivedHashSalt = null; _cachedDerivedHashMacKey = null;
|
|
636
699
|
},
|
|
637
700
|
_getKeysForTest: function () { return keys; },
|
|
638
701
|
_getPathsForTest: function () { return paths; },
|
package/lib/vault/rotate.js
CHANGED
|
@@ -651,6 +651,25 @@ async function rotate(opts) {
|
|
|
651
651
|
_reSealValue(current, oldKeys, newKeys), { mode: 0o600 });
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
// 3b. Framework-managed crypto-field derived-hash files — always
|
|
655
|
+
// rotated regardless of operator opts.paths, so the staging copy is
|
|
656
|
+
// complete. The plaintext salt is copied verbatim; the SEALED MAC key
|
|
657
|
+
// (keyed hmac-shake256 mode) is re-sealed under the new keypair so an
|
|
658
|
+
// envelope rotation doesn't orphan it (a passphrase-only rotation
|
|
659
|
+
// re-seals to the same value since the keypair is unchanged).
|
|
660
|
+
var saltSrc = nodePath.join(dataDir, "vault.derived-hash-salt");
|
|
661
|
+
if (nodeFs.existsSync(saltSrc)) {
|
|
662
|
+
nodeFs.copyFileSync(saltSrc, nodePath.join(stagingDir, "vault.derived-hash-salt"));
|
|
663
|
+
}
|
|
664
|
+
var macSrc = nodePath.join(dataDir, "vault.derived-hash-mac.sealed");
|
|
665
|
+
if (nodeFs.existsSync(macSrc)) {
|
|
666
|
+
var macCurrent = nodeFs.readFileSync(macSrc, "utf8").trim();
|
|
667
|
+
if (macCurrent.indexOf(C.VAULT_PREFIX) === 0) {
|
|
668
|
+
nodeFs.writeFileSync(nodePath.join(stagingDir, "vault.derived-hash-mac.sealed"),
|
|
669
|
+
_reSealValue(macCurrent, oldKeys, newKeys), { mode: 0o600 });
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
654
673
|
// 4. decrypt + rotate + re-encrypt db.enc
|
|
655
674
|
_emit(progress, { phase: "rotate_db" });
|
|
656
675
|
var encDbPath = nodePath.join(dataDir, paths.encryptedDb);
|
package/lib/vendor-data.js
CHANGED
|
@@ -306,7 +306,7 @@ function _loadAndVerify(name) {
|
|
|
306
306
|
// Memoized — "sha256:" + sha256(pemToRaw(PUBKEY_PEM)). Matches the
|
|
307
307
|
// canonical fingerprint shape `scripts/vendor-data-gen.js` writes into
|
|
308
308
|
// each .data.js's `metadata.publicKeyFingerprint`. Computed lazily on
|
|
309
|
-
// first verify (also lazily by verifyAll at boot).
|
|
309
|
+
// first verify (also lazily by verifyAll at boot). Every
|
|
310
310
|
// per-entry verify cross-checks this against the entry's declared
|
|
311
311
|
// `meta.publicKeyFingerprint` so a pubkey-swap attack fails before
|
|
312
312
|
// signature verify even runs.
|
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:5777b851-3edb-4e73-9a6a-0538d8e52a91",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-05-
|
|
8
|
+
"timestamp": "2026-05-30T21:03:08.883Z",
|
|
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.14.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.14.7",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.14.
|
|
25
|
+
"version": "0.14.7",
|
|
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.14.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/core@0.14.7",
|
|
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.14.
|
|
57
|
+
"ref": "@blamejs/core@0.14.7",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|