Back to skill

Security audit

Lawyer Case Archive Helper - 律师案件归档助手

Security checks for vulnerabilities and agentic risk

Overview

The skill looks like a real legal archiving helper, but it needs Review because it handles confidential case files, writes persistent OCR/output copies, and uses unsafe PowerShell document conversion.

Install only in an isolated Python environment and use it on a dedicated copy of case files. Treat generated DOCX/PDF/OCR text as confidential legal data, review output locations before sharing or backing up, and avoid case/template paths that can be influenced by untrusted parties until the PowerShell conversion is fixed.

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)

T09 · Insecure Skill Coding Practices

Error
Location
archive_case.py:374
Finding

PowerShell Command Injection Through Unescaped Document Paths

Content
View full analysis

Vulnerability Details

File Location: archive_case.py, lines 374-386
Vulnerability Type: PowerShell command injection
Risk Level: High

python
def docx_to_pdf(docx_path, pdf_path):
    """Word转PDF(需要Windows + Word COM)"""
    import subprocess
    cmd = f'''
    $word = New-Object -ComObject Word.Application; 
    $word.Visible = $false; 
    $word.DisplayAlerts = 0; 
    $doc = $word.Documents.Open("{docx_path}"); 
    $doc.ExportAsFixedFormat("{pdf_path}", 17); 
    $doc.Close($false); 
    $word.Quit()
    '''
    subprocess.run(['powershell', '-Command', cmd], capture_output=True)

Technical Analysis

The docx_path and pdf_path parameters are inserted directly into dynamically constructed PowerShell source code. They are not escaped, validated, or passed as non-code parameters.

An attacker who can control either parameter can include PowerShell syntax that terminates the quoted string and introduces additional commands. Passing PowerShell as an argument list does not prevent this vulnerability because the entire interpolated value is supplied to the PowerShell interpreter through -Command.

The normal command-line workflow derives these paths from a case directory and case name, which limits exploitation on Windows because some metacharacters are prohibited in filenames. However, docx_to_pdf() is a public Python function and can be called directly by another script or integration with arbitrary strings. Paths may also originate from less restrictive application-level inputs in future integrations.

The function ignores the subprocess return code and prints a successful-conversion message even if PowerShell fails. This can conceal exploitation attempts and conversion errors.

Attack Path

  1. An attacker gains control over a value passed as docx_path or pdf_path, such as through a Python integration that calls docx_to_pdf() directly.
  2. The attacker supplies a cra ...[truncated 970 chars]
Remediation
View remediation

Remediation Suggestions

  • Do not construct executable PowerShell source by interpolating paths.
  • Prefer a conversion API that accepts paths as ordinary arguments, such as a controlled Python COM integration.
  • If PowerShell is required, place the conversion logic in a fixed, reviewed .ps1 file and invoke it using powershell -File, passing document paths as separate parameters.
  • Resolve paths with Path.resolve() and enforce that input and output paths remain inside an approved case directory.
  • Require expected extensions such as .docx and .pdf, and reject control characters or values that do not represent valid filesystem paths.
  • Use PowerShell's literal-path handling where supported.
  • Run conversion with the least-privileged account necessary.
  • Set check=True, inspect the return code and standard error, and report conversion success only after confirming that the expected PDF exists.

T08 · Insecure Dependencies

Warning
Location
SKILL.md:24
Finding

Unpinned and Unverified Third-Party Dependencies

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 24-28
Vulnerability Type: Software supply-chain exposure
Risk Level: Medium

bash
# Python environment (3.10+)
# Install dependencies
pip install rapidocr-onnxruntime python-docx pdfplumber openpyxl

Technical Analysis

The installation instructions resolve third-party packages without exact version constraints or cryptographic hashes. Consequently, the installed artifacts depend on the package index and package versions available at installation time rather than on a reproducible, reviewed dependency set.

If a package release or configured package index is compromised, or if dependency resolution selects a vulnerable transitive dependency, a user may install code that was not included in this audit. Several of these dependencies are subsequently imported and executed by the application, and some include or rely on native components.

No evidence was found that the named package identifiers are deliberate typosquats or that the project retrieves packages from an explicitly malicious source. The finding concerns the absence of controls that would prevent a future or environment-specific supply-chain substitution.

Attack Path

  1. An attacker compromises a dependency release, a transitive dependency, or a package index used by the target environment.
  2. A user follows the documented unpinned pip install command.
  3. pip resolves the current attacker-controlled or otherwise unsafe artifact because no reviewed version or hash is enforced.
  4. The package is installed into the application's environment.
  5. The malicious or vulnerable package code executes when imported or used by the OCR, DOCX, or PDF-processing workflow.

Impact Assessment

A malicious dependency can execute with the privileges of the user installing or running the application. Potential consequences include access to confidential case images and documents, modification ...[truncated 315 chars]

Remediation
View remediation

Remediation Suggestions

  • Pin every direct dependency to a reviewed exact version.
  • Generate and commit a lock file that includes resolved transitive dependencies.
  • Use hash-verified installation, such as a requirements file containing --hash entries and installation with pip install --require-hashes.
  • Obtain packages only from an explicitly configured, trusted package index.
  • Review and update dependency pins through a controlled process that includes vulnerability and provenance checks.
  • Run dependency auditing in CI with tools such as pip-audit.
  • Install and run the application in an isolated virtual environment under a non-administrative account.
  • Record the expected package source, version, and hashes so installations are reproducible.
Vulnerability Patterns
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (8)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 19)May include surrounding context.

md
| `SKILL.md` | 技能说明文档 | 本文件 |

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill explicitly states it writes generated case summaries, archival documents, PDFs, and OCR text back into the case folder, but provides no warning about the sensitivity of legal matter data, possible exposure of OCR-extracted personal information, or the risk of overwriting existing files. In a legal-document workflow, these outputs may contain privileged, confidential, or regulated personal data, so silent in-place writes increase the chance of accidental disclosure, commingling, or destructive overwrite.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

文件中的自然语言说明、输出文档内容、命令行提示及生成模板字段均固定为中文,没有提供语言切换、用户选择或适用范围声明。根据语言/locale政策,这构成了默认强制特定语言的行为。

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 · archive_case.py (reported line 386)May include surrounding context.

python
$doc.Close($false); 
    $word.Quit()
    '''
    subprocess.run(['powershell', '-Command', cmd], capture_output=True)
    print(f"  已转换: {pdf_path}")

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

OCR output from case files is written persistently to a plaintext .txt file in the case directory, and the surrounding flow does not prominently warn the user that this may include highly sensitive legal matter, personal data, or privileged content. In a lawyer case-archiving context, creating an extra unprotected derivative copy materially increases exposure through accidental sharing, backup propagation, endpoint compromise, or improper retention.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code uses Chinese-only natural-language descriptions and console messages, which can impose a specific language on users without opt-in. The file does not indicate that the skill is intentionally region-specific or provide any alternative locale choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This file’s natural-language descriptions and user-facing messages are exclusively in Chinese, including the module description and console output. Under the policy, forcing a specific language without user opt-in can be a natural-language policy violation when no alternative language choice or documented locale constraint is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains natural-language strings that enforce a single language experience for usage instructions and operational output. Under the policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is clearly justified.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.