Back to skill

Security audit

Skill Optimizer

Security checks for vulnerabilities and agentic risk

Overview

The skill appears intended to evaluate other skills and does not contain malicious payloads, but it requests more powerful write and command-execution authority than its read-only auditing behavior needs.

Review before installing. The skill's scripts appear to only read skill files and print reports, but the package should narrow its permissions, remove Write unless editing is explicitly implemented and user-directed, avoid broad activation triggers, and make template-file validation consistent before it is trusted as an automated quality gate.

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

Excessive Write and Command-Execution Permissions

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, line 8
Vulnerability Type: Violation of least privilege
Risk Level: Medium

Vulnerable Code

yaml
allowed-tools: [Bash, Read, Write, Exec]

Technical Analysis

The Skill is designed to inspect Skill metadata, document structure, and referenced files. Its implemented scripts only read files and print assessment results; they do not require file modification.

Nevertheless, the configuration grants Write and two broad command-execution capabilities, Bash and Exec. These permissions exceed the legitimate requirements of a read-only auditing workflow. Granting both execution mechanisms also unnecessarily increases the available attack surface.

The declaration does not itself execute malicious commands. However, if the hosting agent makes these declared tools available while processing attacker-controlled Skill content, manipulated instructions could cause the agent to invoke capabilities that the auditor does not legitimately need.

Attack Path

  1. A user invokes the optimizer against an untrusted or attacker-controlled Skill.
  2. The optimizer is loaded with Write, Bash, and Exec available.
  3. Malicious content in the target Skill attempts to influence the hosting agent's behavior.
  4. If the agent follows that content, it can invoke the unnecessarily granted tools.
  5. Commands may execute or files may be modified with the operating-system privileges of the hosting agent.

This repository does not contain an embedded payload that performs these steps; the vulnerability is the unnecessary privilege exposure that makes such an exploitation path possible.

Impact Assessment

Successful exploitation could permit:

  • Modification of files writable by the hosting agent.
  • Execution of arbitrary local commands under the agent's operating-system account.
  • Access to local resources exposed to invoked shell commands.
  • Damage beyond the intended read-only assessment scope.

...[truncated 135 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the unnecessary Write permission.
  2. Retain Read as the primary capability for assessment.
  3. Do not grant both unrestricted Bash and Exec.
  4. If script execution is required, expose only a narrowly scoped invocation mechanism for the bundled validator.
  5. Require explicit user confirmation before any future operation that executes a command or modifies a file.
  6. Run validation scripts in a restricted environment with:
    • A read-only project mount.
    • No network access.
    • Minimal environment variables.
    • A dedicated low-privilege operating-system account.
  7. Add a permission regression test that fails if write or unrestricted execution capabilities are introduced without a documented requirement.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/optimize-skill.py:230
Finding

Mandatory Referenced-File Validation Is Not Enforced and Accepts Non-File Paths

Content
View full analysis

Vulnerability Details

File Locations:

  • scripts/optimize-skill.py, lines 230-252
  • scripts/check-templates.py, lines 45-48
  • Related mandatory-validation specification: SKILL.md, lines 72-97

Vulnerability Type: Validation bypass and incorrect filesystem object validation
Risk Level: Medium

Vulnerable Code

The primary optimization flow performs metadata and structure checks and then calculates a score without invoking the referenced-file validator:

python
def optimize_skill(skill_name):
    """优化单个技能"""
    skill_file = find_skill_file(skill_name)
    
    if not skill_file:
        return {'error': f'技能文件不存在:{skill_name}'}
    
    # 读取技能文件
    with open(skill_file, 'r', encoding='utf-8') as f:
        content = f.read()
    
    # 解析元数据
    metadata = parse_skill_metadata(content)
    
    # 检查元数据
    metadata_results = check_metadata(metadata)
    
    # 检查结构
    structure_results = check_structure(content)
    
    # 计算评分
    score = calculate_score(metadata_results, structure_results)

The separate validator checks only whether a path exists:

python
for file_path in mentioned_files:
    full_path = os.path.join(skill_dir, file_path)
    if os.path.exists(full_path):
        found.append(file_path)
    else:
        missing.append(file_path)

Technical Analysis

The project describes referenced template and resource validation as mandatory and states that a missing referenced file must cause the assessed Skill to fail. The documented primary evaluator, however, never calls check_skill_templates() or implements equivalent validation before calculating its score.

Consequently, a Skill can satisfy metadata and heading checks and receive a passing or high score even when files referenced in its SKILL.md do not exist.

The standalone validator also uses os.path.exists(). This checks the existence of any filesystem object, not whether the referenced path is a regular file. A directory named with a .md or `. ...[truncated 1891 chars]

Remediation
View remediation

Remediation Suggestions

  1. Integrate referenced-file validation directly into optimize_skill() before score calculation.
  2. Make validation failure affect both:
    • The returned status or process exit code.
    • The final score according to the documented mandatory-failure policy.
  3. Replace generic existence checks with regular-file validation, for example:
python
skill_root = Path(skill_dir).resolve()
candidate = (skill_root / file_path).resolve()

if not candidate.is_relative_to(skill_root):
    missing.append(file_path)
elif not candidate.is_file():
    missing.append(file_path)
else:
    found.append(file_path)
  1. Define an explicit symlink policy:
    • Reject all symlinks for referenced resources; or
    • Resolve them and require the final target to remain inside the Skill root and be a regular file.
  2. Use one shared validation function for both single-Skill and batch assessment paths to prevent behavior divergence.
  3. Return a structured validation result rather than relying only on printed status messages.
  4. Add automated tests for:
    • Missing referenced files.
    • Valid regular files.
    • Directories with .md or .py suffixes.
    • Broken symlinks.
    • Symlinks escaping the Skill root.
    • Batch-mode enforcement.
    • Correct score and exit-status behavior after validation failure.
  5. Add the currently missing referenced files or remove their references from SKILL.md.
Vulnerability Patterns
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (6)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The declared description suggests a broader 'skill quality assessment' or 'skill evaluation/checking' capability, potentially covering overall validation after creation/modification and batch evaluation. The actual code only performs one specific check: whether files mentioned in SKILL.md under certain path patterns exist on disk. It does support batch checking of multiple skills, but only for this narrow template-file consistency rule. There is no implementation of general quality scoring, broader validation criteria, or trigger handling based on user phrases/keywords. Therefore, the description materially overstates and mischaracterizes the code's primary purpose.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- `scripts/optimize-skill.py` - 评估脚本

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger description is very broad and includes generic keyword-based activation such as 'skill 优化', 'skill 评估', and '技能检查', which can cause unintended invocation in unrelated conversations. Because the skill has access to Bash, Write, and Exec tools, accidental activation can expand tool exposure and lead to unnecessary filesystem access or command execution in contexts where the user did not explicitly request this skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains natural-language strings that define the tool description and usage entirely in Chinese. Under the policy, forcing a specific language without opt-in is a language/locale policy violation unless the constraint is explicitly justified, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The report output, error messages, batch summaries, and usage text shown during execution are all fixed in Chinese. Because the script does not offer user choice or document a justified locale restriction, this violates the natural-language language/locale policy.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

SQP-3 applies to all file types and covers language/locale policy violations. This file presents its description and runtime output in Chinese only, with no opt-in, alternative language, or indication that the tool is intentionally region-specific.

Content

No source excerpt is available for this finding.