@blamejs/core 0.16.36 → 0.16.37
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/lib/metrics.js +36 -4
- package/lib/middleware/age-gate.js +7 -1
- package/lib/sql.js +15 -1
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,8 @@ upgrading across more than a few patches at a time.
|
|
|
8
8
|
|
|
9
9
|
## v0.16.x
|
|
10
10
|
|
|
11
|
+
- v0.16.37 (2026-07-16) — **Three fail-open / injection fixes: the age gate no longer admits a user whose age fails to compute, the query builder's OFFSET-without-LIMIT runs on every backend, and metrics exemplars can no longer carry an unsanitized value into the scrape stream.** Three defects, each in a class the framework treats as security-relevant. b.middleware.ageGate classified a non-finite age (a NaN or Infinity returned by getAge when a birth field fails to parse) as an adult -- admitting the request with none of the child-safety privacy defaults -- instead of treating an uncomputable age as unknown. b.sql (and b.db.from / b.db.collection over it) emitted a bare OFFSET with no LIMIT, which is valid only on Postgres and is a syntax error on SQLite -- the framework's own backend -- and MySQL, so a valid builder chain failed to run on two of three dialects. And b.metrics exemplars rendered their labels, value, and timestamp into the OpenMetrics scrape surface without the credential-scrub and numeric-coercion regular labels receive, so an operator-supplied exemplar could leak a credential-shaped label or inject a forged metric line through exemplar.value / exemplar.timestamp. **Fixed:** *Age gate treats a non-finite age as unknown, not as an adult* — b.middleware.ageGate now classifies a non-finite age (NaN or +/-Infinity, the shape getAge returns when a birth field fails to parse or date math goes wrong) as "unknown" rather than letting it fall through to "above-threshold". Because typeof NaN === "number" and every comparison against NaN is false, an uncomputable age previously bypassed the below-threshold branch and was admitted as a confirmed adult -- with none of the child-safety privacy defaults (Cache-Control: private, no-store; Referrer-Policy: no-referrer; the privacy-posture header) the unknown path applies. When the birth value is request-derived this is attacker-influenced. A non-finite age is now handled exactly like a null return: the request is classified unknown and the privacy defaults are applied. · *Query builder OFFSET without LIMIT runs on SQLite and MySQL, not only Postgres* — b.sql SELECT (and the b.db.from / b.db.collection consumers built on it) emitted a bare "OFFSET n" when .offset() was set without .limit(). A bare OFFSET is valid only on Postgres; SQLite (the framework's own node:sqlite backend) and MySQL both reject it as a syntax error, so a valid builder chain produced SQL that failed to prepare on two of the three supported dialects, including the default one. The builder now emits the dialect's unbounded-limit sentinel before the OFFSET -- SQLite LIMIT -1, MySQL the maximum unsigned BIGINT, Postgres LIMIT ALL -- so one query text runs unchanged across all three. Statements that set an explicit LIMIT are byte-for-byte unchanged. · *Metrics exemplars are sanitized on the scrape surface the same way regular labels are* — b.metrics histogram exemplars rendered their labels, value, and timestamp into the OpenMetrics /metrics exposition -- the same broadly-readable scrape surface regular labels reach -- without the sanitization regular labels receive. Exemplar label values bypassed the credential scrubber, so a credential-shaped value an operator attached to an exemplar (e.g. tapping a raw header alongside trace context) egressed in cleartext (CWE-532); and exemplar.value / exemplar.timestamp were appended to the exposition line raw, so a non-numeric operator-supplied value such as "1.0\n# forged 999" could inject a forged metric line. Exemplar labels now flow through the same credential scrubber as regular labels, and exemplar value and timestamp are coerced to a finite number (value falling back to the observed value, timestamp to none) at store time, so only sanitized labels and bare numbers ever reach the wire. Trace context (trace_id / span_id) and numeric values pass through unchanged.
|
|
12
|
+
|
|
11
13
|
- v0.16.36 (2026-07-16) — **DKIM simple header canonicalization now signs and verifies the DKIM-Signature header verbatim, so simple-canon signatures round-trip and interoperate.** b.mail.dkim's simple header canonicalization (c=simple/... in a signature) signs and verifies each header exactly as it appears on the wire, per RFC 6376 §3.4.1. Two defects broke that for the DKIM-Signature header itself: the signer canonicalized the header UNFOLDED while emitting it FOLDED on the wire, and the verifier prefixed a spurious extra space to the parsed header value. Together they meant a simple-header-canonicalization signature never matched the bytes that were signed -- neither the framework's own signatures nor an RFC-compliant peer's would verify under simple canon. The signer now canonicalizes and emits the same folded header (appending the signature to the folded, b-emptied form), and the verifier canonicalizes the parsed header verbatim, so a simple-canon signature round-trips and is byte-compatible with other implementations. Relaxed canonicalization, the common default, is unchanged. Separately, a supply-chain gate now fails the build if a vendored component in lib/vendor/MANIFEST.json has no attribution entry in NOTICE. **Added:** *b.safeBuffer.byteLengthOfIfMeasurable — measure a value's byte length, or null when it is not a byte carrier* — byteLengthOfIfMeasurable(value) returns the byte length of a string, Buffer, or Uint8Array, and null for anything else (a plain Array, an array-like object, a number, null). It is the safe way to cap the size of an untrusted metadata bag whose byte field may be any shape: measure the cap only when the value is measurable, rather than gating byteLengthOf (which throws on a non-byte-carrier) on a hand-rolled length check that admits array-likes and crashes. The image and PDF content guards now compose it for their byte caps instead of each vetting the type inline. **Fixed:** *DKIM simple header canonicalization signs and verifies the DKIM-Signature header verbatim* — Under simple header canonicalization (RFC 6376 §3.4.1) the DKIM-Signature header is signed and verified byte-for-byte as it appears on the wire, including its folding. b.mail.dkim canonicalized the header UNFOLDED when computing the signature but emitted it FOLDED on the wire, and the verifier prepended an extra space to the parsed header value before canonicalizing -- so the bytes signed never matched the bytes verified. A simple-header-canonicalization signature therefore never verified, whether produced by the framework or by an RFC-compliant peer. The signer now canonicalizes the folded, b-emptied header and builds the wire header by appending the signature to it, and the verifier canonicalizes the parsed (folded) header verbatim -- including the DKIM-Signature field name exactly as it appears on the wire, so a peer that signs a lowercase dkim-signature: field name also verifies -- so a simple-canon signature round-trips and interoperates. This was fail-closed -- a broken simple-canon signature was reported as a verification failure, never a false pass -- and relaxed canonicalization (the common default, which normalizes folding and whitespace on both sides) was and remains correct. **Detectors:** *Every vendored component in the manifest must be attributed in NOTICE* — A gate fails the build when a component recorded in lib/vendor/MANIFEST.json has no attribution entry in the NOTICE file. Third-party components ship with their license and attribution obligations; this catches a vendored library or data file added to the manifest without its NOTICE entry before the package is published, rather than after a downstream scanner flags the omission.
|
|
12
14
|
|
|
13
15
|
- v0.16.35 (2026-07-16) — **A resumed saga that later fails now compensates the steps it completed before the crash, and a webhook delivery retries a transient DNS failure during its safety re-check instead of dead-lettering.** Two durability fixes in the agent orchestration and webhook delivery primitives. b.agent.saga rebuilt its completed-step list from empty when a saga resumed from a persisted checkpoint, so a failure after the resume compensated only the steps that ran in that resumed pass -- the steps completed before the crash were never rolled back, defeating the saga's whole purpose (a charge committed before the crash would never be refunded when a later step failed). Resume now seeds the completed-step list with the steps that finished before the crash, so a failure compensates the full set in reverse order. Separately, b.webhook.dispatcher re-checks a delivery's destination for an SSRF rebind just before each attempt; that check resolves the destination host, and a transient resolver failure (a temporary DNS error) during it was treated as a permanent failure and dead-lettered the delivery on the first attempt. The re-check now dead-letters only a genuine SSRF refusal or malformed URL and treats a transient resolver fault as retryable, like every other transport error. **Added:** *b.webhook.dispatcher accepts a dnsLookup override for the destination SSRF check* — b.webhook.dispatcher now accepts an optional dnsLookup(host) resolver, forwarded to the SSRF destination check, so an operator can point destination resolution at a specific resolver (and a test can drive the transient-versus-permanent classification offline). It defaults to the framework's DNS-over-TLS resolver, unchanged. **Fixed:** *A resumed saga compensates the steps it completed before the crash, not only those in the resumed run* — b.agent.saga runs a sequence of steps and, on a step failure, compensates the completed steps in reverse order. When a saga resumed from a persisted checkpoint, it started its completed-step list empty, so a failure after the resume compensated only the steps that ran in the resumed pass -- the steps completed before the crash were left uncompensated. For a distributed transaction that is the exact failure the pattern exists to prevent: work committed before the crash (a charge, a reservation, an external call) would never be rolled back when a later step failed. Resume now seeds the completed-step list with the steps that finished before the crash, reconstructed from the saga definition, so a subsequent failure compensates the full completed set in reverse; compensation runs against the resumed state, which already reflects those steps' effects, and the failing step itself is not compensated. To keep that reseeding safe against replay, resume also refuses a saga the state store marks terminal (failed-and-compensated or completed) rather than re-running its compensators, and the state-store interface documents that compensators must be idempotent -- a crash mid-compensation can replay a compensation on the next resume, so compensating twice must be safe. · *Webhook delivery retries a transient DNS failure during its SSRF re-check instead of dead-lettering* — b.webhook.dispatcher re-validates a delivery's destination against SSRF (private / loopback / metadata IPs, or a rebind since registration) just before each attempt, which resolves the destination host. A transient resolver failure during that resolution -- a lookup timeout or system/resolve failure -- was caught and marked a permanent failure, dead-lettering the delivery on its first attempt rather than retrying. The re-check now classifies the failure: a genuine SSRF refusal or malformed URL dead-letters, a resolver failure honors the framework DNS resolver's own terminal-versus-transient verdict (a permanent failure such as a host with no addresses or a removed record dead-letters immediately, a transient one is retried on the backoff curve, capped at maxAttempts), matching how the dispatcher already treats a transient DNS error during the delivery POST itself. So a webhook is no longer lost to a momentary DNS blip, a genuine rebind to an internal address is still dead-lettered immediately, and a permanently unresolvable destination dead-letters without burning every retry attempt.
|
package/lib/metrics.js
CHANGED
|
@@ -211,6 +211,34 @@ function _validateLabelValue(value) {
|
|
|
211
211
|
return coerced;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
// Redact every value of a free-form label map through the credential
|
|
215
|
+
// scrubber. Exemplar labels (trace_id / span_id, or any operator-supplied
|
|
216
|
+
// pair passed to histogram.observe) are rendered verbatim into the
|
|
217
|
+
// OpenMetrics exposition — the SAME scrape surface regular labels reach — so
|
|
218
|
+
// they get the same scrub. Redacting at STORE time mirrors how _resolveLabels
|
|
219
|
+
// scrubs regular labels before they land in entry.labels, keeping
|
|
220
|
+
// _renderFamilyLines a verbatim renderer for every exposition path that shares
|
|
221
|
+
// it (CWE-532).
|
|
222
|
+
function _redactLabelMap(labelObj) {
|
|
223
|
+
var out = {};
|
|
224
|
+
if (!labelObj || typeof labelObj !== "object") return out;
|
|
225
|
+
var keys = Object.keys(labelObj);
|
|
226
|
+
for (var i = 0; i < keys.length; i++) out[keys[i]] = _validateLabelValue(labelObj[keys[i]]);
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Coerce an exemplar's value / timestamp to a finite number. Per OpenMetrics
|
|
231
|
+
// 1.0 §6.2 both are numeric, but _renderFamilyLines appends them to the
|
|
232
|
+
// exposition line RAW (unlike labels, which _escapeLabelValue quotes). A
|
|
233
|
+
// non-numeric operator-supplied field — `exemplar.value = "1\n# forged 9"` —
|
|
234
|
+
// would otherwise inject a forged metric line into every scrape. Reject any
|
|
235
|
+
// non-finite value to the caller-supplied fallback so only a bare number ever
|
|
236
|
+
// reaches the wire.
|
|
237
|
+
function _numericExemplarField(value, fallback) {
|
|
238
|
+
var n = typeof value === "number" ? value : Number(value);
|
|
239
|
+
return isFinite(n) ? n : fallback;
|
|
240
|
+
}
|
|
241
|
+
|
|
214
242
|
// Serialize a labels object to a canonical Map key. Routed through
|
|
215
243
|
// canonical-json so the framework has one canonical-sort source of
|
|
216
244
|
// truth for sorted-keys serialization (avoiding the silent-data-loss
|
|
@@ -290,7 +318,11 @@ function _renderFamilyLines(family, openMetrics, lines) {
|
|
|
290
318
|
if (openMetrics && entry.exemplars && entry.exemplars[bi]) {
|
|
291
319
|
var ex = entry.exemplars[bi];
|
|
292
320
|
bucketLine += " # " + _renderLabels(ex.labels || {}) + " " + ex.value;
|
|
293
|
-
|
|
321
|
+
// Present-vs-missing on the coerced timestamp is `is a number`, not
|
|
322
|
+
// truthiness: _numericExemplarField stores a finite number or null,
|
|
323
|
+
// and the Unix epoch is a valid timestamp of 0 — a truthiness guard
|
|
324
|
+
// would silently drop it.
|
|
325
|
+
if (typeof ex.timestamp === "number") bucketLine += " " + ex.timestamp;
|
|
294
326
|
}
|
|
295
327
|
lines.push(bucketLine);
|
|
296
328
|
}
|
|
@@ -644,9 +676,9 @@ function create(opts) {
|
|
|
644
676
|
// arg; the registry only records what's passed in.
|
|
645
677
|
if (exemplar && typeof exemplar === "object") {
|
|
646
678
|
entry.exemplars[i] = {
|
|
647
|
-
labels: exemplar.labels
|
|
648
|
-
value: exemplar.value
|
|
649
|
-
timestamp: exemplar.timestamp
|
|
679
|
+
labels: _redactLabelMap(exemplar.labels),
|
|
680
|
+
value: _numericExemplarField(exemplar.value, arg.value),
|
|
681
|
+
timestamp: _numericExemplarField(exemplar.timestamp, null),
|
|
650
682
|
};
|
|
651
683
|
}
|
|
652
684
|
}
|
|
@@ -140,7 +140,13 @@ function create(opts) {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
var classification;
|
|
143
|
-
|
|
143
|
+
// A non-finite age (NaN from parseInt on a malformed birth field or
|
|
144
|
+
// date math, ±Infinity) is NOT a confirmed adult: typeof NaN === "number"
|
|
145
|
+
// and `NaN < consentRequired` is false, so without the isFinite guard the
|
|
146
|
+
// classifier fell through to "above-threshold" and dropped every privacy
|
|
147
|
+
// default for a user whose age simply failed to compute. Treat it as
|
|
148
|
+
// "unknown" (privacy headers applied), consistent with a null return.
|
|
149
|
+
if (age === null || typeof age !== "number" || !isFinite(age)) classification = "unknown";
|
|
144
150
|
else if (consentRequired !== null && age < consentRequired) classification = "below-threshold";
|
|
145
151
|
else classification = "above-threshold";
|
|
146
152
|
|
package/lib/sql.js
CHANGED
|
@@ -1760,7 +1760,21 @@ class SelectBuilder extends Builder {
|
|
|
1760
1760
|
if (h.sql) { sql += " HAVING " + h.sql; for (var hi = 0; hi < h.params.length; hi++) params.push(h.params[hi]); }
|
|
1761
1761
|
|
|
1762
1762
|
if (this._orderBy.length > 0) sql += " ORDER BY " + this._orderBy.join(", ");
|
|
1763
|
-
|
|
1763
|
+
// OFFSET without LIMIT is valid only on Postgres; SQLite and MySQL both
|
|
1764
|
+
// reject a bare OFFSET as a syntax error (there is no bare-OFFSET spelling
|
|
1765
|
+
// for "skip N, return the rest" on those backends). Emit the dialect's
|
|
1766
|
+
// unbounded-limit sentinel so one query text runs unchanged across all
|
|
1767
|
+
// three: SQLite `LIMIT -1`, MySQL the max unsigned BIGINT, Postgres
|
|
1768
|
+
// `LIMIT ALL`. When a real LIMIT is set the existing token is emitted
|
|
1769
|
+
// untouched, so limit-present statements are byte-for-byte unchanged.
|
|
1770
|
+
var limitToken = null;
|
|
1771
|
+
if (this._limit !== null) {
|
|
1772
|
+
limitToken = String(this._limit);
|
|
1773
|
+
} else if (this._offset !== null) {
|
|
1774
|
+
limitToken = dialect === "sqlite" ? "-1"
|
|
1775
|
+
: (dialect === "mysql" ? "18446744073709551615" : "ALL");
|
|
1776
|
+
}
|
|
1777
|
+
if (limitToken !== null) sql += " LIMIT " + limitToken;
|
|
1764
1778
|
if (this._offset !== null) sql += " OFFSET " + this._offset;
|
|
1765
1779
|
|
|
1766
1780
|
if (this._lockMode !== 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:b15701b8-cd2a-49f6-bbcd-c91646be481f",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-07-
|
|
8
|
+
"timestamp": "2026-07-16T19:30:55.778Z",
|
|
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.16.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.16.37",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.16.
|
|
25
|
+
"version": "0.16.37",
|
|
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.16.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/core@0.16.37",
|
|
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.16.
|
|
57
|
+
"ref": "@blamejs/core@0.16.37",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|