Skip to content

Commit a0c8a45

Browse files
committed
chore: tighten template sandbox guard
1 parent 139c62e commit a0c8a45

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/pipeline/template.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export function resolvePath(pathStr: string, ctx: RenderContext): unknown {
190190
* Evaluate arbitrary JS expressions as a last-resort fallback.
191191
* Runs inside a `node:vm` sandbox with dynamic code generation disabled.
192192
*/
193-
const FORBIDDEN_EXPR_PATTERNS = /\b(__proto__|prototype|globalThis|process|require|import)\b/;
193+
const FORBIDDEN_EXPR_PATTERNS = /\b(constructor|__proto__|prototype|globalThis|process|require|import|eval)\b/;
194194

195195
/**
196196
* Deep-copy plain data to sever prototype chains, preventing sandbox escape
@@ -222,10 +222,10 @@ function evalJsExpr(expr: string, ctx: RenderContext): unknown {
222222
return vm.runInNewContext(
223223
`(${expr})`,
224224
{
225-
args,
226-
item,
227-
data,
228-
index,
225+
args,
226+
item,
227+
data,
228+
index,
229229
encodeURIComponent,
230230
decodeURIComponent,
231231
JSON,

0 commit comments

Comments
 (0)