Back to skill

Security audit

Run Command Safety Check

Security checks for vulnerabilities and agentic risk

Overview

This is a local shell-command safety review skill, but its implementation is narrower than advertised and has file-boundary/output handling risks that users should review before installing.

Install only if you are comfortable treating this as a lightweight advisory report generator, not a complete command-safety gate. Prefer dry-run/stdout use, scan trusted directories, avoid directories containing untrusted symlinks, and do not point --output at important paths unless overwrite behavior is fixed or explicitly controlled.

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

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/run.py:31
Finding

Directory Scan Follows Symbolic Links Outside the Requested Root

Content
View full analysis

Vulnerability Details

File Location: scripts/run.py, lines 31-39 and 142-146
Vulnerability Type: Out-of-scope local file access through symbolic links
Risk Level: Medium

Vulnerable Code

python
def list_text_files(root: Path, limit: int = 50):
    results = []
    for path in root.rglob("*"):
        if len(results) >= limit:
            break
        if path.is_file():
            if path.suffix.lower() in {".md",".txt",".json",".yaml",".yml",".py",".js",".ts",".csv",".tsv",".sh"}:
                results.append(path)
    return results
python
def pattern_report(spec: dict, path: Path, limit: int) -> str:
    targets = [path] if path.is_file() else list_text_files(path, limit=limit)
    findings = []
    for target in targets:
        text = read_text(target)

Technical Analysis

The directory scanner recursively enumerates entries and accepts any entry for which Path.is_file() returns true. Python follows symbolic links when evaluating is_file() and when reading a path. The implementation does not reject symbolic links, resolve candidate paths, or verify that resolved files remain beneath the requested scan root.

Consequently, a directory under an attacker's control can contain a symbolic link with an allowed extension that targets a readable file elsewhere on the local system. When that directory is scanned, pattern_report() reads the external target. If its contents match one of the configured patterns, matching content and the target path are included in the generated report.

Attack Path

  1. An attacker gains the ability to place files or symbolic links in a directory that a user or automation process will scan.
  2. The attacker creates a symbolic link with an accepted extension, such as external.txt, pointing to a sensitive file outside the intended directory.
  3. A user invokes scripts/run.py --input <attacker-controlled-directory>.

...[truncated 749 chars]

Remediation
View remediation

Remediation Suggestions

  • Reject symbolic links during traversal by checking path.is_symlink() before accepting a candidate.
  • Resolve the scan root once and resolve every candidate before reading it.
  • Require every resolved candidate to remain under the resolved root, for example with candidate.resolve().is_relative_to(root.resolve()).
  • Handle resolution failures and broken links as non-fatal rejected entries.
  • Apply maximum file-size limits before reading to reduce denial-of-service exposure.
  • Add tests covering symlinks to files both inside and outside the selected root.
  • Consider reporting rejected out-of-root links without disclosing their contents.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run.py:275
Finding

Caller-Controlled Output Can Silently Overwrite Files and Follow Symbolic Links

Content
View full analysis

Vulnerability Details

File Location: scripts/run.py, lines 275-277
Vulnerability Type: Unsafe output-file creation and overwrite
Risk Level: Medium

Vulnerable Code

python
output_path = Path(args.output).expanduser()
output_path.parent.mkdir(parents=True, exist_ok=True)
output_path.write_text(rendered, encoding="utf-8")

Technical Analysis

The --output value is fully caller-controlled. The implementation creates missing parent directories and writes to the destination without checking whether it already exists or is a symbolic link. Path.write_text() opens an existing destination for truncating write and follows symbolic links.

An attacker who can influence command arguments, or create a symbolic link at a predictable output location, can cause the process to replace another file with generated report content. This is especially relevant when the script is invoked by an agent or automation service with broader write permissions than the attacker.

Attack Path

  1. An attacker influences the --output argument or prepares the output location before invocation.
  2. The attacker selects an existing writable file or creates a symbolic link from the expected output path to that file.
  3. A more privileged user or automation process runs the documented script command.
  4. write_text() follows the destination link, if present, and truncates the resolved target.
  5. The target file is replaced with the generated report, potentially corrupting data or configuration.

Impact Assessment

Exploitation can overwrite any file writable by the invoking process. Possible effects include loss of user data, corruption of application configuration, or denial of service. If the process can write security-sensitive configuration, the consequences may be more severe; however, the code does not itself elevate privileges, and it cannot overwrite files beyond the process's existing permissions.

Remediation
View remediation

Remediation Suggestions

  • Refuse to overwrite existing destinations by default.
  • Add an explicit --force option for intentional replacement and clearly document its effect.
  • Reject output paths that are symbolic links and verify that the resolved parent is within an approved workspace.
  • Create new files atomically with exclusive-create semantics, such as mode x, to prevent silent replacement.
  • Where replacement is required, write to a securely created temporary file in the same directory and atomically rename it after validation.
  • Re-check destination properties immediately before the final write to reduce time-of-check/time-of-use races.
  • Add tests for existing files, symbolic-link destinations, paths outside the workspace, and concurrent destination replacement.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (16)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared purpose is narrowly framed as shell-command safety review, but the skill text authorizes broader behaviors such as reading directories, processing files, and generating reports from external specs and templates. This mismatch can mislead users and higher-level policy systems, causing the skill to be invoked in trust-sensitive contexts while it actually has a wider data-access and processing surface.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The implementation materially diverges from the advertised security purpose. Instead of primarily validating dangerous shell-command patterns before execution, it acts as a broad reporting tool with unrelated directory, CSV, and skill-package audit modes, which can mislead users into relying on it as a safety control it does not actually provide. In a security workflow, this mismatch is dangerous because it creates false assurance and can allow unsafe commands to proceed without the promised review.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

该 README 是 markdown 文件,适用 SQP-1。L34 的“检查这段 shell 命令安不安全”属于开放式自然语言触发表述,未说明必须在何种路由上下文、输入约束或排除条件下激活;L33-L35 也仅给出正例,没有负例或边界说明,容易与一般性的安全咨询请求重叠。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This markdown file presents all user-facing content in a single language and does not indicate that the user can choose another language. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is clearly documented and justified.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill declares executable behavior involving python3, file inputs, and file outputs, but does not define any explicit tool scope such as allowed-tools or permissions. This creates an authority ambiguity where an agent may grant broader shell and filesystem access than the user expects, increasing the chance of unintended command execution or file modification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The manifest description and title/body text present core instructions in Chinese while also mixing in English phrases, but nowhere indicate that the user can choose their preferred language. This can violate a language/locale policy when a skill effectively defaults to a specific language without explicit user opt-in or a documented regional justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This markdown file is entirely framed as a Chinese-language example output, with all section headings and instructions written only in Chinese. Under the policy rule for language or locale constraints, this can be considered a natural-language policy violation because it imposes a specific language without documenting user choice or opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The title, category label, summary, and input hint are all specified only in Chinese, which imposes a specific language/locale in the skill's natural-language interface. The file does not mention that users may choose another language or that the Chinese locale is an intentional region-specific constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The template content is entirely written in Chinese and the title indicates a fixed output template, but there is no indication that the user can choose another language or that the locale restriction is required for a region-specific purpose. This creates a natural-language policy concern because it implicitly enforces a specific language without opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The generated report strings are hard-coded in Chinese, such as '结果', '摘要', and follow-up instructions, which imposes a specific language on users. This is a natural-language policy issue because the script does not offer a language option or document a justified locale restriction.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The pattern scan is only partially aligned with the stated shell-safety goal and spends coverage on secret-like strings and private URLs instead of the declared command-danger checks. This weakens detection fidelity for the intended use case and may cause both missed dangerous shell constructs and user confusion about what is actually being evaluated.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill-package auditing functionality is outside the scope of a shell command safety checker and unnecessarily broadens capability. In security-sensitive tooling, unexplained extra behavior increases the attack surface, complicates review, and raises the risk that operators misunderstand what the tool is validating.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
72% confidence
Finding

SQP-3 适用于所有文件类型。该 README 从标题到说明全部使用中文,且未说明是否支持其他语言、是否会根据用户偏好切换语言,也未给出这是区域性技能的合理限定,因此存在默认强制单一语言的政策风险。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The entire skill content, including title and instructions, is written only in Chinese, which can constitute a language/locale policy constraint if users are not given a choice. The file does not state that the skill is region-specific or offer an alternative language option.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

All user-facing instructions in this file are presented in Chinese, and the file does not state that the skill is region-specific or that users may choose another language. That can violate a language/locale policy when a specific language is imposed without opt-in or justification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

This markdown file includes a command that writes out.md, which affects user data on the local filesystem. The test steps present the file-generation action as routine but do not include any warning that running the command will create or potentially overwrite a file in the working directory.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.