@zvenigora/ng-eval-core 0.8.0 → 0.9.0
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
CHANGED
|
@@ -14,6 +14,34 @@ Versions 0.1.104–0.1.107 are on npm without entries here.
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
+
## [0.9.0] - 2026-10-02
|
|
18
|
+
|
|
19
|
+
**A primitive receiver no longer skips the prototype-pollution guard —
|
|
20
|
+
[B1](../../docs/backlog-retired.md#b1).** A breaking minor. No exported symbol changes shape, but an
|
|
21
|
+
expression that read one of seven names off a string, number or boolean now throws.
|
|
22
|
+
`eval-signals` 0.2.1 and `eval-forms` 0.2.7 widen their peer ranges to admit it.
|
|
23
|
+
|
|
24
|
+
### Breaking
|
|
25
|
+
- **A string, number or boolean receiver is refused `constructor`, `__proto__`, `prototype`,
|
|
26
|
+
`__defineGetter__`, `__defineSetter__`, `__lookupGetter__` and `__lookupSetter__`**, by dot or
|
|
27
|
+
computed access, with or without `caseInsensitive`, with the error any other blocked name
|
|
28
|
+
throws: `Access to dangerous property "constructor" is blocked for security reasons`. Why: the
|
|
29
|
+
member visitor skipped the guard entirely for a primitive receiver, so `s.constructor` handed
|
|
30
|
+
back the global `String` function — callable, `s.constructor("x")` — and `s.__proto__` handed
|
|
31
|
+
back `String.prototype`, with `n.__proto__.toFixed.call(1.5, 0)` running off it. No escalation
|
|
32
|
+
past that was found (every second hop to a dangerous name was already refused, and so was every
|
|
33
|
+
write to a built-in prototype), but nothing an expression needs from a primitive goes through
|
|
34
|
+
its constructor or its prototype.
|
|
35
|
+
- **Kept readable on a primitive:** `toString`, `valueOf`, `toLocaleString`, `hasOwnProperty`,
|
|
36
|
+
`isPrototypeOf` and `propertyIsEnumerable`. They are on the blocklist for objects, but on a
|
|
37
|
+
primitive they are ordinary reads — `s.toString()`, `n.toLocaleString()`,
|
|
38
|
+
`s.hasOwnProperty("length")` work as before, as do `s.length` and `s.toUpperCase()`.
|
|
39
|
+
- **A case variant is not refused.** The names are matched exactly, and a primitive receiver is
|
|
40
|
+
never case-corrected, so under `caseInsensitive` `s.CONSTRUCTOR` is a missing property and
|
|
41
|
+
evaluates to `undefined`, as it did in 0.8.0.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
17
45
|
## [0.8.0] - 2026-10-02
|
|
18
46
|
|
|
19
47
|
**`EvalContext.getKey` resolves through `get`'s own chain —
|
|
@@ -1204,6 +1204,27 @@ const DANGEROUS_PROPERTY_NAMES = new Set([
|
|
|
1204
1204
|
'valueOf',
|
|
1205
1205
|
'toLocaleString'
|
|
1206
1206
|
]);
|
|
1207
|
+
/**
|
|
1208
|
+
* The subset of DANGEROUS_PROPERTY_NAMES refused on a string, number or
|
|
1209
|
+
* boolean receiver: the names that reach a global constructor, a built-in
|
|
1210
|
+
* prototype or an accessor definer. The other six - `toString`, `valueOf`,
|
|
1211
|
+
* `toLocaleString`, `hasOwnProperty`, `isPrototypeOf`,
|
|
1212
|
+
* `propertyIsEnumerable` - are ordinary reads on a primitive and stay
|
|
1213
|
+
* readable.
|
|
1214
|
+
*
|
|
1215
|
+
* Matched by exact key, under `caseInsensitive` too: a primitive receiver is
|
|
1216
|
+
* never case-corrected, so a variant such as `s.CONSTRUCTOR` is a missing
|
|
1217
|
+
* property, not a route to `String`.
|
|
1218
|
+
*/
|
|
1219
|
+
const DANGEROUS_PRIMITIVE_PROPERTY_NAMES = new Set([
|
|
1220
|
+
'__proto__',
|
|
1221
|
+
'constructor',
|
|
1222
|
+
'prototype',
|
|
1223
|
+
'__defineGetter__',
|
|
1224
|
+
'__defineSetter__',
|
|
1225
|
+
'__lookupGetter__',
|
|
1226
|
+
'__lookupSetter__'
|
|
1227
|
+
]);
|
|
1207
1228
|
/**
|
|
1208
1229
|
* Set of constructor names that should be blocked from modification
|
|
1209
1230
|
*/
|
|
@@ -1230,6 +1251,17 @@ const isDangerousProperty = (key) => {
|
|
|
1230
1251
|
}
|
|
1231
1252
|
return false;
|
|
1232
1253
|
};
|
|
1254
|
+
/**
|
|
1255
|
+
* Checks if a property name is dangerous on a primitive receiver
|
|
1256
|
+
* @param key The property name to check
|
|
1257
|
+
* @returns true if the property is in the primitive subset, false otherwise
|
|
1258
|
+
*/
|
|
1259
|
+
const isDangerousPrimitiveProperty = (key) => {
|
|
1260
|
+
if (typeof key === 'string') {
|
|
1261
|
+
return DANGEROUS_PRIMITIVE_PROPERTY_NAMES.has(key);
|
|
1262
|
+
}
|
|
1263
|
+
return false;
|
|
1264
|
+
};
|
|
1233
1265
|
/**
|
|
1234
1266
|
* Checks if an object is a dangerous constructor that shouldn't be modified
|
|
1235
1267
|
* @param obj The object to check
|
|
@@ -1624,12 +1656,16 @@ const evaluateMember = (node, st, callback) => {
|
|
|
1624
1656
|
// The key the lookup actually matched, reported to the read hooks. The
|
|
1625
1657
|
// returned tuple keeps the original `key`; only the event is corrected.
|
|
1626
1658
|
let resolvedKey = key;
|
|
1627
|
-
//
|
|
1659
|
+
// A primitive receiver (string, number, boolean) is checked against the
|
|
1660
|
+
// primitive subset of the blocklist: `toString` and its kin are ordinary
|
|
1661
|
+
// reads on it, while `constructor`, `__proto__` and the accessor definers
|
|
1662
|
+
// would reach its global constructor and built-in prototype
|
|
1628
1663
|
const isPrimitive = (typeof object === 'string' || typeof object === 'number' || typeof object === 'boolean');
|
|
1629
1664
|
if (st.options?.caseInsensitive && typeof key === 'string') {
|
|
1630
|
-
// Use case-insensitive lookup but with prototype pollution protection
|
|
1631
|
-
//
|
|
1632
|
-
|
|
1665
|
+
// Use case-insensitive lookup but with prototype pollution protection.
|
|
1666
|
+
// A primitive is checked by exact key: it is never case-corrected below,
|
|
1667
|
+
// so a variant such as `s.CONSTRUCTOR` reads as a missing property
|
|
1668
|
+
if (isPrimitive ? isDangerousPrimitiveProperty(key) : isDangerousProperty(key)) {
|
|
1633
1669
|
throw new Error(`Access to dangerous property "${key}" is blocked for security reasons`);
|
|
1634
1670
|
}
|
|
1635
1671
|
// Try case-insensitive lookup on own properties first
|
|
@@ -1676,7 +1712,8 @@ const evaluateMember = (node, st, callback) => {
|
|
|
1676
1712
|
}
|
|
1677
1713
|
// Get the value using the found key or use safeGetProperty fallback for non-primitives
|
|
1678
1714
|
if (isPrimitive) {
|
|
1679
|
-
// For primitives, direct
|
|
1715
|
+
// For primitives, a direct read: the key passed the primitive subset's
|
|
1716
|
+
// check above, and the lookup block never ran, so foundKey is unset
|
|
1680
1717
|
value = foundKey ? obj[foundKey] : obj[key];
|
|
1681
1718
|
}
|
|
1682
1719
|
else {
|
|
@@ -1688,9 +1725,12 @@ const evaluateMember = (node, st, callback) => {
|
|
|
1688
1725
|
}
|
|
1689
1726
|
}
|
|
1690
1727
|
else {
|
|
1691
|
-
// Use safe property access for prototype pollution protection
|
|
1728
|
+
// Use safe property access for prototype pollution protection; a
|
|
1729
|
+
// primitive gets a direct read, after the primitive subset's check
|
|
1692
1730
|
if (isPrimitive) {
|
|
1693
|
-
|
|
1731
|
+
if (isDangerousPrimitiveProperty(key)) {
|
|
1732
|
+
throw new Error(`Access to dangerous property "${String(key)}" is blocked for security reasons`);
|
|
1733
|
+
}
|
|
1694
1734
|
value = object[key];
|
|
1695
1735
|
}
|
|
1696
1736
|
else {
|