Back to skill

Security audit

XPR Code Sandbox

Security checks for vulnerabilities and agentic risk

Overview

The skill is meant for JavaScript computation, but its sandbox boundary is flawed and can expose the host process despite promising no process, filesystem, or network access.

Review carefully before installing. This skill should only run JavaScript you fully trust, or it should be fixed to use stronger isolation before being treated as a safe sandbox for arbitrary code.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
src/index.ts:38
Finding

Host-Realm Constructors Permit JavaScript Sandbox Escape

Content
View full analysis
{ // Capture console methods const consoleMock = { log: (...args: unknown[]) => { logs.push(args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ')); }, warn: (...args: unknown[]) => { logs.push('[warn] ' + args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ')); }, error: (...args: unknown[]) => { logs.push('[error] ' + args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ')); }, }; return { INPUT: input, console: consoleMock, JSON, Math, Date, Array, Object, String, Number, RegExp, Map, Set, parseInt, parseFloat, isNaN, isFinite, encodeURIComponent, decodeURIComponent, atob: (s: string) => Buffer.from(s, 'base64').toString('binary'), btoa: (s: string) => Buffer.from(s, 'binary').toString('base64'), // Explicitly undefined — blocked require: undefined, process: undefined, globalThis: undefined, global: undefined, }; } ``` The globals are then placed into contexts that execute user-controlled code: ```ts const globals = createSandboxGlobals(input, logs); const context = vm.createContext(globals, { codeGeneration: { strings: false, wasm: false }, }); // Wrap code so the last expression is returned const wrapped = `(function() {\n${code}\n})()`; const script = new vm.Script(wrapped, { filename: 'sandbox.js' }); const result = script.runInContext(context, { timeout: timeoutMs }); ``` The same vulnerable globals are used by `eval_expression`: ```ts const globals = createSandboxGlobals(undefined, []); co ...[truncated 4031 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep

Static analysis

Detected: suspicious.dynamic_code_execution

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
src/index.ts:159