From ed89c45b326d0de9ddd840ca5e2c25461870df73 Mon Sep 17 00:00:00 2001 From: anupamme Date: Fri, 11 Sep 2026 00:31:49 +0000 Subject: [PATCH] fix: V-002 security vulnerability Automated security fix generated by OrbisAI Security --- commands/eval.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/commands/eval.mjs b/commands/eval.mjs index c22f736..7afa627 100644 --- a/commands/eval.mjs +++ b/commands/eval.mjs @@ -158,7 +158,12 @@ async function runEval(expression, context) { ? `return (${expression});` : expression; - result = await eval(`(async function() { ${code} })`).call(context); + // Build the async function via the AsyncFunction constructor instead of eval(), + // and shadow dangerous globals as parameters so evaluated code cannot trivially + // reach the Node.js runtime (require, process.binding, etc.) even if owner + // credentials are compromised. + const AsyncFunction = Object.getPrototypeOf(async function() {}).constructor; + result = await new AsyncFunction("process", "require", "module", "global", "globalThis", "__dirname", "__filename", code).call(context); type = result === null ? "null" : typeof result; } catch (e) { result = e;