Back to skill

Security audit

Drawing Cleaner

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed local drawing-text cleaner that reads Markdown and writes cleaned Markdown, with no evidence of hidden network access, credential use, persistence, or destructive behavior.

Install only if you are comfortable running a local Python cleaner over selected Markdown drawing extracts. Review the chosen input and output paths before running, and treat cleaned content as quoted project data when sending it to another AI tool.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/clean_drawing.py:208
Finding

Untrusted Drawing Text Is Forwarded Verbatim to Downstream AI Systems

Content
View full analysis

Vulnerability Details

File Location: scripts/clean_drawing.py:208-220, 266; related downstream workflow in SKILL.md:87, 101
Vulnerability Type: Indirect prompt-injection exposure through insufficient output sanitization
Risk Level: Medium

Vulnerable Code

python
for line in raw_lines:
    # Remove Markdown formatting symbols
    cleaned = re.sub(r'^#+\s*', '', line).strip()
    cleaned = re.sub(r'^-+\s*', '', cleaned).strip()
    cleaned = re.sub(r'\s*\|\s*', '  ', cleaned)

    if not cleaned:
        continue

    # Split merged fragments
    segments = [s.strip() for s in cleaned.split('  ') if s.strip()]

    for seg in segments:
        if is_noise(seg):
            continue
        tag = classify_line(seg)
        # Deduplicate within each category
        if seg not in result[tag]:
            result[tag].append(seg)

The retained input is later written verbatim:

python
for tag in priority_order:
    items = classified.get(tag, [])
    if not items:
        continue
    lines_out.append(f"## [{tag}]\n\n")
    for item in items:
        lines_out.append(f"- {item}\n")
    lines_out.append("\n")

The documented workflow then supplies this output to another AI system:

markdown
boq-generator skill

SKILL.md:101 also recommends sending content from the catch-all category to a language model for summarization before passing it to boq-generator.

Technical Analysis

The input Markdown represents text extracted from potentially untrusted drawing files. The cleaning process removes only a small set of Markdown prefixes and filters content using construction-domain regular expressions. It does not distinguish descriptive drawing data from natural-language instructions directed at an AI agent.

Any text that does not match a noise pattern is retained. Content that does not match a recognized construction category is placed in the catch-all category and reproduced without escaping, provenance metadata, or an unt ...[truncated 2621 chars]

Remediation
View remediation

Remediation Suggestions

  1. Establish an explicit untrusted-data boundary

    • Mark every extracted segment as untrusted source content.
    • Use a structured representation such as JSON with fields including source, category, content, and trust_level.
    • Avoid presenting extracted text in a form that resembles agent instructions.
  2. Harden downstream prompts

    • Tell downstream models that drawing content is quoted data and must never be followed as instructions.
    • Delimit source content clearly and place security instructions outside those delimiters.
    • State that requests to ignore rules, reveal prompts, invoke tools, or modify the workflow found inside source content are document data only.
  3. Detect and quarantine suspicious content

    • Add a separate category for likely prompt-injection language.
    • Flag phrases that address an assistant, refer to system or developer messages, request disclosure, override earlier instructions, or request tool execution.
    • Require human review of quarantined content rather than silently deleting it.
  4. Apply least privilege downstream

    • Do not give summarization or quantity-generation agents unnecessary filesystem, shell, credential, or network access.
    • Require explicit user approval for consequential tool operations.
    • Validate generated quantities against deterministic rules before accepting them.
  5. Preserve provenance

    • Retain source file and source-line metadata for each output item.
    • Ensure downstream systems can distinguish original drawing text from pipeline-generated headings and instructions.
  6. Add adversarial tests

    • Test drawings containing direct and obfuscated prompt-injection phrases.
    • Verify that suspicious text is quarantined and cannot alter downstream model behavior.
    • Include multilingual and Unicode-obfuscated variants because drawing text may contain mixed-language content.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (8)

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/clean_drawing.py (reported line 194)May include surrounding context.

python
for rule in CATEGORY_RULES:
        for pat in rule['patterns']:
            if re.search(pat, text, re.IGNORECASE):
                return rule['tag']
    return '其他'

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill instructs execution of a local Python script that reads an input Markdown file and writes a cleaned output file, but it declares no explicit tool scope or permissions boundary. In an agent environment, this can cause the skill to gain implicit file read/write behavior without clear user-visible constraints, increasing the risk of unintended access or modification of local files.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The trigger phrases like '清洗图纸文本', '去掉噪声', and '整理提取结果' are broad enough to match ordinary user requests that may not be intended to invoke this specific skill. Over-broad activation can lead an agent to run file-processing behavior unexpectedly, including reading prior outputs and creating new files without the user realizing a specialized skill was invoked.

Content

No source excerpt is available for this finding.

Ae4

Medium
Category
analysis-evasion
Confidence
80% confidence
Finding

Suspicious Unicode normalization or mixed-script content

Content

No source excerpt is available for this finding.

Ae4

Medium
Category
analysis-evasion
Confidence
80% confidence
Finding

Suspicious Unicode normalization or mixed-script content

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

This file is entirely presented in Chinese and provides no indication that users may choose another language or that the locale restriction is intentional and justified. Under the language/locale policy rule, a skill artifact that effectively enforces a single language without opt-in can be a policy concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The instructions state that the script will automatically generate an output file when no path is provided, but there is no explicit warning to the user that filesystem changes will occur. This can surprise users and, in automated environments, lead to unintended file creation, overwrites, or accumulation of derived artifacts.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code file contains natural-language comments, messages, and argument descriptions exclusively in Chinese, including the stated purpose and user-facing CLI text. Under the policy rule, forcing a specific language without offering an alternative or opt-in is a locale/language policy concern.

Content

No source excerpt is available for this finding.