Back to skill

Security audit

safeclaw

Security checks for vulnerabilities and agentic risk

Overview

SafeClaw has a coherent security-checking purpose, but it tells the agent to run unreviewed parent-directory code with a shell command built from a user path.

Review this skill before installing or invoking it. The main risk is not the stated goal, which is reasonable, but that invocation depends on whatever `main.py` exists outside the reviewed package and passes user input through a shell-shaped command. Only use it in a controlled workspace where the checker implementation and dependencies are known, pinned, and trusted; avoid copying the example MCP server entries directly without pinning package versions and narrowing filesystem scope.

Vulnerability Patterns
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (3)

T08 · Insecure Dependencies

Error
Location
SKILL.md:22
Finding
Execution of Unbundled and Unaudited Code Outside the Skill Package<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:22-32` **Vulnerability Type**: `T08: Insecure Dependencies` **Risk Level**: High ### Vulnerable Code ```bash cd {baseDir}/../../ && uv run python main.py check --config "<config_path>" --format json ``` ```bash cd {baseDir}/../../ && uv run python main.py check --auto --format json ``` ### Technical Analysis The skill instructs the agent to leave the audited skill directory and execute `main.py` from a parent project directory. The audited package does not contain `main.py`, a dependency manifest, a lockfile, or the source code implementing the advertised security checks. As a result, the effective executable is outside the reviewed package boundary. Its behavior depends on mutable parent-directory content and on the Python environment selected or resolved by `uv run`. The artifact therefore cannot guarantee that the executed code is the intended non-invasive configuration checker. This also creates a trust-boundary problem: reviewing or installing the skill does not establish the integrity of the code that will run when the skill is invoked. ### Attack Path 1. An attacker gains the ability to create or replace `main.py` in the directory resolved by `{baseDir}/../../`, or modifies the dependency configuration used by `uv`. 2. A user invokes SafeClaw to inspect a configuration file. 3. The agent follows the documented command and changes into the parent project directory. 4. `uv run python main.py` executes the attacker-controlled or otherwise unaudited code. 5. The code runs with the privileges and filesystem/network access of the agent process. ### Impact Assessment Successful exploitation can result in arbitrary code execution under the account running the agent. Depending on the surrounding runtime permissions, the executed code could: - Read the configuration file supplied for analysis. - Access other files readable by the agent account. - Modify files writable by that account. - U ...[truncated 324 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Bundle the complete checker implementation inside the skill package. 2. Invoke the checker using a canonical path located beneath `{baseDir}` rather than changing to a parent directory. 3. Resolve and verify the executable path before invocation, and fail closed if it escapes the skill directory. 4. Include a version-controlled dependency manifest and a lockfile with integrity information. 5. Install dependencies from explicitly approved registries and pin all dependency versions. 6. Run the checker in a restricted environment with read-only access to the selected configuration file and no unnecessary network access. 7. Document and verify the expected hash or signature of the checker entry point before execution. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:42
Finding
Shell Command Injection Through User-Controlled Configuration Path<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:42-44` **Vulnerability Type**: `T09: Insecure Skill Coding Practices` **Risk Level**: High ### Vulnerable Code ```bash cd {baseDir}/../../ && uv run python main.py check --config "<path>" --format json ``` ### Technical Analysis The documented execution flow constructs a shell command by interpolating a user-provided configuration path into a command string. The path is surrounded by double quotes, but double quoting does not make arbitrary text safe for shell evaluation. Shell constructs such as command substitutions—`$(...)` and backticks—are evaluated inside double quotes. A value containing a closing quote can also terminate the intended argument and introduce additional commands or shell operators. The instructions do not require path validation, canonicalization, safe shell escaping, or execution through a structured argument array. The vulnerability is reachable when an agent substitutes the path into the command and passes the resulting string to a shell, as directed by the fenced `bash` example. ### Attack Path 1. An attacker persuades a user or agent to check a configuration path containing shell syntax, such as: ```text $(attacker-controlled-command) ``` or: ```text "; attacker-controlled-command; # ``` 2. The agent inserts the supplied value into the documented shell command. 3. The resulting command is interpreted by a shell. 4. The shell evaluates the command substitution or injected command separators. 5. The attacker-controlled command executes with the privileges of the agent process before or alongside the intended configuration check. ### Impact Assessment Successful exploitation permits arbitrary command execution with the permissions of the account running the skill. The injected command could read or modify accessible files, inspect inherited environment variables, access local credentials available to the process, or communicate over the ne ...[truncated 285 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not construct a shell command by concatenating or interpolating the configuration path. 2. Invoke the checker through a structured process API with a separate argument array, for example: ```python subprocess.run( ["uv", "run", "python", checker_path, "check", "--config", config_path, "--format", "json"], shell=False, check=True, ) ``` 3. Canonicalize the path and verify that it points to a regular configuration file in a user-approved location. 4. Reject paths containing NUL bytes, control characters, or unexpected encoding. 5. Do not rely solely on quote escaping; ensure the path is never interpreted as shell syntax. 6. Use `--` where supported to terminate option parsing and prevent paths beginning with `-` from being treated as command options. 7. Run the checker with least privilege and limit its filesystem and network access. ]]>

T08 · Insecure Dependencies

Warning
Location
example-config.json:24
Finding
Unpinned Automatic npm Package Execution in Example Configuration<![CDATA[ ## Vulnerability Details **File Location**: `example-config.json:24-34` **Vulnerability Type**: `T08: Insecure Dependencies` **Risk Level**: Medium ### Vulnerable Code ```json "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"], "audited": true }, "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "audited": true } ``` ### Technical Analysis The example configuration launches two npm packages through `npx -y` without specifying package versions or integrity hashes. When the packages are not already available locally, `npx` can retrieve and execute the versions currently selected by the configured npm registry. The `-y` flag suppresses interactive confirmation, reducing the opportunity for a user to inspect the package and version before execution. Because the package references are unpinned, the effective code may change after this skill has been reviewed. The `"audited": true` metadata is declarative and does not enforce package provenance, version immutability, signature validation, or integrity verification. In addition, the filesystem server receives access to `/tmp`, a broadly shared temporary location that may contain files created by unrelated processes. ### Attack Path 1. A user copies or adapts the supplied example configuration. 2. The MCP launcher invokes `npx -y` for one of the unversioned packages. 3. `npx` resolves the package through the configured npm registry and may download it automatically. 4. A compromised publisher account, registry response, dependency, or unsafe future package release supplies malicious code. 5. The downloaded package executes with the privileges of the MCP launcher. 6. For the filesystem server, the process also receives the configured access to `/tmp`. ### Impact Assessment A compromised package or dependency can execute arbitrary JavaScript with the permissions of the launching user. Potential effects inc ...[truncated 482 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin each npm package to an explicitly reviewed version, such as `package-name@x.y.z`. 2. Use a lockfile and enforce package integrity hashes during installation. 3. Remove `-y` from security-sensitive examples so installation is not silently approved. 4. Preinstall reviewed dependencies in a controlled build process instead of downloading packages at runtime. 5. Use an approved registry and verify package provenance, publisher identity, and signatures where supported. 6. Run MCP servers in a sandbox with minimal filesystem, environment, and network permissions. 7. Replace `/tmp` with a dedicated private directory containing only the files required by the filesystem server. 8. Treat `"audited": true` only as informational metadata and enforce verification through technical controls. ]]>
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
Findings (2)

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
The documented JSON output schema requires status and result values in Chinese (for example, `安全|注意|高危` and other Chinese field contents) while the rest of the skill is written in English. This creates a language/locale constraint without user opt-in or justification, which matches the policy-violation category for forced language behavior.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
Lines L66-L68 label the compliance levels as '安全', '注意', and '高危', which imposes a specific language in user-facing output. The file does not indicate that this is optional, configurable, or justified as a region-specific tool, so it may violate language/locale policy expectations.

Static analysis

No suspicious patterns detected.