Back to skill

Security audit

Token Optimizer 1.0.0

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly a workflow helper, but its instructions include unsafe shell-based diagnostics and forceful process-kill examples that deserve review before use.

Install only if you are comfortable reviewing or rewriting the example code before use. Do not let an agent pass user-supplied ports or process names into the shell examples as written, and require confirmation before any process termination. Expect checkpoint data to be saved locally if the checkpoint example is used.

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
SKILL.md:154
Finding

OS Command Injection in Diagnostic Helpers

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 154–158 and 170–174
Vulnerability Type: OS command injection through unvalidated shell interpolation
Risk Level: High

Vulnerable Code

javascript
checkPort(port) {
    try {
        const isWindows = process.platform === 'win32';
        const cmd = isWindows 
            ? `netstat -ano | findstr :${port}`
            : `lsof -i :${port}`;
        const output = execSync(cmd, { encoding: 'utf-8', timeout: this.config.timeout });
javascript
checkProcess(processName) {
    try {
        const isWindows = process.platform === 'win32';
        const cmd = isWindows
            ? `powershell -Command "Get-Process -Name '${processName}' -ErrorAction SilentlyContinue | Select-Object Id"`
            : `pgrep -x "${processName}"`;
        const output = execSync(cmd, { encoding: 'utf-8' });

Technical Analysis

The checkPort() and checkProcess() methods interpolate port and processName directly into command strings passed to child_process.execSync(). Neither value is validated, constrained to an expected format, nor safely escaped.

Because execSync() executes the resulting string through a command shell, shell metacharacters embedded in either argument can alter the intended command structure. Although checkFile() performs limited input validation, equivalent controls are absent from these command-execution methods.

The code appears as an implementation example in the skill document. The vulnerability becomes exploitable when an agent or developer copies or implements the documented component and passes untrusted task input to these methods.

Attack Path

  1. An attacker supplies a crafted port value or process name through a task, configuration, API parameter, or other input consumed by the diagnostic helper.
  2. The value is passed to checkPort() or checkProcess().
  3. The method inserts the val ...[truncated 838 chars]
Remediation
View remediation

Remediation Suggestions

  1. Replace shell-based execSync() calls with execFileSync() or spawnSync() and provide arguments as an array with shell execution disabled.
  2. Validate ports as integers and require the inclusive range 1–65535.
  3. Apply a strict allowlist to process names, permitting only characters required by supported platforms, such as letters, digits, periods, underscores, and hyphens.
  4. Reject values containing whitespace, quotes, command separators, redirection operators, substitutions, or other shell metacharacters.
  5. Set explicit timeouts and output-size limits for every child process, including checkProcess().
  6. Return an explicit validation error rather than treating every command failure as proof that a port is available or a process is absent.
  7. Add security tests covering malformed values and shell-injection payloads on Windows and Unix-like platforms.

A safer pattern is:

javascript
const { execFileSync } = require('child_process');

function validatePort(port) {
    const value = Number(port);
    if (!Number.isInteger(value) || value < 1 || value > 65535) {
        throw new TypeError('Port must be an integer between 1 and 65535');
    }
    return String(value);
}

function validateProcessName(processName) {
    if (
        typeof processName !== 'string' ||
        !/^[A-Za-z0-9._-]{1,255}$/.test(processName)
    ) {
        throw new TypeError('Invalid process name');
    }
    return processName;
}

// Unix-like examples; use platform-specific executable arguments on Windows.
const output = execFileSync(
    'lsof',
    ['-i', `:${validatePort(port)}`],
    { encoding: 'utf-8', timeout: 5000 }
);

const processOutput = execFileSync(
    'pgrep',
    ['-x', validateProcessName(processName)],
    { encoding: 'utf-8', timeout: 5000 }
);
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (6)

Tp2

High
Category
MCP Tool Poisoning
Confidence
85% confidence
Finding

Mixing characters from multiple Unicode scripts in a single identifier is a common technique to create visually ambiguous tool names.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill name and description are entirely in Chinese, and the rest of the document consistently presents usage instructions only in Chinese. There is no indication that users can choose another language or that the skill is intentionally limited to a Chinese-speaking or region-specific context, which creates a language/locale policy concern.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The PreChecker executes host shell commands via execSync to inspect ports and processes. Even though the shown examples are diagnostic, this exceeds a documentation-only workflow controller and creates command-execution risk if parameters like port or processName are influenced by untrusted input, especially because shell metacharacter injection is possible in the constructed commands.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The documentation recommends forceful process termination commands such as Stop-Process -Force without warning about disruption, data loss, or accidental termination of the wrong process. In an agent skill context, operational guidance can be executed or copied directly, making unsafe destructive instructions more dangerous than ordinary prose.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The appendix again lists forceful termination commands without guardrails, which normalizes destructive actions as routine troubleshooting. Repetition in a quick-reference section increases the chance of blind execution and unintended service interruption.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The Checkpoint component persists state to disk without that storage behavior being declared in the skill's manifest or user-facing scope. Undeclared persistence can leak task metadata, create privacy/compliance issues, and surprise users who expect an in-memory workflow helper only.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.