Back to skill

Security audit

Safe Shell

Security checks for vulnerabilities and agentic risk

Overview

This skill is meant to make shell use read-only, but its command validator can approve unsafe command strings and it also permits broad environment-variable disclosure.

Review this carefully before installing. The skill's goal is useful, but do not rely on it as a hard safety boundary for shell execution unless the validator is fixed to parse structured commands, reject all shell control syntax, remove or redact environment-variable dumps, and use a pinned, verifiable installer.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
safe-shell.js:62
Finding
Shell command validation can be bypassed through unhandled control operators<![CDATA[ ## Vulnerability Details **File Location**: `safe-shell.js:62-75` **Additional Relevant Location**: `safe-shell.js:100-105`, `SKILL.md:185` **Vulnerability Type**: Command validation bypass and potential shell injection **Risk Level**: High ### Vulnerable Code ```javascript // Check allowlist (must appear at the start of the command) const isAllowed = ALLOWED_COMMANDS.some(cmd => trimmed === cmd || trimmed.startsWith(cmd + ' ') || trimmed.startsWith(cmd + '\t') ); if (!isAllowed) { return { safe: false, reason: 'Command is not in the allowlist', blocked: false }; } return { safe: true }; ``` The approved, unchanged command is subsequently displayed for execution by a separate tool: ```javascript console.log(`Approved command: ${command}`); console.log('Actual execution must be performed through the exec tool'); ``` ### Technical Analysis The allowlist only verifies that the supplied string begins with an approved executable name. It does not parse the command into an executable and arguments, nor does it comprehensively reject shell syntax. The blocked-pattern list does not prohibit all of the following constructs: - Semicolon command sequencing - `&&` and `||` conditional execution - Arbitrary pipelines - Command substitution - Relative-path output redirection - Shell-specific expansion and quoting behaviors Consequently, input beginning with an allowed command can contain an additional unapproved operation. The complete string is then presented as approved and intended to be passed to an external execution tool. This also contradicts the documentation in `SKILL.md:185`, which states that command chains such as `;`, `&&`, and `||` are blocked. The JavaScript file does not directly execute the command, so exploitation depends on an agent or downstream component trusting the validator and passing the approved string to a shell. That downstream behavior is explicitly contemplated by the program's execution message. # ...[truncated 1362 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not pass user-controlled command strings to a shell. 2. Parse requests into a fixed executable and a structured argument array. 3. Invoke the executable with shell processing disabled, for example through `spawn()` or `execFile()` with `shell: false`. 4. Create a separate argument schema for every allowed command. Reject flags that can execute programs, write files, load plugins, or reference unsafe pseudo-filesystems. 5. Reject all shell control operators, including pipes, semicolons, redirections, command substitution, newlines, `&&`, and `||`. 6. Resolve the executable to an explicitly trusted absolute path rather than relying on a potentially attacker-controlled `PATH`. 7. Apply execution limits, including timeouts, output limits, and a restricted working directory. 8. Add regression tests for command chaining, newline injection, command substitution, pipelines, redirection, quoting edge cases, and platform-specific shell syntax. 9. Correct the documentation so that it accurately reflects implemented safeguards. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
safe-shell.js:18
Finding
Unrestricted environment-variable enumeration can expose credentials<![CDATA[ ## Vulnerability Details **File Location**: `safe-shell.js:18` **Additional Relevant Location**: `SKILL.md:79` **Vulnerability Type**: Excessive access to sensitive process configuration **Risk Level**: Medium ### Vulnerable Code ```javascript 'whoami', 'hostname', 'uname', 'id', 'env', 'locale' ``` The documentation also explicitly permits complete environment enumeration through platform-specific commands: ```markdown | `env` / `printenv` | `set` / `Get-ChildItem Env:` | Environment variables | ``` ### Technical Analysis The `env` command is included in the allowlist without restrictions. The documentation similarly authorizes `printenv`, Windows `set`, and PowerShell environment-provider enumeration. Environment variables frequently contain sensitive material, including: - API keys and bearer tokens - Cloud-provider credentials - Database connection strings - Package-registry tokens - Internal service endpoints - Proxy credentials - Session-specific secrets Although reading environment variables does not modify the system, unrestricted secret enumeration exceeds the minimum privileges needed for general file viewing, monitoring, and network diagnostics. Classifying a command as read-only does not make its output non-sensitive. ### Attack Path 1. An attacker embeds a request to inspect the runtime environment in a prompt or diagnostic task. 2. The agent invokes `env`, which is explicitly approved by the allowlist. 3. The process returns every environment variable visible to the agent account. 4. Secret values become available in the agent's context, logs, transcript, or tool output. 5. The exposed credentials may subsequently be reused against services for which they are valid. This project contains no direct network-exfiltration implementation. Exfiltration would require another available channel or later attacker access to the transcript or logs. ### Impact Assessment The issue may disclose every environment variable inherited by th ...[truncated 439 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove `env` from the executable allowlist. 2. Remove unrestricted `printenv`, `set`, and `Get-ChildItem Env:` from documented allowed operations. 3. If environment diagnostics are essential, expose only an explicit allowlist of non-sensitive variable names. 4. Redact values when names contain secret-related terms such as `TOKEN`, `KEY`, `SECRET`, `PASSWORD`, `CREDENTIAL`, or `AUTH`. 5. Prefer returning whether a required variable exists rather than returning its value. 6. Prevent sensitive tool output from being persisted in logs or conversation history. 7. Run the Skill with a sanitized environment containing only variables required for its declared functionality. ]]>

T08 · Insecure Dependencies

Warning
Location
SKILL.md:12
Finding
Installation executes an unpinned package from a mutable release tag<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:12` **Additional Relevant Location**: `SKILL.md:3` **Vulnerability Type**: Unsafe third-party package installation and execution **Risk Level**: Medium ### Vulnerable Code ```bash npx clawhub@latest install safe-shell ``` ### Technical Analysis The installation instruction invokes `npx` using the mutable `latest` tag. `npx` can retrieve and execute package code from the configured npm registry. Because `latest` can point to a different release at any time, the code executed during future installations is not fixed to the version reviewed in this audit. The project does not provide a lockfile, integrity hash, exact package version, or other mechanism that binds the installation instruction to a specific audited artifact. Compromise of the publisher account, registry distribution path, package, or dependency chain could therefore turn the installation process into arbitrary code execution. This is distinct from the pre-scan warning about `curl | sh`. The `curl | sh` and `wget | bash` text at `SKILL.md:99` appears only as escaped examples in a table of forbidden commands; it is not an installation instruction and is not itself a vulnerability. ### Attack Path 1. An attacker compromises the package publisher, registry account, mutable release tag, or dependency chain. 2. The attacker publishes a malicious package version and assigns it to `latest`. 3. A user follows the documented installation command. 4. `npx` downloads the package selected by the mutable tag. 5. Package lifecycle or CLI code executes under the installing user's privileges. 6. The malicious release can access or modify resources available to that user. No evidence shows that the currently referenced package is malicious. The finding concerns the avoidable supply-chain exposure caused by mutable and unverifiable installation instructions. ### Impact Assessment If the package distribution channel is compromised, installation ...[truncated 462 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin the installer to an exact, audited package version instead of `latest`. 2. Publish and verify package integrity hashes or signed provenance. 3. Document the expected registry, package owner, version, and checksum. 4. Use a lockfile or equivalent reproducible dependency mechanism for all transitive dependencies. 5. Disable or review dependency lifecycle scripts where practical. 6. Recommend installation in a non-privileged, isolated environment. 7. Establish a release process that verifies package contents against the audited source repository. 8. Replace placeholder repository metadata with a verifiable project URL so users can confirm provenance. ]]>
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (9)

External Script Fetching

High
Category
Supply Chain
Content
| 任何修改 | `chmod`, `chown`, `attrib`, `touch` | 配置破坏 |
| 关机重启 | `shutdown`, `reboot`, `halt`, `restart` | 断连 |
| 进程控制 | `kill`, `pkill`, `killall`, `taskkill` | 服务中断 |
| 管道执行 | `curl \| sh`, `wget \| bash`, `\| cmd` | 恶意代码 |
| 提权 | `sudo`, `su`, `runas` | 权限风险 |
| 下载执行 | `curl`, `wget`, `Invoke-WebRequest` | 潜在风险 |
| 远程连接 | `ssh`, `scp`, `sftp`, `rdp` | 安全风险 |
Confidence
90% confidence
Finding
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

External Script Fetching

High
Category
Supply Chain
Content
| 任何修改 | `chmod`, `chown`, `attrib`, `touch` | 配置破坏 |
| 关机重启 | `shutdown`, `reboot`, `halt`, `restart` | 断连 |
| 进程控制 | `kill`, `pkill`, `killall`, `taskkill` | 服务中断 |
| 管道执行 | `curl \| sh`, `wget \| bash`, `\| cmd` | 恶意代码 |
| 提权 | `sudo`, `su`, `runas` | 权限风险 |
| 下载执行 | `curl`, `wget`, `Invoke-WebRequest` | 潜在风险 |
| 远程连接 | `ssh`, `scp`, `sftp`, `rdp` | 安全风险 |
Confidence
90% confidence
Finding
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Lp3

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding
The skill advertises shell-based capabilities but does not declare an explicit tool scope such as allowed-tools or permissions. That creates ambiguity for the runtime and reviewers, and can let the agent invoke broader shell access than the skill text informally intends.

Rp1

Medium
Category
MCP Rug Pull
Confidence
89% confidence
Finding
The manifest references an MCP-related installer command without a fixed version, so consumers may fetch different code depending on time and registry state. In a security-oriented shell skill, that broadens the attack surface to upstream package compromise or typosquatting-like replacement risks.

Rp1

Medium
Category
MCP Rug Pull
Confidence
93% confidence
Finding
The installation command uses `npx clawhub@latest`, which is not a pinned immutable version and may resolve to different code over time. This creates a supply-chain risk where a future compromised or breaking release could change what gets installed or executed.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
The manifest description and the entire markdown guidance are presented in Chinese, including operational examples and safety constraints. This effectively forces a language/locale for users without documenting an opt-in or a justified region-specific scope.

Rp1

Medium
Category
MCP Rug Pull
Confidence
93% confidence
Finding
The repeated use of `npx clawhub@latest` in installation instructions again introduces an unpinned dependency path. Because this skill is positioned as a security control, mutable installation sources are especially problematic and undermine trust in the claimed safety properties.

Session Persistence

Medium
Category
Rogue Agent
Content
| 磁盘操作 | `diskutil erase`, `dd` | 磁盘数据丢失 |
| SIP | `csrutil` | 系统完整性破坏 |
| 启动安全 | `bless` | 启动修改 |
| 系统偏好 | `defaults write` | 配置修改 |

### 🐧 Linux 专用危险命令
Confidence
75% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
The file’s natural-language comments and user-facing messages are written exclusively in Chinese, and the skill description states its behavior only in that language. For a general-purpose shell executor, this imposes a specific language/locale without offering the user a choice or documenting a region-specific justification.

Static analysis

No suspicious patterns detected.