Back to skill

Security audit

Prompt Leak Auditor

Security checks for vulnerabilities and agentic risk

Overview

This is a local prompt-leak auditing skill that reads user-selected files or directories and produces reports, with no network access, persistence, or hidden system changes found.

Install only if you are comfortable with Chinese-language output. Run it against specific files or small intended directories, avoid very large or untrusted folders, and review reports before sharing them because they may contain local paths and partially redacted sensitive snippets.

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/run.py:27
Finding

Unbounded File Reads Can Cause Resource Exhaustion

Content
View full analysis

Vulnerability Details

File Location: scripts/run.py, lines 27–31 and 136–146
Vulnerability Type: Uncontrolled resource consumption
Risk Level: Medium

Complete Code Snippet

python
def read_text(path: Path) -> str:
    try:
        return path.read_text(encoding="utf-8")
    except UnicodeDecodeError:
        return path.read_text(encoding="utf-8", errors="replace")

The vulnerable function is called during pattern scanning:

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)
        for name, pattern in PATTERNS.items():
            for match in re.finditer(pattern, text, flags=re.IGNORECASE):
                snippet = match.group(0)
                if "secret_like" == name:
                    snippet = re.sub(r"([A-Za-z0-9_\-]{4})[A-Za-z0-9_\-]+", r"\1***", snippet)
                findings.append((str(target), name, snippet[:160]))

Technical Analysis

The scanner loads every selected file completely into memory with Path.read_text(). The --limit option limits the number of files or findings, but it does not impose a maximum size per file or a maximum total number of bytes read.

After allocating memory for the complete file, the implementation applies several regular expressions to the full string. This adds CPU consumption and may create further temporary objects. The fallback after a decoding error reads the complete file again, potentially doubling I/O and allocation pressure for malformed or non-UTF-8 content.

An attacker who can influence the input file or directory can exploit this behavior without requiring command execution, elevated privileges, or a specially crafted binary payload. An oversized file with any accepted extension, such as .md, .txt, .json, or .py, is sufficient.

Attack Path

  1. An attacker creates or sup ...[truncated 1103 chars]
Remediation
View remediation

Remediation Suggestions

  1. Enforce a conservative maximum file size before reading by checking path.stat().st_size.
  2. Enforce a cumulative byte budget across all files in a directory scan.
  3. Process input incrementally in bounded chunks rather than loading complete files into memory.
  4. Preserve a small overlap between chunks so patterns spanning chunk boundaries can still be detected.
  5. Reject oversized files with an explicit report entry instead of silently skipping them.
  6. Validate --limit and reject negative or unreasonably large values.
  7. Apply process-level memory and execution-time limits when running the scanner in an Agent environment.
  8. Avoid reading a malformed file twice; use a single bounded read with controlled decoding behavior.
  9. Add automated tests using oversized and malformed files to verify that scanning terminates safely and reports truncation.

A minimal size guard should follow this pattern:

python
MAX_FILE_BYTES = 10 * 1024 * 1024

def read_text(path: Path) -> str:
    size = path.stat().st_size
    if size > MAX_FILE_BYTES:
        raise ValueError(
            f"File exceeds the {MAX_FILE_BYTES}-byte scanning limit: {path}"
        )
    return path.read_text(encoding="utf-8", errors="replace")

For stronger protection, replace the complete read with bounded streaming and track the total bytes processed across the scan.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (14)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The entire skill description is written in Chinese and does not indicate that language choice is optional or that the skill is intentionally limited to Chinese-speaking users. Under the policy rule, forcing a specific language without user opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file presents all user-facing content exclusively in Chinese, and there is no indication that the user can choose another language or has opted into this locale. Under the language/locale policy rule, forcing a specific language without opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill advertises executable behavior via python3 and references local resources that imply file read/write flows, but it does not declare any explicit tool scope such as permissions or allowed-tools. This creates an authorization ambiguity where a caller or runtime may permit broader shell or filesystem access than reviewers expect, increasing the chance of unintended file access or command execution.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file presents all headings and instructions in Chinese, which effectively forces a specific language for users. The policy allows locale-specific behavior only when the skill offers opt-in or clearly documents a justified regional constraint, neither of which appears here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This markdown file presents all user-facing headings and instructions in Chinese, and there is no indication that the user can opt into another language or that the skill is intended only for a Chinese-language context. That can violate language/locale policy when a skill forces a specific language without user choice.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The file listing helper recursively enumerates text files under a root path, giving the skill the ability to map repository contents and feed those paths into reports. In the context of a narrowly scoped leak-audit skill, this creates unnecessary reconnaissance capability that could expose internal structure and aid further targeting.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The generated report strings in make_structured_report are hard-coded in Chinese, including titles, summaries, and next-step guidance. This enforces a specific language for user-facing output without offering a language choice or documenting a justified locale constraint.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The directory audit mode enumerates files and extracts Markdown headings, which can reveal repository structure, document names, and high-level contents. For a skill advertised as a prompt-leak auditor, this is unnecessary capability and can leak sensitive organizational context such as internal docs, project names, or hidden operational areas.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

directory_report, csv_report, pattern_report, and skill_audit all emit Chinese headings and guidance text. Because this behavior applies broadly across output modes and no locale option is exposed, it violates the language/locale policy criteria.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The CSV audit mode profiles fields and uniqueness counts, which is unrelated to prompt leakage analysis and may expose sensitive schema or dataset characteristics. Even without dumping raw rows, field names and cardinality can disclose business logic, PII categories, or confidential data model details.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The dispatcher enables multiple modes unrelated to the skill’s declared purpose of auditing prompt/skill text for secret leakage and risky instructions. This expands the skill’s operational scope, increasing the chance it will be used to inspect arbitrary files, directories, or datasets and expose information beyond what users would reasonably expect from the manifest.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

This markdown file presents all instructions and headings in Chinese, but it does not indicate that the user opted into that language or that the skill is intentionally limited to a Chinese-speaking context. Under the language/locale policy rule, forcing a specific language without user choice can be a natural-language policy violation.

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 template, including its title and required section labels, is written only in Chinese, which implies a fixed output language. The file does not offer a language choice or explain that the skill is intentionally region-specific, which can violate the language/locale policy for natural-language content.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

This markdown file is entirely Chinese-language and does not indicate that the user can choose another language or that the skill is intentionally limited to a Chinese-speaking context. Under the language/locale policy rule, forcing a specific language without user opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.