Back to skill

Security audit

Agent Runtime

Security checks for vulnerabilities and agentic risk

Overview

This skill is an agent runtime prototype with powerful local file and shell capabilities, but its advertised permission and hook controls are not actually enforced.

Review before installing. Only use this in an isolated sandbox and do not rely on its advertised permissions, hooks, or agent types to protect files or commands. Avoid embedding it as a library until shell access is removed or gated, file access is scoped, hooks fail closed, and the CLI entry point is separated from imports.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (3)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/agent-runtime.mjs:134
Finding

Declared permission and hook controls are not enforced

Content
View full analysis

Vulnerability Details

File Location: scripts/agent-runtime.mjs:134-147, 193-199, 308-320
Vulnerability Type: Missing authorization and fail-open security hooks
Risk Level: High

Vulnerable Code

javascript
class SimpleHookRunner {
  constructor(config = {}) {
    this.preHooks = config.preToolUse || [];
    this.postHooks = config.postToolUse || [];
  }

  async runPreToolUse(toolName, input) {
    // Simplified implementation: always permit
    return { allowed: true, denied: false, messages: [] };
  }

  async runPostToolUse(toolName, input, output, isError) {
    return { allowed: true, denied: false, messages: [] };
  }
}
javascript
this.hookRunner = new SimpleHookRunner();
javascript
for (const match of matches.slice(0, 3)) {
  const tool = match.tool;

  // Pre Hook
  const preResult = await this.hookRunner.runPreToolUse(tool.name, {});
  if (preResult.denied) {
    output += `\n[${tool.name}] blocked by hook\n`;
    continue;
  }

  // Execute
  const result = await tool.execute({}, {});

Technical Analysis

The runtime presents permission and agentTypes properties as access-control metadata, but runTurn() never validates either property before executing a tool. The configured agentType therefore has no effect on authorization.

The pre-execution hook also always returns an allow decision. Although the hook runner stores preHooks and postHooks, it never invokes them. The runtime constructs the hook runner without passing hook configuration, and the documented addHook() API is not implemented.

This creates a fail-open authorization model: any tool selected by the search logic can proceed regardless of its declared permission level or the active agent type. A consuming application may incorrectly assume that an explore or plan agent cannot use tools marked as dangerous.

Attack Path

  1. An application creates ...[truncated 971 chars]
Remediation
View remediation

Remediation Suggestions

  • Implement a centralized authorization check before every tool invocation.
  • Validate this.config.agentType against tool.agentTypes; reject execution unless the active type is explicitly allowed.
  • Map permission levels to explicit caller capabilities and require authorization for write, danger, and admin tools.
  • Implement actual iteration over registered pre- and post-execution hooks.
  • Treat malformed hook responses, hook exceptions, missing policies, and unknown permission levels as denials.
  • Pass hook configuration into SimpleHookRunner and implement the documented addHook() interface.
  • Prevent callers from bypassing policy by directly invoking mutable registry entries. Expose a controlled execution method instead of raw tool configurations.
  • Add tests proving that restricted agent types cannot invoke dangerous tools and that hook denials prevent execution.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/agent-runtime.mjs:214
Finding

Unrestricted file-read and shell-execution tools expose host resources

Content
View full analysis

Vulnerability Details

File Location: scripts/agent-runtime.mjs:214-258
Vulnerability Type: Unrestricted file access and unsafe shell execution
Risk Level: High

Vulnerable Code

javascript
this.registry.register({
  name: 'read_file',
  aliases: ['read', 'cat'],
  description: 'Read file contents',
  permission: 'read',
  agentTypes: ['explore', 'plan', 'general'],
  keywords: ['file', 'read', '读取', '文件', '内容'],
  execute: async (ctx, input) => {
    const filePath = typeof input === 'string' ? input : input.path;
    if (!filePath) return { error: 'path required' };
    try {
      const content = fs.readFileSync(filePath, 'utf-8');
      return { success: true, content, size: content.length };
    } catch (e) {
      return { success: false, error: e.message };
    }
  }
});

this.registry.register({
  name: 'bash',
  aliases: ['shell', 'exec'],
  description: 'Execute Shell command',
  permission: 'danger',
  agentTypes: ['verification', 'general'],
  keywords: ['bash', 'shell', '命令', '执行', '终端'],
  execute: async (ctx, input) => {
    const { spawn } = await import('child_process');
    const command = typeof input === 'string' ? input : input.command;
    if (!command) return { error: 'command required' };

    return new Promise((resolve) => {
      const child = spawn('cmd', ['/C', command], { shell: true });
      let stdout = '', stderr = '';
      child.stdout.on('data', d => stdout += d);
      child.stderr.on('data', d => stderr += d);
      child.on('close', code => resolve({
        command,
        exitCode: code,
        stdout,
        stderr,
        success: code === 0
      }));
    });
  }
});

Technical Analysis

The file-reading tool accepts an arbitrary absolute or relative path and passes it directly to fs.readFileSync(). It performs no canonicalization, workspace-boundary validation, traversal rejecti ...[truncated 2307 chars]

Remediation
View remediation

Remediation Suggestions

  • Route all tool calls through a policy-enforcing execution method; do not expose raw executable tool objects to untrusted callers.
  • Resolve requested file paths with path.resolve() and verify that the canonical path remains inside an explicitly configured workspace root.
  • Reject absolute paths, traversal attempts, symbolic-link escapes, device paths, and access to sensitive files where they are unnecessary.
  • Apply least-privilege filesystem permissions to the runtime process.
  • Avoid invoking a shell. Use spawn() with a fixed executable and separately validated argument array.
  • If command execution is required, define an explicit allowlist of executables and arguments and require approval for dangerous operations.
  • Run command tools in an isolated container or sandbox with a restricted filesystem, environment, network, and operating-system account.
  • Add execution timeouts, process termination, output-size limits, concurrency limits, and error handlers.
  • Correct the mismatch between the verify agent-type constant and the shell tool's verification metadata, while also enforcing that metadata.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/agent-runtime.mjs:501
Finding

Importing the documented module unconditionally terminates the host process

Content
View full analysis

Vulnerability Details

File Location: scripts/agent-runtime.mjs:501-508
Vulnerability Type: Unsafe module initialization and denial of service
Risk Level: Medium

Vulnerable Code

The documented usage imports the module:

javascript
import { AgentRuntime } from './scripts/agent-runtime.mjs';

However, the module unconditionally runs its CLI entry point:

javascript
// ============ CLI Entry ============

const cliArgs = process.argv.slice(2);
if (cliArgs[0] === '--help' || cliArgs[0] === '-h') {
  printHelp();
} else {
  main(cliArgs).then(code => process.exit(code));
}

Technical Analysis

ES modules execute their top-level statements when imported. This file does not check whether it is being run as the main program before starting the CLI.

Consequently, importing AgentRuntime as shown in SKILL.md also interprets the embedding application's command-line arguments, invokes main(), and calls process.exit(). The exit terminates the entire Node.js process rather than only completing the imported module's work.

If the host process was started with arguments recognized by this CLI, the import may also trigger an unintended runtime command before termination.

Attack Path

  1. A server, agent host, test runner, or other Node.js application imports AgentRuntime according to the documented example.
  2. Top-level code reads the host application's process.argv.
  3. main(cliArgs) runs despite the module only being imported as a library.
  4. When the promise resolves, process.exit(code) terminates the host process.
  5. Repeated startup or request-triggered imports can cause repeated service outages where the deployment environment restarts the process.

Impact Assessment

This flaw can cause denial of service in any application that imports the module. The scope is the entire Node.js host process, including unrelated agents, active requests, in-memory stat ...[truncated 107 chars]

Remediation
View remediation

Remediation Suggestions

  • Guard CLI execution so it runs only when this file is the direct program entry point.
  • Compare import.meta.url with the URL for the invoked script before calling main().
  • Keep library exports free of top-level side effects.
  • Set process.exitCode in the CLI wrapper instead of calling process.exit() so pending cleanup can complete.
  • Move CLI handling into a separate executable module that imports the side-effect-free runtime library.
  • Add an automated test that imports AgentRuntime and verifies that the process remains active and no CLI output or commands are triggered.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (9)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 65)May include surrounding context.

md
import { AgentRuntime } from './scripts/agent-runtime.mjs';

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The runtime advertises permission control and hook interception, but the pre/post hook implementation always returns allowed and no code enforces tool permissions before execution. In an agent runtime context, this creates a false sense of security and allows dangerous tools such as shell execution to run without any policy gate, approval, or deny logic.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The built-in bash tool executes arbitrary user-influenced shell commands via child_process.spawn with no validation, sandboxing, allowlist, or approval step. Within an agent runtime, this is especially dangerous because natural-language input is used to select tools automatically, making remote code execution or destructive local actions possible if the runtime is exposed to untrusted prompts.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The natural-language description and heading are presented entirely in Chinese, with no indication that language is optional or selected based on user preference. This can violate language/locale policy when a skill implicitly forces a specific language without user opt-in or documented regional justification.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger phrases are broad and likely to activate on common user requests such as '创建Agent' or '运行Agent' without clear scoping, causing the skill to intercept conversations outside its intended domain. In an agent-runtime skill, unintended activation is more dangerous because it can influence tool orchestration, permissions, and sub-agent behavior at a high-control layer.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The top-level documentation states that Hook interception is part of the runtime's integrated functionality. But the pre-tool hook implementation is documented and coded as a simplified version that directly allows execution, which contradicts the claimed interception/control behavior in a security-relevant way.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The description promises context compression as part of the runtime. In code, compaction simply discards all but the most recent messages, which is loss of context rather than compression or summarization, so the implemented behavior is materially weaker than advertised.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Dangerous shell execution is reachable without an explicit confirmation or warning at the point of execution. In this runtime, tools are auto-selected from user text, so lack of a confirmation barrier materially increases the chance of accidental or prompt-induced execution of destructive commands.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

User-facing help text, status output, and prompts are presented in Chinese only, with no opt-in or locale selection. This creates a natural-language policy issue because the skill imposes a specific language on all users rather than allowing choice or documenting a justified locale restriction.

Content

No source excerpt is available for this finding.