@blamejs/core 0.5.5 → 0.5.6
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 +1 -0
- package/lib/break-glass.js +14 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,7 @@ upgrading across more than a few patches at a time.
|
|
|
8
8
|
|
|
9
9
|
## v0.5.x
|
|
10
10
|
|
|
11
|
+
- **0.5.5** (2026-04-30) — strict default CSP + IPv6 special-range expansion
|
|
11
12
|
- **0.5.4** (2026-04-30) — close SSRF DNS-rebinding window with pinned outbound DNS
|
|
12
13
|
- **0.5.3** (2026-04-30) — security cleanup: trustProxy primitive + Vary merge + HSTS gate
|
|
13
14
|
- **0.5.2** (2026-04-30) — b.breakGlass: passkey factor + service-account bypass + admin tools
|
package/lib/break-glass.js
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
*/
|
|
40
40
|
var audit = require("./audit");
|
|
41
41
|
var C = require("./constants");
|
|
42
|
+
var cache = require("./cache");
|
|
42
43
|
var clusterStorage = require("./cluster-storage");
|
|
43
44
|
var { generateBytes, generateToken, kdf, sha3Hash, encryptPacked, decryptPacked } = require("./crypto");
|
|
44
45
|
var cryptoField = require("./crypto-field");
|
|
@@ -76,6 +77,10 @@ var ALLOWED_REASON_STORAGE = ["cleartext", "hmac", "both"];
|
|
|
76
77
|
// Populated on first access per-table; invalidated on policy.set/delete.
|
|
77
78
|
var policyCache = new Map(); // table -> policy
|
|
78
79
|
var initialized = false;
|
|
80
|
+
// Framework-wide trustProxy setting (set at init). When true, the
|
|
81
|
+
// break-glass primitive consults X-Forwarded-For to populate the
|
|
82
|
+
// grant row's `ip` field — same trust boundary as middleware.
|
|
83
|
+
var _trustProxy = false;
|
|
79
84
|
|
|
80
85
|
// Factor lockout — wrap auth.lockout so a hostile actor brute-forcing
|
|
81
86
|
// TOTP codes against break-glass gets shut out after a few failures.
|
|
@@ -85,7 +90,6 @@ var _factorLockout = null;
|
|
|
85
90
|
var _factorLockoutCache = null;
|
|
86
91
|
function _ensureFactorLockout() {
|
|
87
92
|
if (_factorLockout) return _factorLockout;
|
|
88
|
-
var cache = require("./cache");
|
|
89
93
|
_factorLockoutCache = cache.create({
|
|
90
94
|
namespace: "breakglass.factor",
|
|
91
95
|
backend: "memory",
|
|
@@ -305,10 +309,12 @@ async function migrate(table, opts) {
|
|
|
305
309
|
|
|
306
310
|
function init(opts) {
|
|
307
311
|
opts = opts || {};
|
|
308
|
-
validateOpts(opts, ["now"], "breakGlass.init");
|
|
312
|
+
validateOpts(opts, ["now", "trustProxy"], "breakGlass.init");
|
|
309
313
|
initialized = true;
|
|
310
314
|
policyCache.clear();
|
|
311
315
|
_factorLockout = null;
|
|
316
|
+
_trustProxy = opts.trustProxy === true || typeof opts.trustProxy === "number"
|
|
317
|
+
? opts.trustProxy : false;
|
|
312
318
|
}
|
|
313
319
|
|
|
314
320
|
function _resetForTest() {
|
|
@@ -320,6 +326,7 @@ function _resetForTest() {
|
|
|
320
326
|
}
|
|
321
327
|
_factorLockout = null;
|
|
322
328
|
_factorLockoutCache = null;
|
|
329
|
+
_trustProxy = false;
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
function _requireInit() {
|
|
@@ -695,7 +702,11 @@ async function grant(opts) {
|
|
|
695
702
|
var nowMs = Date.now();
|
|
696
703
|
var grantId = "bg-" + generateToken(16);
|
|
697
704
|
var sessionId = (opts.req && opts.req.session && opts.req.session.id) || null;
|
|
698
|
-
|
|
705
|
+
// Honor the framework-wide trustProxy setting from init() — same
|
|
706
|
+
// boundary as middleware. Without trustProxy, X-Forwarded-For is
|
|
707
|
+
// ignored as attacker-forgeable, and the grant pins to the socket
|
|
708
|
+
// remoteAddress only.
|
|
709
|
+
var ipFromReq = requestHelpers.clientIp(opts.req, { trustProxy: _trustProxy });
|
|
699
710
|
|
|
700
711
|
var grantRow = {
|
|
701
712
|
_id: grantId,
|