Back to skill

Security audit

Code Runner Local

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed code runner, but it runs arbitrary snippets directly on the host without enforced isolation, so users should review it carefully before installing.

Install only if you specifically want an agent to run code locally and you will run it inside a contained environment with no sensitive files, secrets, or broad network access. Do not use it for untrusted snippets on your normal workstation or in a workspace containing credentials.

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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/run-code.cjs:135
Finding
Arbitrary User-Supplied Code Executes Directly on the Host Without Isolation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/run-code.cjs:135-166, 196-247`; related documentation at `SKILL.md:162-171` **Vulnerability Type**: Unsandboxed arbitrary code execution **Risk Level**: High ### Vulnerable Code ```js function executeCommand(command, timeout = DEFAULT_TIMEOUT) { return new Promise((resolve, reject) => { const startTime = Date.now(); const child = exec(command, { timeout: timeout, maxBuffer: 10 * 1024 * 1024, // 10MB buffer encoding: 'utf8' }, (error, stdout, stderr) => { const duration = Date.now() - startTime; if (error) { if (error.killed) { reject({ error: 'Execution timed out', duration, stderr: stderr || '' }); } else { reject({ error: error.message, duration, stderr: stderr || '', code: error.code }); } return; } resolve({ stdout: stdout || '', stderr: stderr || '', duration }); }); }); } ``` The user-controlled code is subsequently written to a file and executed: ```js // Handle interpreted languages tempFile = createTempFile(code, config.ext); const command = `${config.executor} "${tempFile}"`; return await executeCommand(command, timeout); ``` The supported executors include direct operating-system scripting facilities: ```js shellscript: { executor: 'bash', ext: 'sh' }, bash: { executor: 'bash', ext: 'sh' }, powershell: { executor: process.platform === 'win32' ? 'powershell -ExecutionPolicy ByPass -File' : 'pwsh -File', ext: 'ps1' }, bat: { executor: 'cmd /c', ext: 'bat' }, cmd ...[truncated 2539 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Run every snippet inside a new ephemeral container or equivalent operating-system sandbox. 2. Use a dedicated unprivileged account with no access to the host workspace, home directory, credentials, or service sockets. 3. Mount only a newly created working directory and make the container root filesystem read-only. 4. Disable outbound and inbound network access by default. Enable narrowly scoped network access only through explicit policy. 5. Remove inherited secrets and pass a minimal allowlisted environment to the sandbox. 6. Apply strict CPU, memory, file-size, process-count, and execution-time limits. 7. Drop Linux capabilities, enable `no-new-privileges`, and apply syscall filtering such as seccomp where supported. 8. Terminate the complete process group or container when execution finishes or times out, rather than killing only the immediate shell. 9. Require explicit user confirmation before executing shell, PowerShell, Batch, AppleScript, AutoHotkey, or other system-oriented languages. 10. Refuse to execute untrusted code when an approved isolation mechanism is unavailable. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run-code.cjs:119
Finding
Predictable Temporary Files Permit Symlink Overwrite and Local Race Attacks<![CDATA[ ## Vulnerability Details **File Location**: `scripts/run-code.cjs:119-124, 214-215` **Vulnerability Type**: Unsafe temporary-file creation **Risk Level**: Medium ### Vulnerable Code ```js function createTempFile(code, ext, customName = null) { const tmpDir = os.tmpdir(); const fileName = customName || `code_runner_${Date.now()}`; const filePath = path.join(tmpDir, `${fileName}.${ext}`); fs.writeFileSync(filePath, code, 'utf8'); return filePath; } ``` For Java, the extracted class name is used directly as the temporary filename: ```js const className = extractJavaClassName(code); tempFile = createTempFile(code, config.ext, className); ``` ### Technical Analysis Temporary source files are created directly in the shared system temporary directory. The ordinary filename contains only the current timestamp, making it predictable within a small search window. Java execution is even more predictable because a source file such as `/tmp/Main.java` or `/tmp/Test.java` is derived from the public class name. `fs.writeFileSync()` is used without exclusive creation and therefore opens an existing path for truncation. On platforms where the temporary directory is shared and symbolic links are followed, a local attacker can pre-create the expected path as a symbolic link to another file writable by the runner account. When the runner writes the submitted source code, it follows the link and overwrites the target. The same naming design also permits collisions between concurrent runner instances. Cleanup does not resolve the underlying issue because the target can already have been overwritten before cleanup occurs. ### Attack Path 1. A local attacker determines or predicts the temporary filename. For Java, the attacker can target a stable name such as `/tmp/Main.java`; for other languages, the attacker predicts timestamp-based names. 2. The attacker creates a symbolic link at that path pointing to a sensitive file writable by the victim ...[truncated 1072 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Create a private temporary directory for every invocation using `fs.mkdtempSync()` with a random suffix. 2. Set restrictive directory permissions so that only the runner account can access the directory. 3. Create source files with exclusive semantics, such as the `wx` flag, to prevent overwriting existing paths. 4. Do not place predictable class-name files directly in the shared system temporary directory. Put Java source and class files inside the private per-run directory. 5. Avoid timestamp-only identifiers; use cryptographically random names when additional temporary paths are required. 6. Validate that created paths are ordinary files inside the private directory and do not resolve through symbolic links. 7. Recursively remove the private directory in a `finally` block after terminating all processes that use it. 8. Apply sandbox isolation as described in the first finding, because secure temporary-file handling does not make arbitrary code safe to execute on the host. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (12)

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
echo "<code>" | node scripts/run-code.cjs <languageId>
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Missing User Warnings

High
Confidence
99% confidence
Finding
This script accepts arbitrary user-supplied code, writes it to a temporary file, and executes it across many interpreters/compilers using child_process with no sandboxing, privilege separation, or policy restrictions. In an agent skill context, that creates a direct remote code execution capability on the host environment, enabling file access, network access, process spawning, credential theft, persistence attempts, or lateral movement depending on runtime permissions.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The skill description is very broad and covers many common programming-assistance scenarios, which increases the chance an agent will invoke it by default for ordinary coding requests. Because this skill executes arbitrary code across many languages, over-broad routing materially raises the risk of unsafe code execution from untrusted user input or from contexts where execution was not necessary.

Static analysis

Detected: suspicious.dangerous_exec

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
scripts/run-code.cjs:140