T09 · Insecure Skill Coding Practices
- Location
scripts/run_extract.py:4299- Finding
Spreadsheet Formula Injection Through Untrusted PDF Data
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill appears to perform the advertised insurance-PDF extraction, but it exports sensitive personal data into an unprotected spreadsheet with avoidable safety gaps.
Install or use this only if you are authorized to process the insurance PDFs involved. Change the output path to a protected location, restrict access to the generated spreadsheet, delete it when no longer needed, and treat source PDFs as untrusted. Do not run the optimize_*.py scripts unless you intentionally want to rewrite run_extract.py and have a backup.
scripts/run_extract.py:4299Spreadsheet Formula Injection Through Untrusted PDF Data
Referenced artifact was not completely inspected
python scripts/run_extract.py
Referenced artifact was not completely inspected
python scripts/run_extract.py
The skill is explicitly designed to extract and export highly sensitive personal and insurance-policy data, including names, ID numbers, phone numbers, VINs, policy numbers, and license plates, yet it provides no privacy, consent, retention, or secure-handling guidance. This creates a real risk of unauthorized disclosure, insecure local storage, and non-compliant processing of regulated personal data, especially because the output is written to a desktop Excel file that may be broadly accessible.
The docstring states this is a 'Performance optimization patch' that applies optimizations 'without changing output logic'. However, the script replaces parsing code paths with cache-backed alternatives, adds fallback logic, and alters how values are derived across multiple parser functions, which can change behavior if cached content differs from fresh reads or if replacement snippets modify control flow.
The script unconditionally overwrites run_extract.py in place, which is dangerous because it modifies executable parsing logic without confirmation, backup, or integrity checks. In an agent skill context, this can silently alter downstream behavior, corrupt the target file, or introduce hard-to-detect logic changes if the patch content is wrong or tampered with.
The script unconditionally opens run_extract.py for writing and replaces its contents without any confirmation, backup, path validation, or dry-run mode. In an agent skill context, this is dangerous because running the script mutates source code in place, making accidental corruption, unauthorized code modification, or destructive changes much easier.
This script extracts highly sensitive personal data from insurance PDFs, including names, ID numbers, phone numbers, license plates, and VINs, then propagates that data across records using matching and majority-vote logic. In skill context, this increases privacy and compliance risk because it amplifies disclosure scope, can wrongly associate one person's identifiers with another record, and processes more personal data than minimally necessary.
Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.
# 按保险公司名称↑ + 车牌号码↑ 排序
df = df.sort_values(by=["保险公司名称", "车牌号码"], ascending=True)
# 清理非法字符,防止 openpyxl IllegalCharacterError
_ILLEGAL_RE = __import__('re').compile(r'[\x00-\x08\x0b\x0c\x0e-\x1f]')
for col in df.columns:
if df[col].dtype.kind == 'O':
df[col] = df[col].apply(lambda v: _ILLEGAL_RE.sub('', v) if isinstance(v, str) else v)
The script writes a consolidated Excel file containing sensitive insurance and identity data to a fixed desktop path without encryption, access control checks, masking, or any user-facing privacy warning. In this context, that creates a real confidentiality risk because the output is easy to discover, copy, sync, or mishandle on an endpoint.
All user-facing documentation, labels, and instructions are presented in Chinese, and there is no indication that users can choose another language or that the Chinese-only scope is an intentional, documented locale constraint. The policy requires flagging natural-language locale constraints when a specific language is effectively forced without opt-in or justification.
The file contains multiple hard-coded Chinese-language docstring/comment fragments and text-processing literals, with no indication that the skill is region-specific or that users can opt into this locale. Under the policy, forcing a specific language without user choice or documented justification is a natural-language policy concern.
The embedded natural-language description and many injected labels hard-code Chinese-language naming and field conventions, such as the version banner and multiple Chinese field names. There is no indication that the skill offers a language choice or that the locale restriction is explicitly documented as region-specific, which can violate language/locale policy expectations.
The primary natural-language description, operational scope, and many comments are presented exclusively in Chinese. For a general-purpose skill file, this imposes a language constraint without any opt-in, alternative locale, or justification that the tool is region-specific only.
Allowing LOG_FILE to direct logs to an arbitrary filesystem path can expose operational data to unintended locations, especially in shared or privileged environments. While this script does not obviously log full extracted document contents by default, exception traces, filenames, and future debug additions can still leak sensitive information into insecure log files.
The section header and docstring describe an "OCR fallback," suggesting image-based text recognition for garbled PDFs. However, extract_product_name_from_pdf only opens the PDF with fitz and calls page.get_text("text"), which is another text-layer extraction method rather than OCR, so the documentation overstates what the code actually does.