@blamejs/core 0.8.32 → 0.8.34
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/auth/jwt.js +16 -0
- package/lib/auth/oauth.js +22 -1
- package/lib/middleware/body-parser.js +10 -0
- package/lib/middleware/security-headers.js +13 -0
- package/lib/websocket.js +30 -0
- package/package.json +1 -1
- package/sbom.cyclonedx.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.8.x
|
|
10
10
|
|
|
11
|
+
- **0.8.34** (2026-05-08) — `lib/middleware/body-parser.js` BiDi-strip regex uses Unicode-escape form (`\\u202A`-style) instead of literal codepoints to satisfy ESLint's `no-irregular-whitespace`. v0.8.33 publish workflow blocked on this; v0.8.33 tag exists on git but never reached npm — v0.8.34 cumulative includes the v0.8.33 G-class MEDIUM fixes.
|
|
12
|
+
|
|
13
|
+
- **0.8.33** (2026-05-08) — HTTP/web G-class MEDIUM cleanup. Six RFC-cited refinements against shipped WebSocket / Permissions-Policy / JWT / body-parser / OAuth surfaces. **WS close-frame validation (RFC 6455 §5.5.1 + §7.4.2)** — `_handleClose` now refuses 1-byte close-frame payloads (malformed; pre-v0.8.33 silently accepted as clean close, evading anomaly detection) and validates the close-code against the §7.4.2 vocabulary (1000-1011 + 3000-4999 valid; 1004/1005/1006/1015 reserved/forbidden; everything else refused). **Permissions-Policy default expansion** — `b.middleware.securityHeaders` deny-by-default now covers `interest-cohort`, `attribution-reporting`, `bluetooth`, `hid`, `serial`, `idle-detection`, `local-fonts`, `compute-pressure`, `window-management`, `private-state-token-issuance`, `private-state-token-redemption`. **JWT typ assertion (RFC 8725 §3.11)** — `b.auth.jwt.verify({expectedTyp})` refuses tokens whose header.typ doesn't match (typ-confusion class). Case-insensitive match per RFC 8725. Unset `expectedTyp` skips the check (legacy token compatibility). **Multipart filename BiDi/RTL strip** — `_sanitizeFilename` now drops Trojan Source (CVE-2021-42574) BiDi formatting + zero-width codepoints from uploaded filenames before the basename hits the filesystem. **OAuth redirect_uri localhost exception (RFC 9700 §4.1.1)** — `b.auth.oauth.create({redirectUri})` now accepts `http://localhost` / `http://127.0.0.1` / `http://[::1]` without requiring `allowHttp: true` (which would loosen ALL operator-supplied URLs). HTTPS still required for non-loopback hosts.
|
|
14
|
+
|
|
11
15
|
- **0.8.32** (2026-05-08) — Email/DNS MEDIUM impl-vs-spec cleanup. Eight RFC-cited refinements against shipped DKIM / SPF / DMARC / A-R / TLS-RPT / DoH primitives. **DKIM (`b.mail.dkim`)** — verifier enforces `x=` signature expiration (permerrors past expiry per RFC 6376 §3.5) and `t=` future-date sanity (refuses signatures more than 24h ahead of `now`); rejects `x= < t=` malformation. Operator-tunable `clockSkewMs` (default 5 min). **SPF (`b.mail.spf`)** — `_parseSpfRecord` now distinguishes mechanisms from modifiers (RFC 7208 §4.6 — `redirect=` / `exp=` are modifiers, not mechanisms). Pre-v0.8.32 `redirect=` triggered the generic "out of scope" permerror; surfaced separately via `mechanisms.modifiers`. SPF IPv6 CIDR matching now uses a real bitwise CIDR check (`_ipv6Expand` + group-by-group + bit-mask) instead of the prior string-prefix heuristic that mishandled `::` shorthand. **DMARC (`b.mail.dmarc`)** — `recommendedAction` now consults `pct=` per RFC 7489 §6.6.4. When `pct < 100` the receiver applies one-step-less-strict disposition (reject → quarantine; quarantine → none) on the sampled fraction. **A-R (`b.mail.authResults`)** — `reason=` quoted-string now uses RFC 8601 §2.2 `\"` escape (lossless round-trip) instead of the prior `"`-to-`'` collapse. **TLS-RPT (`b.network.smtp.tlsRpt.submit`)** — `mailto:` rua entries are now RFC 5322 addr-spec-validated before forwarding to `b.mail`. Pre-v0.8.32 invalid mailto targets crashed at submit-time with opaque transport errors. **DoH (`b.network.dns.resolveSecure`)** — host now validated label-by-label per RFC 1035 §2.3.4 LDH rule (letters/digits/hyphen, no leading/trailing hyphen, label length 1..63). Pre-v0.8.32 only the total length was checked; underscore / colon / space hosts flowed through to opaque DoH errors. (MTA-STS HTTPS cert validation against `mta-sts.<domain>` is already covered by Node's TLS handshake; no code change needed.)
|
|
12
16
|
|
|
13
17
|
- **0.8.31** (2026-05-08) — `b.fdx` CFPB §1033 / Financial Data Exchange (FDX) consumer-financial-data sharing wrapper. CFPB §1033 (12 CFR §1033.121-461, final rule 2024-10-22) gives US consumers the right to authorize a third party to access their financial data through the data provider's developer interface. Compliance deadline ⏰ 2026-04-01 already past for $250B+ asset-size banks. **`b.fdx.bind({authServer, resources})`** binds the operator's authorization server config to the FAPI 2.0 profile (the §1033.351 security requirements ≈ FAPI 2.0); refuses if PKCE/DPoP/PAR are misconfigured per `b.fapi2.assertOAuthConfig`. **`b.fdx.validateResponse(resourceType, body)`** validates a response shape against the FDX 6.0 minimum schema for accounts / transactions / statements / payment-networks / rewards / tax-forms — refuses missing-required fields. **`b.fdx.consentReceipt(opts)`** generates the §1033.401(b) consent receipt the authorization server gives the consumer at authorization time (data provider, consumer, third-party recipient, scopes, revocation URL, issued+expires timestamps).
|
package/lib/auth/jwt.js
CHANGED
|
@@ -269,6 +269,22 @@ async function verify(token, opts) {
|
|
|
269
269
|
"token declares critical extensions which this verifier does not support");
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
+
// RFC 8725 §3.11 — typ-confusion class. When opts.expectedTyp is
|
|
273
|
+
// supplied (e.g. "JWT", "at+jwt", "logout+jwt"), refuse tokens
|
|
274
|
+
// whose header.typ doesn't match. Caller-side check; the framework
|
|
275
|
+
// doesn't impose a default typ to remain compatible with legacy
|
|
276
|
+
// tokens that omit it. Match is case-insensitive per RFC 8725.
|
|
277
|
+
if (opts.expectedTyp !== undefined) {
|
|
278
|
+
validateOpts.requireNonEmptyString(opts.expectedTyp,
|
|
279
|
+
"verify: opts.expectedTyp", AuthError, "auth-jwt/bad-expected-typ");
|
|
280
|
+
var got = decoded.header.typ;
|
|
281
|
+
if (typeof got !== "string" || got.toLowerCase() !== opts.expectedTyp.toLowerCase()) {
|
|
282
|
+
throw new AuthError("auth-jwt/typ-mismatch",
|
|
283
|
+
"token header.typ='" + got + "' does not match expectedTyp='" +
|
|
284
|
+
opts.expectedTyp + "' (RFC 8725 §3.11 typ-confusion class)");
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
272
288
|
// Algorithm must be in the allowed list AND match what we know how
|
|
273
289
|
// to verify (i.e. one of SUPPORTED_ALGORITHMS).
|
|
274
290
|
if (allowed.indexOf(decoded.header.alg) === -1) {
|
package/lib/auth/oauth.js
CHANGED
|
@@ -111,6 +111,7 @@ var { generateBytes } = require("../crypto");
|
|
|
111
111
|
var httpClient = require("../http-client");
|
|
112
112
|
var safeJson = require("../safe-json");
|
|
113
113
|
var safeUrl = require("../safe-url");
|
|
114
|
+
var { URL } = require("url");
|
|
114
115
|
var { defineClass } = require("../framework-error");
|
|
115
116
|
|
|
116
117
|
// Cap on responses parsed from upstream OAuth providers. Token /
|
|
@@ -235,6 +236,26 @@ function _validateUrl(url, allowHttp, label) {
|
|
|
235
236
|
if (typeof url !== "string" || url.length === 0) {
|
|
236
237
|
throw new OAuthError("auth-oauth/bad-url", label + ": URL is required");
|
|
237
238
|
}
|
|
239
|
+
// RFC 9700 §4.1.1 — redirect URIs MUST be HTTPS, with an exception
|
|
240
|
+
// for `http://localhost` and `http://127.0.0.1[:port]` to enable
|
|
241
|
+
// local development. Pre-v0.8.33 operators developing on localhost
|
|
242
|
+
// had to set `allowHttp: true` globally, which loosens the gate
|
|
243
|
+
// for ALL operator-supplied URLs (issuer, discovery, token, etc.).
|
|
244
|
+
// Now: when the URL is loopback, accept HTTP without flipping the
|
|
245
|
+
// global flag.
|
|
246
|
+
var isLocalhostHttp = false;
|
|
247
|
+
try {
|
|
248
|
+
var parsed = new URL(url); // allow:raw-new-url — RFC 9700 §4.1.1 localhost-exception lookup; safeUrl re-validates below for non-localhost paths
|
|
249
|
+
if (parsed.protocol === "http:" &&
|
|
250
|
+
(parsed.hostname === "localhost" ||
|
|
251
|
+
parsed.hostname === "127.0.0.1" ||
|
|
252
|
+
parsed.hostname === "[::1]" ||
|
|
253
|
+
parsed.hostname === "::1")) {
|
|
254
|
+
isLocalhostHttp = true;
|
|
255
|
+
}
|
|
256
|
+
} catch (_e) { /* malformed; let safeUrl surface the canonical error below */ }
|
|
257
|
+
if (isLocalhostHttp) return url;
|
|
258
|
+
|
|
238
259
|
// Operator-supplied OAuth issuer / endpoint URL — route through
|
|
239
260
|
// safeUrl so the scheme allowlist is consistent with the rest of the
|
|
240
261
|
// framework's outbound gates. Map safe-url's error codes to the
|
|
@@ -246,7 +267,7 @@ function _validateUrl(url, allowHttp, label) {
|
|
|
246
267
|
} catch (e) {
|
|
247
268
|
if (e && e.code === "safe-url/protocol-disallowed") {
|
|
248
269
|
throw new OAuthError("auth-oauth/insecure-url",
|
|
249
|
-
label + ": must be https" + (allowHttp ? " or http" : "") +
|
|
270
|
+
label + ": must be https" + (allowHttp ? " or http" : " (or http://localhost for dev)") +
|
|
250
271
|
" (got '" + url + "')");
|
|
251
272
|
}
|
|
252
273
|
throw new OAuthError("auth-oauth/bad-url",
|
|
@@ -505,6 +505,16 @@ function _sanitizeFilename(name) {
|
|
|
505
505
|
if (idx !== -1) s = s.slice(idx + 1);
|
|
506
506
|
// Drop control characters, NUL, leading/trailing dots.
|
|
507
507
|
s = s.replace(/\p{Cc}/gu, "");
|
|
508
|
+
// Trojan Source CVE-2021-42574 class — strip BiDi formatting +
|
|
509
|
+
// zero-width codepoints from the filename. An attacker uploading
|
|
510
|
+
// `Photo01Bygpj.SCR` displays as `Photo01By.jpg` in audit
|
|
511
|
+
// logs while the OS opens `.SCR`. Universal-refuse on these
|
|
512
|
+
// codepoints; operators with legitimate need pass the raw filename
|
|
513
|
+
// through `b.guardFilename` with explicit BiDi opt-in.
|
|
514
|
+
// BiDi formatting (U+202A..U+202E, U+2066..U+2069), zero-width
|
|
515
|
+
// (U+200B..U+200D, U+2060), BOM (U+FEFF) — Unicode escapes so the
|
|
516
|
+
// regex itself contains no irregular whitespace.
|
|
517
|
+
s = s.replace(/[\u202A-\u202E\u2066-\u2069\u200B-\u200D\u2060\uFEFF]/g, "");
|
|
508
518
|
s = s.replace(/^\.+/, "").replace(/\.+$/, "");
|
|
509
519
|
if (s.length === 0) return null;
|
|
510
520
|
if (s.length > 255) s = s.slice(0, 255);
|
|
@@ -44,6 +44,19 @@ var DEFAULT_PERMISSIONS = [
|
|
|
44
44
|
"geolocation=()", "gyroscope=()", "magnetometer=()", "microphone=()",
|
|
45
45
|
"midi=()", "payment=()", "picture-in-picture=()", "publickey-credentials-get=()",
|
|
46
46
|
"screen-wake-lock=()", "sync-xhr=()", "usb=()", "web-share=()", "xr-spatial-tracking=()",
|
|
47
|
+
// v0.8.33 expansion — newer Permissions-Policy feature names that
|
|
48
|
+
// weren't deny-by-default before. interest-cohort (FLoC, deprecated
|
|
49
|
+
// but still recognized), attribution-reporting (Privacy Sandbox),
|
|
50
|
+
// bluetooth / hid / serial (Web USB-shaped APIs), idle-detection,
|
|
51
|
+
// local-fonts (system-font fingerprinting), compute-pressure
|
|
52
|
+
// (CPU-load-side-channel), window-management (multi-screen probe),
|
|
53
|
+
// and the private-state-token-* family (Privacy-Pass-style anti-
|
|
54
|
+
// fraud tokens). Operators wanting any of these explicitly opt in
|
|
55
|
+
// by passing their own permissionsPolicy.
|
|
56
|
+
"interest-cohort=()", "attribution-reporting=()",
|
|
57
|
+
"bluetooth=()", "hid=()", "serial=()", "idle-detection=()",
|
|
58
|
+
"local-fonts=()", "compute-pressure=()", "window-management=()",
|
|
59
|
+
"private-state-token-issuance=()", "private-state-token-redemption=()",
|
|
47
60
|
];
|
|
48
61
|
|
|
49
62
|
// Strict CSP — no 'unsafe-inline' on script-src OR style-src.
|
package/lib/websocket.js
CHANGED
|
@@ -187,6 +187,19 @@ var DEFAULT_PING_INTERVAL_MS = C.TIME.seconds(30);
|
|
|
187
187
|
var DEFAULT_PONG_TIMEOUT_MS = C.TIME.seconds(35);
|
|
188
188
|
var CLOSE_GRACE_MS = C.TIME.seconds(2);
|
|
189
189
|
|
|
190
|
+
// RFC 6455 §7.4.2 close-code validity gate. Codes 0..999 MUST NOT
|
|
191
|
+
// appear on the wire. 1004 / 1005 / 1006 / 1015 are reserved
|
|
192
|
+
// (1005/1006 are local-only sentinels; 1004/1015 are reserved for
|
|
193
|
+
// future use). Codes 1000..1011 are spec-allocated. 3000..3999 are
|
|
194
|
+
// IANA-registered. 4000..4999 are private-use. Anything else is
|
|
195
|
+
// invalid.
|
|
196
|
+
function _isValidCloseCode(code) {
|
|
197
|
+
if (code === 1004 || code === 1005 || code === 1006 || code === 1015) return false; // allow:raw-byte-literal — RFC 6455 §7.4.2 reserved codes
|
|
198
|
+
if (code >= 1000 && code <= 1011) return true; // allow:raw-byte-literal — RFC 6455 §7.4.2 spec range / allow:raw-time-literal — code is a numeric, not seconds
|
|
199
|
+
if (code >= 3000 && code <= 4999) return true; // allow:raw-byte-literal — RFC 6455 §7.4.2 IANA / private range / allow:raw-time-literal — code is a numeric, not seconds
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
|
|
190
203
|
// Connection lifecycle states — mirrors the browser WebSocket API +
|
|
191
204
|
// the npm `ws` library. Single-source-of-truth field; every state
|
|
192
205
|
// transition goes through _transitionToClosed (or set in the
|
|
@@ -817,8 +830,25 @@ class WebSocketConnection extends EventEmitter {
|
|
|
817
830
|
|
|
818
831
|
_handleClose(frame) {
|
|
819
832
|
var code = CLOSE_NORMAL, reason = "";
|
|
833
|
+
// RFC 6455 §5.5.1 — close-frame body is either empty or 2+
|
|
834
|
+
// bytes (2-byte close code + optional UTF-8 reason). A 1-byte
|
|
835
|
+
// body is malformed; pre-v0.8.33 the framework silently
|
|
836
|
+
// accepted it as a clean close, evading anomaly detection
|
|
837
|
+
// that would have classified the malformation.
|
|
838
|
+
if (frame.payload.length === 1) {
|
|
839
|
+
return this._abort(CLOSE_PROTOCOL_ERROR,
|
|
840
|
+
"close frame payload must be 0 or >=2 bytes (RFC 6455 §5.5.1)");
|
|
841
|
+
}
|
|
820
842
|
if (frame.payload.length >= 2) {
|
|
821
843
|
code = frame.payload.readUInt16BE(0);
|
|
844
|
+
// RFC 6455 §7.4.2 — codes 0..999 MUST NOT be used. 1004 /
|
|
845
|
+
// 1005 / 1006 / 1015 are reserved (1005/1006 are local-only
|
|
846
|
+
// sentinels; 1004/1015 are reserved for future use).
|
|
847
|
+
// 1000-1011 + 3000-4999 are valid; everything else is invalid.
|
|
848
|
+
if (!_isValidCloseCode(code)) {
|
|
849
|
+
return this._abort(CLOSE_PROTOCOL_ERROR,
|
|
850
|
+
"close code " + code + " is reserved or invalid (RFC 6455 §7.4.2)");
|
|
851
|
+
}
|
|
822
852
|
if (frame.payload.length > 2) {
|
|
823
853
|
try { reason = new TextDecoder("utf-8", { fatal: true }).decode(frame.payload.subarray(2)); }
|
|
824
854
|
catch (_e) { return this._abort(CLOSE_INVALID_PAYLOAD, "close reason is not valid UTF-8"); }
|
package/package.json
CHANGED
package/sbom.cyclonedx.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:3be80324-29fb-478d-819e-0b32ffd604d7",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-05-07T15:
|
|
8
|
+
"timestamp": "2026-05-07T15:22:30.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.8.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.8.34",
|
|
23
23
|
"type": "library",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.8.
|
|
25
|
+
"version": "0.8.34",
|
|
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.8.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/core@0.8.34",
|
|
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.8.
|
|
57
|
+
"ref": "@blamejs/core@0.8.34",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|