@zvenigora/ng-eval-core 0.12.0 → 0.12.1

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,7 +14,122 @@ Versions 0.1.104–0.1.107 are on npm without entries here.
14
14
 
15
15
  ---
16
16
 
17
- ## [0.12.0] - 2026-10-13
17
+ ## [0.12.1] - 2026-10-17
18
+
19
+ **Partial hardening of the call sandbox, which does not close every route, so keep
20
+ [`SECURITY.md`'s mitigations](../../SECURITY.md#mitigations) in place whatever the version.** A
21
+ tagged template's tag goes through the call sandbox ([A36](../../docs/backlog-retired.md#a36)), and
22
+ a dangerous function value is refused at the call, `new` and tag sites and at every other read the
23
+ walk makes but `typeof`'s operand ([A35](../../docs/backlog.md#a35)). A sequence leaves one value on
24
+ the stack ([A37](../../docs/backlog-retired.md#a37)). Two routes past the walk's own values stay
25
+ open: a container the host provides, which stays a limit, and a route through `this`, which 0.13.0
26
+ closes. The Security entry below states both, and `SECURITY.md`'s
27
+ [documented limits](../../SECURITY.md#documented-limits) give the rest. It is a patch although an
28
+ expression that reads a dangerous function now throws where it used to give a value: none of the
29
+ three packages' existing cases reads one, and the defect is a security one. No exported symbol
30
+ changes shape: the `.d.ts` is byte-identical to 0.12.0's. `eval-signals` 0.5.1 and `eval-forms` 0.5.0 admit it: their peer
31
+ ranges are `>=0.11.0 <0.13.0` and `>=0.12.0 <0.13.0`.
32
+
33
+ ### Fixed
34
+ - **A sequence leaves exactly one value on the stack, and shows one node to hooks —
35
+ [A37](../../docs/backlog-retired.md#a37).** No visitor was registered for `SequenceExpression`, so
36
+ the walk left every value but the last on the stack: `(0, 1)` left one entry and `((1, 2), 3)` two.
37
+ Within one walk, a `for` loop whose update is a sequence (`i++, j--`) left one entry per iteration,
38
+ and an arrow body `x => (a, b)` one per call, and a reused state accumulated them all. No hook saw
39
+ the node. Every published version up to 0.12.0 is affected.
40
+ - **No residual stack values**: each sequence leaves only its own value, so a reused state no
41
+ longer accumulates anything.
42
+ - **One `before` and one `after` node-hook event per sequence**, the `after` carrying the last
43
+ value, where there were none. So under `trackTime`, `nodeTimings` gains a `SequenceExpression`
44
+ entry.
45
+ - **One trace entry per sequence**, carrying the last value, where there was none. So
46
+ `tracePushCount` counts one more per sequence, and `traceTruncated` can be set on a walk that
47
+ used to fit under `maxTraceItems`.
48
+ - **Evaluated values are unchanged.** A sequence's value was already its last expression's, since
49
+ each consumer reads only the top of the stack.
50
+
51
+ ### Security
52
+ - **A tagged template's tag goes through the call sandbox and the write policy —
53
+ [A36](../../docs/backlog-retired.md#a36).** The visitor applied the tag with no check at all, so
54
+ with `Function` in the context `` Function`return 7`() `` gave 7. Every published version up to
55
+ 0.12.0 is affected.
56
+ - **Now refused**, with the call's message `Function call blocked for security reasons: <name>`:
57
+ a tag the call sandbox refuses, by its written name, by `Function`'s identity, or by the
58
+ source-pattern test. A member tag is checked under its property name, a computed key included,
59
+ as a member call is, so `` obj["fetch"]`x` `` is refused as `obj["fetch"]()` is.
60
+ - **Now asked**: a context's `checkMemberWrite`, before a tag that is a built-in writing into its
61
+ receiver or its first argument, as before such a call.
62
+ - **A member tag's `this` is now its object**, or a prior scope's `thisArg`, as a member call's
63
+ is. It was the evaluation context. So a mutating built-in used as a member tag writes into its
64
+ object: `` a.push`x` `` now appends to `a`, where it wrote into the context. Any other tag's
65
+ `this` is still the context, as a bare call's is.
66
+ - **A member tag raises no `before` or `after` node-hook events, and leaves no trace entry, for
67
+ its own `MemberExpression` node**, as a member call's callee already does. Its read event is
68
+ unchanged.
69
+ - **A tag that is not a function** throws the call's error, `Cannot call undefined or null
70
+ function` or `Value is not a function: <type>`. It threw a `TypeError` from `apply`.
71
+ - **A call, `new` or tagged template whose callee is a dangerous function is refused by its value,
72
+ under any name — [A35](../../docs/backlog.md#a35).** The sandboxes read the callee's written name,
73
+ so with `eval` in the context as `run`, `run("1+1")` gave 2. `new`'s list of names never held the
74
+ timers either. In a browser application with zone.js, `new setTimeout("<code>", 0)` constructed
75
+ under the timer's own name, and zone.js handed the string to the browser's timer, which runs it
76
+ unless a CSP forbids `unsafe-eval`. Every published version up to 0.12.0 is affected.
77
+ - **A listed value** is one of the realm's dangerous functions, matched by identity: the global
78
+ value of each name the call sandbox refuses, where the realm has it, and zone.js's saved
79
+ original of each; and `GeneratorFunction`, `AsyncFunction` and `AsyncGeneratorFunction`, read
80
+ from function literals, where they are not `Function` itself. A bound function is a listed value
81
+ too when its name, stripped of every `bound ` prefix, is one of those names.
82
+ - **Now refused**, with the site's existing message, `Function call blocked for security
83
+ reasons: <name>` or `Constructor blocked for security reasons: <name>`: a callee whose value is
84
+ a listed value, under any name. That covers an alias, a member, a call result, `this.k`, a scope
85
+ namespace, a destructured name, an optional call, a case variant under `caseInsensitive`, and
86
+ `new setTimeout(…)` or `new setInterval(…)` under the timer's own name. The name is the written
87
+ name, the property name, or `anonymous`. A callee under which the listed value is read takes
88
+ the read's message instead, from the entry below, since the value is refused where it is read,
89
+ before the call. Such a callee is a sequence, a conditional, a logical, an assignment, or a
90
+ parenthesised or optional-chain expression.
91
+ - **Every read of a dangerous function the walk makes is refused, except as a callee, a tag or
92
+ `typeof`'s operand — [A35](../../docs/backlog.md#a35).** The call sandbox checked only the
93
+ callee, so a listed value handed on as anything else reached the native code that calls it. With
94
+ `eval` in the context, `["1+1"].map(eval)` gave `[2]` and `eval.call(null, "1+1")` gave 2. With
95
+ `Function`, `Function.call(null, "return 7")()` gave 7. Every published version up to 0.12.0 is
96
+ affected.
97
+ - **The rule.** Whenever the walk reads a listed value, as defined above, it throws
98
+ `Access to dangerous function "<name>" is blocked for security reasons`. The name is the
99
+ identifier, the member's property name, or the function's own `name`. Among the reads that
100
+ hand it on:
101
+ - an argument;
102
+ - the receiver of `call`, `apply` or `bind`;
103
+ - an element of an array or a property of an object the expression builds;
104
+ - a branch of a conditional or a logical;
105
+ - the last expression of a sequence used as a callee, a constructor or a tag;
106
+ - a parenthesised callee under `preserveParens`;
107
+ - the expression's own result.
108
+ - **Reads that only inspect the value throw too**, since the rule has no exception for them:
109
+ - assigning over a listed function, `fetch = 1` or `obj.fetch = 1`, since an assignment reads
110
+ its target before writing it;
111
+ - updating one, `obj.fetch++`, which writes first and then throws, so the failed evaluation
112
+ leaves its write behind ([A40](../../docs/backlog.md#a40));
113
+ - an operator's operand, `x instanceof Function` or `obj.fetch != null`;
114
+ - a conditional's test, `obj.fetch ? 1 : 0`;
115
+ - a template interpolation, `` `${eval}` ``, and a declaration's initializer;
116
+ - `typeof (eval)` under `preserveParens`, whose operand is the parenthesis, not the identifier.
117
+ - **Not refused.** A callee or a tag itself is refused by the entry above, with its site's
118
+ message. `typeof`'s operand is exempt, so `typeof eval` is still `"function"`. Only that node
119
+ itself is exempt, never what is under it: in `(0, eval)("1+1")` the callee is the sequence, so
120
+ the read of `eval` inside it is refused.
121
+ - **Not covered: two routes by which a listed value reaches native code without passing through
122
+ the walk's own values.** So this release is partial hardening.
123
+ - **A container the host provides**, whose elements are spread into a native call.
124
+ - **A route through `this`**, which 0.13.0 closes.
125
+
126
+ `SECURITY.md` states both as limits. It gives the mitigations that hold whatever the route:
127
+ a host places no listed function in the context, and in a browser, a Content Security Policy
128
+ without `'unsafe-eval'` stops `eval`, `Function` and a string timer.
129
+
130
+ ---
131
+
132
+ ## [0.12.0] - 2026-10-14
18
133
 
19
134
  **Colon-joined names, opt-in — Phase 9 ([plan](../../docs/colon-identifiers/phase-9-plan.md)) — and
20
135
  a parse cache that honours the options it is asked with.** A minor: two additions, the