Back to skill

Security audit

Prompt-Engineering-workflow

Security checks for vulnerabilities and agentic risk

Overview

The skill mainly builds structured prompts, but it includes maintenance scripts that can execute code from projects being validated or documented.

Install only if you want a Chinese-first prompt-engineering template and can avoid running its maintenance scripts on untrusted repositories. Treat scripts/validate_skill.py and assets/generate-api-docs.py as trusted-code-only tools; run them in an isolated environment if validating or documenting third-party content.

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

Error
Location
scripts/validate_skill.py:682
Finding
Validation of an Untrusted Skill Executes Its Project-Supplied Fingerprint Script<![CDATA[ ## Vulnerability Details **File Location**: `scripts/validate_skill.py`, lines 682–768 **Vulnerability Type**: Arbitrary code execution through an untrusted validation target **Risk Level**: High ### Vulnerable Code The validator derives the executable path directly from the user-controlled `--skill-dir` directory: ```python import subprocess fp = skill_dir / "scripts" / "fingerprint.py" ``` It subsequently starts that project-supplied Python file as a subprocess: ```python r = subprocess.run( [sys.executable, str(fp), "parse", raw, "--skill-dir", str(skill_dir)], capture_output=True, text=True, encoding="utf-8") ``` ### Technical Analysis The validator accepts an arbitrary Skill directory through its documented `--skill-dir` command-line option. It then treats `scripts/fingerprint.py` inside that directory as an executable validation component. Although the validator statically parses selected assignments from the file before execution, this does not establish that the file is safe. An attacker can preserve the expected `CORE_ATOM_KEYS` and `DEPENDENCY_RULES` assignments while adding arbitrary top-level Python statements. Those statements execute immediately when the subprocess starts, before argument parsing or fingerprint validation occurs. The vulnerability crosses a trust boundary: a trusted auditing utility executes code supplied by the untrusted artifact it is intended to inspect. Passing arguments as a list prevents shell metacharacter injection, but it does not mitigate execution of a malicious Python program. ### Attack Path 1. An attacker prepares a Skill directory containing the expected structure and documentation. 2. The attacker supplies a crafted `scripts/fingerprint.py`. 3. The crafted file retains the constants expected by the validator so that static checks do not immediately reject it. 4. The attacker adds malicious top-level Python code to the file. 5. The Skill documentation contains at least one matching ...[truncated 1189 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Do not execute files from the target Skill.** Move fingerprint parsing into the trusted validator and process fingerprint strings as data. 2. **Use a trusted parser implementation.** If code reuse is required, import or invoke a parser from the validator’s own installation directory, not from `--skill-dir`. 3. **Separate trusted tooling from inspected content.** Resolve trusted utility paths relative to the running validator: ```python trusted_fp = Path(__file__).resolve().parent / "fingerprint.py" ``` This is appropriate only if that file belongs to the trusted validator package rather than the inspected artifact. 4. **Prefer direct library calls over subprocesses.** Refactor fingerprint parsing into a side-effect-free trusted module and call its parsing function directly. 5. **Add a regression test.** Create a target Skill whose `fingerprint.py` writes a marker file at module initialization. Validation must reject or inspect the target without creating that marker. 6. **Use defense-in-depth isolation.** If target-controlled code must ever run, execute it in a disposable sandbox with: - No host credentials or secrets. - Network access disabled. - A read-only target directory. - No writable host mounts. - Resource and execution-time limits. - A dedicated unprivileged operating-system identity. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
assets/generate-api-docs.py:136
Finding
API Documentation Generation Imports and Executes Project-Controlled Python Modules<![CDATA[ ## Vulnerability Details **File Location**: `assets/generate-api-docs.py`, lines 136–270 **Related Documentation**: `assets/api-docs-auto-generation.md`, lines 22–35 and 146–212 **Vulnerability Type**: Arbitrary code execution through unsafe import-based reflection **Risk Level**: High ### Vulnerable Code The generator imports the selected package and discovered submodules: ```python pkg = importlib.import_module(package_name) ``` ```python for finder, name, ispkg in pkgutil.iter_modules(pkg.__path__, prefix=f"{package_name}."): try: submodule = importlib.import_module(name) scan_module(submodule, name) except ImportError: pass ``` The class-index generation path repeats the unsafe import behavior: ```python pkg = importlib.import_module(package_name) ``` ```python for finder, name, ispkg in pkgutil.iter_modules(obj.__path__, prefix=prefix + "."): try: submod = importlib.import_module(name) collect(submod, name) except ImportError: pass ``` The command-line entry point places the caller’s current working directory on the import path and imports a package named `scripts`: ```python cwd = Path.cwd() if str(cwd) not in sys.path: sys.path.insert(0, str(cwd)) importlib.invalidate_caches() ref_doc = _generate_reference("scripts") (output_dir / "api_reference.md").write_text(ref_doc, encoding="utf-8") index_doc = _generate_class_index("scripts") (output_dir / "api_class_reference.md").write_text(index_doc, encoding="utf-8") ``` ### Technical Analysis Python imports are executable operations, not passive source inspection. Importing a package executes its `__init__.py`, and importing each discovered submodule executes its top-level statements. The generator explicitly adds the current working directory to `sys.path`, making project-controlled modules eligible for resolution. It then imports `scripts` and recursively imports discovered submodules. Consequently, running this do ...[truncated 1939 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Replace runtime imports with static analysis.** Use Python’s `ast` module to extract: - Public classes and functions. - Function signatures and annotations. - Docstrings. - Enum declarations. - Literal `__all__` assignments. 2. **Do not add the inspected repository to `sys.path`.** Treat repository content as data, not executable modules. 3. **Require explicit source paths.** Accept a source directory and parse `.py` files directly instead of resolving package names through Python’s import system. 4. **Handle dynamic constructs safely.** When metadata cannot be resolved statically, mark it as unavailable rather than importing the module. 5. **Correct the documentation.** Clearly state that import-based reflection executes module initialization code and must never be used on untrusted repositories without isolation. 6. **Sandbox any unavoidable runtime reflection.** Use a disposable environment with: - No secrets or inherited credentials. - Disabled network access. - Read-only source mounts. - A dedicated unprivileged user. - Restricted writable output storage. - CPU, memory, and execution-time limits. 7. **Add security regression tests.** Include a fixture package whose `__init__.py` and submodule top-level code attempt to create marker files. Static documentation generation must complete without executing those statements. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • 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
Findings (102)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
Large-scale compliance auditing, directory traversal, file hygiene inspection, and JSON/exit-code reporting are operational auditing behaviors, not merely prompt generation. When a skill understates these capabilities, agents may invoke broad local inspection logic in a context that did not justify it, increasing privacy and integrity risks.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
Large-scale compliance auditing, directory traversal, file hygiene inspection, and JSON/exit-code reporting are operational auditing behaviors, not merely prompt generation. When a skill understates these capabilities, agents may invoke broad local inspection logic in a context that did not justify it, increasing privacy and integrity risks.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
Large-scale compliance auditing, directory traversal, file hygiene inspection, and JSON/exit-code reporting are operational auditing behaviors, not merely prompt generation. When a skill understates these capabilities, agents may invoke broad local inspection logic in a context that did not justify it, increasing privacy and integrity risks.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
Large-scale compliance auditing, directory traversal, file hygiene inspection, and JSON/exit-code reporting are operational auditing behaviors, not merely prompt generation. When a skill understates these capabilities, agents may invoke broad local inspection logic in a context that did not justify it, increasing privacy and integrity risks.

Ae1

High
Category
analysis-evasion
Content
- 契约门禁:见 [scripts/validate_skill.py](scripts/validate_skill.py)(用途:校验原子契约/深度段/指纹/依赖规则/信号表;运行:`python scripts/validate_skill.py --skill-dir . --strict`)
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Hidden Instructions

High
Category
Prompt Injection
Content
# claude 模型适配器

<!--
MODEL-ADAPTER
id: claude
target: Anthropic Claude 系列(Opus / Sonnet / Haiku)
Confidence
70% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Hidden Instructions

High
Category
Prompt Injection
Content
# deepseek 模型适配器

<!--
MODEL-ADAPTER
id: deepseek
target: DeepSeek 系列(V3 / R1)
Confidence
70% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Hidden Instructions

High
Category
Prompt Injection
Content
# gemini 模型适配器

<!--
MODEL-ADAPTER
id: gemini
target: Google Gemini 系列
Confidence
70% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Hidden Instructions

High
Category
Prompt Injection
Content
# openai 模型适配器

<!--
MODEL-ADAPTER
id: openai
target: OpenAI GPT 系列(gpt-4o / o-series / gpt-5 系)
Confidence
70% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Hidden Instructions

High
Category
Prompt Injection
Content
# qwen 模型适配器

<!--
MODEL-ADAPTER
id: qwen
target: 阿里通义千问系列(Qwen)
Confidence
70% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
ex = read_text(skill_dir / "references" / "complete-examples.md")
    checked.append("references/complete-examples.md")
    if da is None or ex is None:
        return
    rules = re.findall(
        r"^\|\s*R(\d+)\s*\|\s*([a-z-]+)\s*(=|≥|≤)\s*D(\d)\s*\|"
        r"\s*([a-z-]+)\s*(=|≥|≤)\s*D(\d)\s*\|",
Confidence
85% confidence
Finding
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Lp3

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding
The skill advertises and references scripts that use file reads, file writes, and shell execution, but it declares no explicit tool scope or permission boundaries. In an agent environment, this can cause the skill to run with broader-than-expected capabilities, increasing the chance of unintended filesystem modification or command execution.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The trigger text says to use the skill whenever a user asks to generate, optimize, grade prompts, or turn vague needs into professional prompts. This is a wide natural-language description without explicit exclusions or negative examples, so it could overlap with many ordinary requests about writing or refining text and cause unintended invocation.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
This instruction requires all generated prompts to use Chinese punctuation and prohibits mixed-language formatting unless a specific language suffix is supplied. That imposes a default locale/style policy on users rather than offering a neutral default or asking for preference first.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The script imports the target package and its submodules dynamically to generate docs, which executes module top-level code during analysis. If run against an untrusted or compromised package, this can trigger arbitrary code execution, filesystem/network access, or other import-time side effects under the user's privileges.

Natural-Language Policy Violations

Medium
Confidence
89% confidence
Finding
The document title and all operative instructions are written in Chinese, and the data-flow section explicitly references `lang=zh` normalization, which indicates a Chinese-default locale. There is no visible user opt-in, alternative language option, or clear region-specific justification in this file, so it may violate language/locale policy requirements.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
The skill file is written entirely in Chinese and includes no indication that users may choose another language or locale. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is explicitly documented and justified.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
This markdown file uses Chinese throughout for headings, requirements, and checklist items, which effectively forces a specific language for users of the skill. Under the policy, language constraints should either provide user choice or be clearly documented as justified for a specific locale or compliance context.

Natural-Language Policy Violations

Medium
Confidence
82% confidence
Finding
This markdown file is written entirely in Chinese and defines output-format requirements such as 'Markdown/纯文本/表格' and textual constraints without indicating that language is optional or user-selectable. Under the policy, forcing a specific language or locale without opt-in is a natural-language policy violation unless clearly documented as region-specific.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The file is entirely written in Chinese and prescribes Chinese-language interaction patterns without indicating that the skill is locale-specific or offering a language fallback. This can cause users or downstream agents to misunderstand instructions, produce incorrect outputs, or be excluded from safely using the skill, especially in multilingual environments where prompt behavior must be predictable.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
The file’s instructional content is written entirely in Chinese and provides role/output templates only in Chinese, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking context. This creates a natural-language locale policy concern because it implicitly fixes the interaction language without opt-in or justification.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
SQP-3 applies to all file types and covers language or locale policy violations. This skill file presents all instructions and constraints only in Chinese, which effectively forces a specific language on users without any visible opt-in, alternative language, or justification that the skill is region-specific.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
The entire skill file is written as mandatory operational guidance in Chinese, including the title and all instruction content, with no indication that language selection is optional or limited to a region-specific use case. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation.

Vague Triggers

Medium
Confidence
89% confidence
Finding
The trigger terms include very broad business words such as budget, cost, profit, and ROI, which can cause the finance domain atom to activate for general business or operational conversations that are not actually finance-specific. In a prompt-engineering framework, this can misroute tasks, inject inappropriate finance framing, and degrade downstream reasoning or produce misleading domain-specific advice where it does not belong.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The applicability signals include very broad everyday business terms such as '员工', '组织', and '企业文化', which can cause the HR domain atom to activate for loosely related requests. In a prompt-engineering skill, overbroad triggering can inject unnecessary HR-specific constraints or guidance into unrelated tasks, reducing reliability and potentially skewing outputs in sensitive personnel contexts.

Static analysis

No suspicious patterns detected.