Back to skill

Security audit

Regulation Extractor

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its stated purpose, but it can send extracted document text to Feishu, expose Feishu secrets through command-line use, overwrite local JSON files, and delete Bitable records without strong safeguards.

Install only if you are comfortable reviewing the scripts and running them deliberately. Use a virtual environment, keep backups of JSON outputs before cleaning, avoid --delete_dupes until you have exported or reviewed the target Bitable records, prefer --dry_run first, and do not pass Feishu secrets directly on shared shells or in CI logs.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/sync_to_bitable.py:44
Finding

Feishu Application Secret Exposed Through Command-Line Arguments

Content
View full analysis

Vulnerability Details

File Location: scripts/sync_to_bitable.py:44-52; usage is documented in SKILL.md:74-78
Vulnerability Type: Sensitive credential exposure through process arguments
Risk Level: Medium

Vulnerable Code

python
def main():
    parser = argparse.ArgumentParser(description="条文写入飞书多维表格")
    parser.add_argument("json", help="提取结果JSON路径")
    parser.add_argument("--app_token", required=True, help="飞书多维表格app_token")
    parser.add_argument("--table_id", required=True, help="表格table_id")
    parser.add_argument("--app_id", required=True, help="飞书App ID")
    parser.add_argument("--app_secret", required=True, help="飞书App Secret")
    parser.add_argument("--dry_run", action="store_true", help="仅检查,不写入")
    parser.add_argument("--delete_dupes", action="store_true", help="删除重复记录(保留最早的)")
    args = parser.parse_args()

The documented invocation also explicitly places the secret in the command line:

bash
python scripts/sync_to_bitable.py <output.json> \
  --app_token <APP_TOKEN> --table_id <TABLE_ID> \
  --app_id <APP_ID> --app_secret <APP_SECRET> \
  --delete_dupes

Technical Analysis

The Feishu application secret is accepted as a normal command-line argument. Process arguments may be visible through operating-system process inspection facilities, shell history, terminal recording, CI/CD logs, job metadata, crash reports, and endpoint monitoring products.

The secret is legitimately required to request a Feishu tenant access token, and the reviewed code sends it only to the official open.feishu.cn authentication endpoint. The vulnerability is therefore not an undeclared network exfiltration path; it is an unsafe local credential-delivery mechanism.

Attack Path

  1. A user follows the documented command and supplies the Feishu application secret through --app_secret.
  2. The command is retained in shell history, captur ...[truncated 743 chars]
Remediation
View remediation

Remediation Suggestions

  • Remove the --app_secret command-line option.
  • Read the secret from a protected environment variable or operating-system secret store.
  • For interactive execution, use getpass.getpass() so the secret is not echoed or stored in shell history.
  • For automated execution, integrate with a managed secret service and inject the secret only into the target process.
  • Ensure the secret is never printed, included in exception messages, or written to logs.
  • Restrict the Feishu application to the minimum Bitable scopes required by this workflow.
  • Rotate the existing application secret if it has already been used through documented command lines or CI jobs.

T08 · Insecure Dependencies

Note
Location
SKILL.md:123
Finding

Unpinned Third-Party Dependencies Permit Unreviewed Package Changes

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:123-126
Vulnerability Type: Unpinned package installation and supply-chain exposure
Risk Level: Low

Vulnerable Code

text
## 依赖

pip install PyMuPDF rapidocr-onnxruntime

Technical Analysis

The installation instructions request package names without reviewed version constraints, hashes, or a lock file. Each installation therefore resolves whichever compatible releases are currently served by the configured Python package index.

No evidence of typosquatting, dependency confusion, a malicious package, or an untrusted package repository was found. The risk arises because future package releases, transitive dependencies, or package-index compromise can change the code installed after this Skill has been audited.

Python packages and their transitive dependencies execute within the installing user's environment. A malicious or compromised release could run code during installation, import, model initialization, or ordinary runtime operation.

Attack Path

  1. An attacker compromises a named dependency, one of its transitive dependencies, or the package-index delivery path.
  2. A malicious new release is published under a dependency name resolved by the documented installation command.
  3. A user runs the unpinned pip install command.
  4. Package resolution selects the changed release without requiring review of the new artifact.
  5. Malicious package code executes with the privileges of the installing or running user.

Impact Assessment

Exploitation could provide arbitrary code execution with the privileges of the user who installs or runs the dependencies. Depending on that user's access, this could expose local PDF documents, generated JSON files, environment variables, Feishu credentials, and other user-accessible files. The audited project does not itself request elevated installation privileges.

Remediation
View remediation

Remediation Suggestions

  • Create a version-controlled requirements or lock file containing reviewed, exact versions.

  • Pin transitive dependencies as well as direct dependencies.

  • Record package hashes and install with:

    bash
    pip install --require-hashes -r requirements.txt
    
  • Use a trusted package index or an internally controlled package mirror.

  • Run dependency vulnerability and provenance checks before updating locked versions.

  • Review and test dependency updates before publishing a new Skill version.

  • Install and run the Skill in an isolated virtual environment with access only to necessary input and output data.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/deep_clean.py:183
Finding

JSON Cleaning Scripts Overwrite Source Files Non-Atomically Without Backups

Content
View full analysis

Vulnerability Details

File Location: scripts/deep_clean.py:183-188; scripts/clean_json.py:72-76
Vulnerability Type: Unsafe non-atomic in-place file replacement
Risk Level: Low

Vulnerable Code

In scripts/deep_clean.py:

python
# 重新生成report
report = validate(new_arts)
d['articles'] = new_arts
d['report'] = report

with open(json_path, 'w', encoding='utf-8') as f:
    json.dump(d, f, ensure_ascii=False, indent=2)

In scripts/clean_json.py:

python
# 重新生成report
from extract_regulation import validate
d['report'] = validate(arts)

with open(json_path, 'w', encoding='utf-8') as f:
    json.dump(d, f, ensure_ascii=False, indent=2)

Technical Analysis

Both scripts open each selected JSON source file using mode w. Opening the file in this mode truncates it before serialization has completed. If the process is interrupted, storage becomes unavailable, serialization raises an exception, or the system crashes, the original content can be lost and the file may remain empty or partially written.

Directory mode processes every top-level *.json file in the user-selected directory. The scripts do not create backups, validate that every file is an intended extractor result before mutation, or use atomic replacement. In addition, deep_clean.py intentionally removes entries using heuristic filters. Those transformations are declared functionality, but their irreversible in-place application increases the data-integrity impact of false positives.

Attack Path

  1. A user points a cleaning script at a JSON file or directory containing extraction results.
  2. The script parses the file and opens the same path with mode w, immediately truncating the source.
  3. The process is terminated, the disk fills, an I/O error occurs, or serialization otherwise fails before completion.
  4. The original source is no longer available, leaving an empty or incomplete JSON file.
  5. Subs ...[truncated 695 chars]
Remediation
View remediation

Remediation Suggestions

  • Write the transformed document to a temporary file in the same directory.
  • Flush buffered data and call os.fsync() before replacement.
  • Parse and validate the completed temporary JSON before committing it.
  • Replace the source atomically with os.replace().
  • Preserve an optional timestamped backup before destructive cleaning.
  • Validate that input files contain the expected articles structure and required article fields before modifying them.
  • Add an output-directory or --in-place option, with non-destructive output as the default.
  • Add a dry-run mode that reports removals and transformations without changing files.
  • Require confirmation when directory mode would modify multiple files.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (15)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明描述的是一个完整的规范PDF条文抽取流水线,包含PDF输入、OCR识别、条文切分、编号规范化、质量标记、JSON输出以及飞书同步等能力。但给出的代码片段只处理已经存在的JSON文件,针对articles.text执行基于正则的文本清洗,并调用外部模块重新判断quality与生成report。它没有读取PDF、没有执行OCR、没有做条文切分或编号转换,也没有任何飞书相关逻辑。虽然“文本清洗”和“质量标记”与声明的一部分相符,但该片段的实际功能仅覆盖声明中的一个后处理子步骤,无法准确代表所宣称的主要能力,因此应判定为描述与代码行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

代码的核心目标与描述大体相关,确实是在做建筑规范PDF条文提取、去重、编号切分、带圈数字转换、OCR错误标记、简单清洗和JSON输出。但描述中几个重要能力在代码里没有实现:1)没有RapidOCR或任何OCR库调用,因此不支持纯图片PDF识别;2)没有飞书多维表格写入逻辑;3)若干宣称的文本清洗细项仅部分体现,例如页眉关键词过滤和部分后处理存在,但未见中英文粘连修复、符号表专项处理、过长文本切分等。因此描述比实际能力明显更强,属于描述与行为不完全一致。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

代码整体仍与“从规范PDF提取条文并输出JSON”这一大方向相关,但声明描述了一个更完整的端到端能力,包括双层文本去重、纯图片OCR、编号规范化、文本清洗、质量标记,以及直接写入飞书多维表格。当前代码块实际只清晰展示了OCR补处理与JSON输出:它会检查已有JSON是否为空,针对失败PDF进行文字层提取或OCR,再调用外部解析函数生成JSON。最显著的缺口是完全没有飞书相关接口或网络写入行为,因此声明中的“同步到飞书多维表格”未被代码体现。此外,声明中若干精细清洗/规范化能力并未在该代码块中直接出现,只能部分推测由外部函数承担。基于提供的代码块,描述比实际行为更宽,存在明显不一致。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明描述的是一个端到端的‘PDF规范条文提取与同步飞书’技能,而给出的代码片段只是后处理阶段的质量检查脚本。它读取固定目录下已有的JSON文件并打印质量问题报告,属于辅助审查功能,而非所宣称的主功能。虽然声明中提到OCR错误检测、质量标记、文本清洗相关问题,代码确实覆盖了其中一小部分质量检测逻辑,但缺失了核心能力:PDF处理、OCR提取、条文切分、清洗输出、以及飞书写入。因此该代码与声明用途存在明显的功能范围和主要目的不匹配。

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill documents file processing, local JSON rewriting, and Feishu synchronization, but it does not declare any explicit tool scope or permission boundaries. In an agent environment, missing scope declarations can allow broader-than-expected file and network access, increasing the chance of unintended data exposure or misuse when handling PDFs and extracted content.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

Broad trigger phrases can cause the skill to activate in situations beyond the user's intent, especially in multi-skill agent systems. Because this skill processes files and may sync content externally, overbroad activation raises the risk of accidental handling of sensitive PDFs or unintended downstream transmission.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill advertises synchronization to Feishu but does not clearly warn that extracted document content may be transmitted to an external service. In this context, the PDFs may contain proprietary, regulated, or internal engineering material, so silent or under-disclosed exfiltration to a third-party platform creates a meaningful confidentiality and compliance risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documentation explicitly describes a destructive batch_delete capability without any warning, confirmation requirement, or guidance on safe use. In an automation skill that reads and writes Feishu Bitable records, omission of deletion safeguards can lead an agent or operator to remove large numbers of records accidentally or in response to ambiguous prompts, causing data loss.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code file performs a file write that replaces the original JSON content, which can alter user data irreversibly if the cleaning logic removes needed text. Although the script prints per-file results afterward, there is no user-facing warning before the overwrite and no confirmation prompt or backup behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This code opens the provided JSON path for writing and replaces the original file contents after applying filtering and text transformations. Although the script's top docstring describes cleaning behavior, it does not clearly warn the user at execution time that the original input file will be modified destructively in place, which is a safety-relevant file operation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The module docstring states the script checks quality issues for JSON files in Chinese, and the rest of the script hard-codes Chinese-centric logic such as Chinese-character regex checks and Chinese-only output labels. There is no user opt-in, language selection, or documented justification that this skill is intentionally limited to Chinese-language content.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This line imposes a specific output encoding unconditionally, which is a language/locale-related behavior applicable to all runs. The file does not provide an opt-in, fallback, or documentation justifying why UTF-8 must be forced for the user's environment.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

Natural-language strings in the module docstring and user-facing output are entirely Chinese, and the CLI provides no language selection or opt-in. Under the policy, forcing a specific language without user choice can be a locale-policy violation unless the constraint is clearly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The module docstring presents the skill description and usage entirely in Chinese, which constitutes a natural-language locale constraint visible to users. There is no indication that other languages are supported or that the Chinese-only presentation is intentional and limited to a region-specific compliance context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The file’s user-facing natural language instructions and descriptions are entirely in Chinese, including the primary module docstring and operational comments. Under the policy rule for natural-language violations, this effectively imposes a specific language without opt-in or an explicit statement that the skill is region-specific.

Content

No source excerpt is available for this finding.