Back to skill

Security audit

skill-optimizer

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed skill-document optimizer, but its batch and cron paths can automatically modify and commit skill files too broadly.

Install only if you want an agent to be able to rewrite skill instructions. Prefer analyze mode first, require manual diff review before optimize or batch optimize, avoid enabling the weekly cron until git commits are gated or removed, and replace the template's API-key echo example with a non-revealing presence check.

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

T09 · Insecure Skill Coding Practices

Warning
Location
templates/optimized-skill-template.md:35
Finding

Reusable Template Exposes API Keys Through Command Output

Content
View full analysis
= 2.0 | `npm install -g tool-x` | `tool-x --version` | | API Key Y | — | See TOOLS.md | `echo $API_KEY` | ``` ### Technical Analysis The reusable skill template recommends `echo $API_KEY` as a dependency verification command. This prints the complete secret rather than merely confirming that the variable is configured. Because this template is intended to be copied into generated or optimized skills, the unsafe pattern may propagate to other project files. If an agent or user executes the command, the API key can be retained in terminal scrollback, CI logs, agent transcripts, command-capture systems, or other monitoring output. The issue does not expose a hardcoded credential in this repository. Exploitation requires a generated skill to retain the example and execute it in an environment where `API_KEY` contains a real secret. ### Attack Path 1. A skill is created or optimized using `optimized-skill-template.md`. 2. The API-key verification row is retained or adapted without replacing the command. 3. A real credential is assigned to the referenced environment variable. 4. A user, agent, or automated validation process executes `echo $API_KEY`. 5. The complete credential is written to observable output. 6. A party with access to logs, transcripts, terminal history, or captured output retrieves and reuses the credential. ### Impact Assessment An attacker could obtain the privileges associated with the disclosed API key, potentially including access to remote services, data, usage quotas, or billable operations. The exact impact depends on the permissions assigned to the credential. This issue does not independently provide local privilege escalation or arbitrary code execution. ]]>
Remediation
View remediation
&2 exit 1 fi ``` Additional hardening measures: 1. Explicitly state that credentials must never be printed, logged, or included in generated reports. 2. Use secret managers or protected environment variables for credential storage. 3. Redact sensitive environment-variable values from agent transcripts and CI logs. 4. Add a review rule that rejects generated verification commands containing `echo $...` for variables whose names include `KEY`, `TOKEN`, `SECRET`, or `PASSWORD`. 5. Rotate any credential that may already have been exposed through this pattern. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/cron/skill-optimizer-cron.sh:164
Finding

Scheduled Script Automatically Stages Unrelated Files Under the Skills Directory

Content
View full analysis
/dev/null; then echo "" echo "📝 No skill changes to commit." else git add skills/ 2>/dev/null || true git commit -m "Weekly skill optimization — $DATE Analyzed $SKILL_COUNT skills, $NEEDS_IMPROVEMENT need improvement. Report: tmp/skill-optimization-cron-$DATE.md" 2>/dev/null || echo "⚠️ Git commit skipped (not a git repo or no changes)" echo "" echo "📝 Changes committed to git." fi ``` ### Technical Analysis The scheduled script stages the entire `skills/` tree with `git add skills/`, rather than staging only files created or modified by the current optimization operation. Consequently, unrelated tracked changes and untracked files can be included whenever the commit branch is entered. The preceding `git diff --quiet skills/` check only examines unstaged changes to tracked files by default. If at least one tracked file has changed, the broad `git add skills/` command can also collect unrelated untracked files under that directory. Suppression of Git error output further reduces operator visibility into what was staged or committed. The script does not push commits to a remote repository, so this finding causes local repository persistence rather than direct exfiltration. A later manual or automated push could nevertheless transmit committed material. ### Attack Path 1. The weekly cron task is configured and runs with write access to the workspace repository. 2. An unrelated modification exists in a tracked file under `skills/`, causing `git diff --quiet skills/` to return a nonzero status. 3. Additional unrelated or sensitive files are present anywhere under `skills/`. 4. The script executes `git add skills/`, staging the entir ...[truncated 924 chars]
Remediation
View remediation
0)); then git add -- "${modified_files[@]}" git diff --cached --check git diff --cached --name-status git commit -m "Weekly skill optimization — $DATE" fi ``` Additional hardening measures: 1. Do not automatically commit when the cron job only generates an analysis report and has not intentionally modified skill files. 2. Validate that every staged path remains inside the expected workspace using canonical paths. 3. Exclude secrets, backup files, temporary artifacts, and files such as `*.bak`, `.env`, and credential exports through both validation logic and `.gitignore`. 4. Inspect `git diff --cached --name-only` against an explicit allowlist before committing. 5. Require human approval for commits that include unexpected paths or file types. 6. Avoid suppressing all Git diagnostics; capture failures in the report without exposing secrets. 7. Configure secret scanning as a pre-commit control. 8. If sensitive data has already been committed, rotate affected credentials and purge the material from repository history. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • 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
Findings (12)

Self-Modification

High
Category
Rogue Agent
Confidence
95% confidence
Finding

The skill explicitly promotes editing SKILL.md files as part of an optimization loop, which is a form of self-modification. In a system where skills guide future agent behavior, allowing an automated process to rewrite those instructions can create persistence, instruction drift, and amplification of unsafe or adversarial content—especially when combined with scheduled execution.

Content

Scanner excerpt · README.md (reported line 63)May include surrounding context.

md
| Reflect (analyze trajectories) | Score 10 quality dimensions, identify weaknesses |
| Aggregate (merge patches) | Combine related improvements |
| Select (learning rate) | Max 4 edits per pass (prevents overfitting) |
| Update (apply to doc) | Edit SKILL.md with bounded changes |
| Gate (validate) | Re-score, only accept improvements |
| Slow update | Gradual improvement across passes |
| Meta skill | Cross-skill patterns → better rubric |

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The skill’s declared purpose is analysis and optimization of SKILL.md files, but the document also instructs backup creation, direct file modification, batch workspace enumeration, and artifact/report generation. That mismatch is dangerous because users or orchestrators may invoke what appears to be a read-mostly auditing skill while unintentionally granting it authority to perform broader write operations across the workspace.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The README describes an automated weekly workflow that analyzes skills, writes reports, optimizes files, and claims to commit changes, but it does not clearly warn users that it may modify skill documents and potentially alter git history. In an agentic environment, silent or under-disclosed self-modifying behavior increases the risk of unintended repository changes, integrity loss, and propagation of bad edits across skills.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The README's 'What It Does' section says the cron job 'Commits any optimization changes to git.' However, the actual cron setup message at L140 only instructs execution of the cron script, review of the report, and optimization of low-scoring skills; it does not mention committing changes. This is an intent-level contradiction within the documentation about what the automated workflow does.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The activation guidance is broad enough to overlap with routine maintenance, auditing, onboarding, and improvement tasks, which increases the chance the skill is selected in situations where the user did not specifically request optimization. In context, this is more dangerous because the skill includes write-mode behavior, so ambiguous triggering can lead to unintended edits or broad workspace actions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Optimize mode performs file writes and overwrites the active SKILL.md while only mentioning a backup step, without a prominent warning that the primary file will be changed. This is risky because users may treat optimization as advisory analysis and unknowingly permit destructive or hard-to-review edits to operational skill definitions.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The batch command pattern is underspecified and allows workspace-wide enumeration and optimization without clear scope limits, exclusions, or confirmation requirements. In a multi-skill workspace, this can amplify mistakes from a single invocation into widespread unintended modifications, especially because the workflow ranks and edits multiple skills automatically.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script’s documented behavior says it analyzes skills and generates a report, but it also later stages and commits repository changes. That mismatch is security-relevant because operators may schedule or approve the cron job under the assumption it is read-only, while it actually performs persistent write actions to the workspace history.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The cron job automatically runs 'git add skills/' and 'git commit' even though its stated role is analysis/reporting. In a shared or sensitive workspace, this can silently persist unintended or attacker-induced modifications to skill files, creating unauthorized history changes and potentially normalizing malicious edits as routine automated maintenance.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The README hard-codes '--tz "Asia/Jakarta"' and documents the schedule as 'Every Monday at 03:00 WIB,' which imposes a locale-specific setting in natural language instructions. There is no indication that this timezone is optional, user-selected, or required for a region-specific compliance reason.

Content

No source excerpt is available for this finding.

Vague Triggers

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This markdown file explicitly notes that the skill's trigger clarity is weak because it has 'Basic triggers listed but no negative triggers.' Under SQP-1 for markdown files, missing negative examples or exclusion conditions can make invocation scope too broad or unclear.

Content

No source excerpt is available for this finding.

Vague Triggers

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

This markdown template is in scope for vague-trigger review, and the example trigger text 'another common phrasing' is intentionally broad rather than domain-specific. As a reusable template, it may lead skill authors to document activation conditions that overlap with everyday language without sufficient constraints.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.