Back to skill

Security audit

Document Processor

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent document-processing tool, but it needs Review because dependency installation and OCR temporary-file handling are under-scoped for sensitive documents.

Install only if you are comfortable with a local document tool that can read and write chosen files and install Python packages from PyPI. Use a virtual environment, avoid running the installer as administrator/root, keep backups of originals, use explicit output paths, and do not run OCR analysis on confidential files unless you are prepared to manually remove retained /tmp/pdf_ocr_* artifacts.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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)

T08 · Insecure Dependencies

Warning
Location
install_dependencies.py:63
Finding

Unpinned Dependencies Installed from an External Package Repository

Content
View full analysis

Vulnerability Details

File Location: install_dependencies.py:63-70, 92-95
Vulnerability Type: Uncontrolled third-party dependency installation
Risk Level: Medium

python
# Base dependencies
dependencies = [
    "PyPDF2>=3.0.0",
    "python-docx>=0.8.11",
    "pdf2docx>=0.5.6",
    "Pillow>=9.0.0",
    "pdfplumber>=0.8.0",
    "docx2pdf>=0.1.8",
]
python
for dep in dependencies:
    package_name = dep.split('>=')[0] if '>=' in dep else dep.split('==')[0] if '==' in dep else dep

    if run_command(f"{sys.executable} -m pip install --upgrade {dep}", f"Install {package_name}"):

The command execution helper used by this installation path is defined at install_dependencies.py:10-14:

python
def run_command(cmd, description):
    """Run command and display progress"""
    print(f"🔧 {description}...")
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)

Technical Analysis

Every dependency uses an open-ended minimum version constraint. The --upgrade option instructs pip to retrieve the newest version accepted by each constraint whenever the installer runs. There is no lock file, exact version pinning, package hash verification, or explicitly configured trusted package index.

Consequently, the code that users install is not necessarily the code that was reviewed with this project. If a dependency release or its package-distribution account is compromised, a later execution of the installer can retrieve attacker-controlled package content. Python packages may execute build backends or installation-related code during installation, and malicious behavior can also execute when the resulting package is imported.

The use of shell=True is unnecessary and increases the fragility of the command boundary. The dependency strings are currently hard-coded, so the reviewed code does not expose a direct user-controlled shell-injectio ...[truncated 1391 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace minimum-version constraints with exact, reviewed versions.
  2. Maintain a lock file generated by a dependency-management tool and commit it to source control.
  3. Require hashes for downloaded distributions, such as through a hash-locked requirements file and pip's --require-hashes option.
  4. Remove unconditional --upgrade; dependency upgrades should be explicit, reviewed changes.
  5. Configure an approved package index explicitly and prevent unexpected fallback to untrusted indexes.
  6. Install dependencies in an isolated virtual environment using a non-privileged account.
  7. Invoke pip without a shell:
python
subprocess.run(
    [sys.executable, "-m", "pip", "install", "--require-hashes", "-r", "requirements.lock"],
    check=True,
    capture_output=True,
    text=True,
    shell=False,
)
  1. Add automated dependency vulnerability, provenance, and integrity checks to the release process.

T09 · Insecure Skill Coding Practices

Note
Location
pdf_ocr.py:61
Finding

OCR Analysis Leaves Sensitive Document Images and Extracted Text in Temporary Storage

Content
View full analysis

Vulnerability Details

File Location: pdf_ocr.py:61-62, 110-111, 231-256, 399-405
Vulnerability Type: Sensitive temporary-file retention
Risk Level: Low

Temporary storage is created at pdf_ocr.py:61-62:

python
# Create temporary directory
self.temp_dir = tempfile.mkdtemp(prefix="pdf_ocr_")
print(f"📁 Temporary directory: {self.temp_dir}")

A complete rendered page image is retained at pdf_ocr.py:110-111:

python
# Save image for debugging
debug_path = os.path.join(self.temp_dir, f"page_{page_num:03d}.png")
image.save(debug_path)

OCR-derived text is retained at pdf_ocr.py:231-256:

python
def save_results(self, pdf_path):
    """Save OCR results"""
    if not self.ocr_results:
        return

    results_file = os.path.join(self.temp_dir, "ocr_results.txt")

    with open(results_file, 'w', encoding='utf-8') as f:
        f.write("="*60 + "\n")
        f.write("PDF OCR analysis results\n")
        f.write("="*60 + "\n\n")

        for result in self.ocr_results:
            f.write(f"Page {result['page_num']}:\n")
            f.write("-"*40 + "\n")

            if 'error' in result:
                f.write(f"Error: {result['error']}\n")
            else:
                text = result['text'].strip()
                if text:
                    f.write(text[:500])
                    if len(text) > 500:
                        f.write("\n... (truncated)")
                else:
                    f.write("[No text content]")

            f.write("\n\n")

Normal completion of the analyze command does not clean the directory at pdf_ocr.py:399-405:

python
if args.command == 'analyze':
    result = processor.analyze_pdf_structure(
        args.input,
        args.start,
        args.end,
        args.language
    )
    return 0 if result else 1

Technical Analysis

OCR processing renders PDF pages int ...[truncated 1845 chars]

Remediation
View remediation

Remediation Suggestions

  1. Manage temporary artifacts with tempfile.TemporaryDirectory() so cleanup occurs automatically.
  2. Enclose the entire analysis lifecycle in try/finally and invoke cleanup() in the finally block.
  3. Do not save debug page images by default. Require an explicit option such as --retain-debug-artifacts.
  4. If retention is requested, write artifacts to a user-selected directory and clearly report that sensitive data will remain there.
  5. Apply restrictive permissions to retained files and directories.
  6. Avoid writing OCR text unless it is required for the requested operation.
  7. Add tests verifying that successful, failed, and interrupted operations all remove temporary data.

Example lifecycle hardening:

python
processor = PDFOCRProcessor()
try:
    result = processor.analyze_pdf_structure(
        args.input,
        args.start,
        args.end,
        args.language
    )
    return 0 if result else 1
finally:
    processor.cleanup()
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (27)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

If the shipped code primarily performs testing, subprocess invocation, filesystem inspection, and temp-directory manipulation while presenting itself as a user-facing document processor, that creates a security-relevant transparency gap. Hidden or undocumented subprocess behavior is dangerous in an agent environment because reviewers and users may permit execution under false assumptions, enabling broader file-system or command activity than expected.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

If the shipped code primarily performs testing, subprocess invocation, filesystem inspection, and temp-directory manipulation while presenting itself as a user-facing document processor, that creates a security-relevant transparency gap. Hidden or undocumented subprocess behavior is dangerous in an agent environment because reviewers and users may permit execution under false assumptions, enabling broader file-system or command activity than expected.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

If the shipped code primarily performs testing, subprocess invocation, filesystem inspection, and temp-directory manipulation while presenting itself as a user-facing document processor, that creates a security-relevant transparency gap. Hidden or undocumented subprocess behavior is dangerous in an agent environment because reviewers and users may permit execution under false assumptions, enabling broader file-system or command activity than expected.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

If the shipped code primarily performs testing, subprocess invocation, filesystem inspection, and temp-directory manipulation while presenting itself as a user-facing document processor, that creates a security-relevant transparency gap. Hidden or undocumented subprocess behavior is dangerous in an agent environment because reviewers and users may permit execution under false assumptions, enabling broader file-system or command activity than expected.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
98% confidence
Finding

The helper accepts a command string and executes it with shell=True, which is a classic tool-parameter abuse pattern because the shell will interpret metacharacters, chaining, and redirection. In an agent skill that installs packages and may evolve to consume external parameters, this becomes more dangerous because successful exploitation can execute arbitrary system commands under the agent's privileges.

Content

Scanner excerpt · install_dependencies.py (reported line 14)May include surrounding context.

python
"""运行命令并显示进度"""
    print(f"🔧 {description}...")
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
        if result.returncode == 0:
            print(f"  ✅ 完成")
            return True

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The entire skill documentation and example interaction are presented only in Chinese, with no indication that users may choose another language or that the skill is intentionally restricted to a Chinese-speaking context. Under the stated policy, forcing a specific language without opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The README materially overstates implemented capabilities by advertising watermark removal, compression, OCR, image extraction, page reordering/deletion, and batch/folder processing while later listing many of them as not yet implemented. In an agent skill context, this can cause the system or users to invoke nonexistent or substituted functionality, increasing the risk of unsafe fallback behavior, broken workflows, or trust in operations the skill cannot actually perform.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The README promotes file-modifying operations such as conversion, extraction, merging, splitting, and watermark handling without warning about overwrites, irreversible changes, formatting loss, or document integrity risks. In a document-processing skill, missing safety guidance can lead to accidental destruction of important files or silent corruption of outputs that users may trust.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The activation rule says the skill will activate whenever a user needs document processing, which is overly broad for an agent-integrated skill. This can trigger the skill on generic document-related requests outside its narrow implemented scope, causing unintended file operations, incorrect tool selection, or exposure of user files to unnecessary processing.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
82% confidence
Finding

The skill declares powerful tools including shell execution and file write capabilities but does not define any explicit scope constraints such as allowed-tools or permission boundaries. In an agent setting, this increases the blast radius of misuse because document inputs can drive command execution or arbitrary file modification without a clearly documented least-privilege model.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The manifest description and the entire skill documentation are written in Chinese, presenting the skill as Chinese-language by default without any opt-in or alternative language path for users. Under the policy, forcing a specific language is a natural-language policy violation unless the skill offers language choice or clearly justifies a locale-specific constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This Python file contains user-facing natural language that is fixed to Chinese, starting with the module docstring and continuing throughout the script. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present here.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
97% confidence
Finding

This call executes a shell command via subprocess.run(..., shell=True), which turns the command string into shell-interpreted input. Even though the current dependency list is hard-coded, this helper is generic and any future or indirect user-controlled value passed into cmd could lead to command injection and arbitrary code execution.

Content

Scanner excerpt · install_dependencies.py (reported line 14)May include surrounding context.

python
"""运行命令并显示进度"""
    print(f"🔧 {description}...")
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
        if result.returncode == 0:
            print(f"  ✅ 完成")
            return True

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · install_dependencies.py (reported line 42)May include surrounding context.

python
"""检查pip是否可用"""
    print("📦 检查pip...")
    try:
        subprocess.run([sys.executable, "-m", "pip", "--version"], 
                      capture_output=True, check=True)
        print("  ✅ pip可用")
        return True

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · install_dependencies.py (reported line 142)May include surrounding context.

python
for package in packages:
        try:
            subprocess.run([sys.executable, "-m", "pip", "show", package], 
                          capture_output=True, check=True)
            installed.append(package)
        except:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The CLI description and option help strings are user-facing and written only in Chinese, which imposes a language choice on users. The file does not offer an alternative locale or indicate that the skill is intentionally limited to Chinese-speaking users.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code file contains natural-language strings that force a specific language/locale for usage, help text, and runtime interaction. Under the policy, language restrictions should either be optional for the user or clearly justified as region-specific; neither is present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This file contains natural-language descriptions and user-visible output exclusively in Chinese, starting with the module docstring and continuing throughout the CLI. Under the policy, forcing a specific language without user opt-in is a language/locale policy violation unless the constraint is explicitly documented and justified, which it is not here.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · pdf_ocr.py (reported line 46)May include surrounding context.

python
print("  pip install pytesseract pillow")
            print("还需要安装 Tesseract OCR 引擎:")
            print("  macOS: brew install tesseract")
            print("  Ubuntu: sudo apt-get install tesseract-ocr")
            print("  Windows: 下载安装 Tesseract")
        
        if missing:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The title and description force a specific language for user-facing interaction, and the rest of the script's prompts and help text continue this pattern. Under the policy, language-specific behavior should offer user opt-in or be explicitly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file contains user-facing docstrings and console messages entirely in Chinese, including status output and next-step instructions. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present here.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · test_skill.py (reported line 37)May include surrounding context.

python
# 测试帮助命令
        import subprocess
        try:
            result = subprocess.run(
                [sys.executable, "pdf_extractor.py", "--help"],
                capture_output=True,
                text=True,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · test_skill.py (reported line 67)May include surrounding context.

python
# 测试帮助命令
        import subprocess
        try:
            result = subprocess.run(
                [sys.executable, "pdf_to_word.py", "--help"],
                capture_output=True,
                text=True,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · test_skill.py (reported line 94)May include surrounding context.

python
# 测试帮助命令
        import subprocess
        try:
            result = subprocess.run(
                [sys.executable, "word_to_pdf.py", "--help"],
                capture_output=True,
                text=True,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · test_skill.py (reported line 121)May include surrounding context.

python
# 测试检查命令
        import subprocess
        try:
            result = subprocess.run(
                [sys.executable, "install_dependencies.py", "--check"],
                capture_output=True,
                text=True,

Static analysis

No suspicious patterns detected.