Back to skill

Security audit

胡田 OPC导师 IP工具包

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent IP-assistance toolkit, but it needs Review because it can send confidential invention search terms to a third-party patent API when credentials are present and documents an unpinned remote MCP package that would receive API credentials.

Install only if you are comfortable with a China-focused IP workflow and manually control when confidential invention details leave your machine. Use --free for local/free-tool guidance unless you intentionally want Zhiyuya API search, prefer environment or a secret manager over --api-key, avoid enabling the documented MCP server unless you can verify and pin the package version, and sanitize patent titles before saving generated drafts.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (4)

other

Warning
Location
scripts/prior-art-search.py:77
Finding

Automatic disclosure of potentially confidential invention keywords to a third-party API

Content
View full analysis

Vulnerability Details

File Location: scripts/prior-art-search.py, lines 77-91
Vulnerability Type: Sensitive data disclosure without explicit per-request confirmation
Risk Level: Medium

Complete Code Snippet

python
url = f"{self.base_url}/patent/search"
headers = {
    "Content-Type": "application/json",
    "X-App-Id": self.app_id,
    "X-App-Key": self.app_key
}
payload = {
    "query": query,
    "page_num": page,
    "page_size": page_size
}

response = requests.post(url, json=payload, headers=headers, timeout=30)

The API client is enabled automatically whenever the expected credentials are present:

python
use_api = not args.free and searcher.zhiyuya.available
report = searcher.generate_report(keywords, use_api)

Technical Analysis

Patent-search keywords may describe inventions before filing and can therefore constitute confidential business information or material relevant to patent novelty. The script transmits the complete user-supplied query to https://open.zhihuiya.com/v1/patent/search whenever API credentials are available. It does not show the exact destination and payload immediately before transmission, request affirmative consent, or warn that invention information will be disclosed to a third party.

The network operation is functionally relevant to the declared deep prior-art search capability and uses HTTPS with a timeout. It therefore does not appear covert or unrelated to the Skill. Nevertheless, automatically selecting the remote mode merely because credentials exist exceeds a privacy-preserving default. The minimum-privilege design would require an explicit remote-search option or confirmation and should transmit only the minimum search terms required.

The API credentials are also transmitted in request headers. That is necessary for authenticated API access, but it makes endpoint integrity and TLS validation critical.

Attack Path

...[truncated 1236 chars]

Remediation
View remediation

Remediation Suggestions

  • Make local/free mode the default and require an explicit --remote or --provider zhihuiya option.
  • Before the first transmission, display the destination host and identify the fields that will leave the machine; require confirmation in interactive use.
  • Add a non-interactive consent flag such as --allow-network for automation.
  • Warn users not to submit unpublished enabling details unless they have reviewed the provider's privacy, retention, and confidentiality terms.
  • Minimize queries by encouraging abstract search terms rather than complete technical descriptions.
  • Document data categories, destination, purpose, retention considerations, and the effect of --free.
  • Permit an administrator-controlled endpoint allowlist and reject redirects to unapproved hosts.
  • Use scoped, revocable API credentials and rotate them after suspected exposure.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/prior-art-search.py:403
Finding

API secrets accepted through command-line arguments can be exposed to other local users

Content
View full analysis

Vulnerability Details

File Location: scripts/prior-art-search.py, lines 403-414
Vulnerability Type: Credential exposure through process arguments
Risk Level: Medium

Complete Code Snippet

python
parser.add_argument('--api-id', type=str,
                    help='智慧芽API App ID(也可通过环境变量ZHIYUYA_APP_ID设置)')
parser.add_argument('--api-key', type=str,
                    help='智慧芽API App Key(也可通过环境变量ZHIYUYA_APP_KEY设置)')

args = parser.parse_args()

# 初始化检索器
if args.api_id and args.api_key:
    os.environ['ZHIYUYA_APP_ID'] = args.api_id
    os.environ['ZHIYUYA_APP_KEY'] = args.api_key

Technical Analysis

Command-line arguments are commonly visible through process inspection facilities, shell history, terminal logging, job schedulers, monitoring agents, and CI/CD build logs. Accepting a secret through --api-key therefore places the credential in channels that are not designed for confidential data.

Copying the value into an environment variable after argument parsing does not remove it from the original process argument vector. The secret can remain visible for the lifetime of the process and persist in shell or automation logs after execution.

This is unnecessary for the declared functionality because the script already supports environment-based credential loading. A protected credential file, secret manager, or non-echoing prompt would avoid exposing the key in process arguments.

Attack Path

  1. A user invokes the script with --api-key REAL_SECRET.
  2. The shell may save the full command in history.
  3. While the script is running, another local account or monitoring process with process-inspection access reads the command line.
  4. Alternatively, a CI/CD system records the invocation in job output or metadata.
  5. The observer extracts the API key and uses it directly against the provider.
  6. The attacker consumes quota or accesses any API operations authorized for the corre ...[truncated 601 chars]
Remediation
View remediation

Remediation Suggestions

  • Remove the --api-key argument.
  • Continue supporting environment variables for controlled deployments, but document their exposure considerations.
  • For interactive use, read the secret with getpass.getpass() so it is not echoed or stored in command history.
  • Support a credential file only if ownership and permissions are validated, such as mode 0600 on POSIX systems.
  • Prefer operating-system keychains or a deployment secret manager for production use.
  • Scope credentials to only the patent-search endpoints and minimum required quota.
  • Ensure logs never contain request headers or parsed arguments.
  • Rotate any credential that has previously been passed directly on the command line.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/patent-draft-helper.py:314
Finding

Unsanitized patent title permits output-directory traversal

Content
View full analysis

Vulnerability Details

File Location: scripts/patent-draft-helper.py, lines 314-322
Vulnerability Type: Path traversal and unintended file creation
Risk Level: Medium

Complete Code Snippet

python
for name, content in draft.items():
    filename = f"{self.data.get('title', 'patent')}_{name}_{timestamp}.md"
    filepath = os.path.join(output_dir, filename)

    with open(filepath, 'w', encoding='utf-8') as f:
        f.write(content)

    saved_files[name] = filepath
    print(f"✓ 已保存:{filepath}")

The title can originate from a user-controlled JSON file:

python
with open(filepath, 'r', encoding='utf-8') as f:
    self.data = json.load(f)

Technical Analysis

The generator incorporates the untrusted title field directly into an output filename. Path separators and traversal components are not removed, and the resulting path is not resolved and checked against the intended output directory.

A title containing ../ can cause generated files to be written outside ./output. A title beginning with a path separator can also cause os.path.join to disregard the intended output directory on platforms where the constructed filename is interpreted as absolute. The timestamp and document-type suffix constrain the exact final filename, but they do not prevent output-directory escape or creation of files in unintended writable directories.

The files are opened with mode w, so an existing file with the generated name will be truncated and replaced. The practical overwrite target must match the generated suffix, including the current timestamp, but uncontrolled file placement remains a security boundary violation.

Attack Path

  1. An attacker prepares a technical-brief JSON file with a title containing traversal components, such as ../../shared/report.
  2. A user selects the JSON-loading option and loads the file.
  3. The user elects to save the generated draft.
  4. `save_ ...[truncated 1003 chars]
Remediation
View remediation

Remediation Suggestions

  • Convert the title to a safe basename before using it in a filename.
  • Allow only a conservative character set, for example letters, digits, spaces, underscores, and hyphens.
  • Replace /, \, .., control characters, and platform-specific reserved characters.
  • Impose a reasonable title length limit.
  • Resolve both the output directory and destination path with pathlib.Path.resolve().
  • Verify that the resolved destination is contained within the resolved output directory before opening it.
  • Open new files with exclusive creation mode (x) when overwriting is not required.
  • Consider using an internally generated identifier for filenames and placing the human-readable title only inside the document.
  • Add tests covering absolute paths, ../, Windows separators, drive prefixes, Unicode separator lookalikes, and symbolic-link edge cases.

T03 · Remote Payload Retrieval and Execution

Warning
Location
references/api-integration.md:199
Finding

Documentation recommends execution of an unpinned remote package through npx

Content
View full analysis

Vulnerability Details

File Location: references/api-integration.md, lines 199-213
Vulnerability Type: Mutable remote package retrieval and execution
Risk Level: Medium

Complete Code Snippet

json
{
  "mcpServers": {
    "zhiyuya": {
      "command": "npx",
      "args": ["-y", "@zhiyuya/mcp-server"],
      "env": {
        "ZHIYUYA_APP_ID": "your_app_id",
        "ZHIYUYA_APP_KEY": "your_app_key"
      }
    }
  }
}

Technical Analysis

The suggested MCP configuration invokes npx with -y and an unpinned package name. If the package is not already installed, npx can retrieve it from the configured package registry and execute it without an interactive installation confirmation. Because no exact version or integrity value is specified, the executed code can change after this Skill has been reviewed.

The spawned package also receives the API application ID and key through its environment. A compromised package release, registry account, dependency, or registry configuration could read and exfiltrate those credentials and perform any action available to the local process.

This behavior is presented as optional advanced integration rather than being automatically executed by the included Python scripts. Exploitation therefore requires a user or agent to copy and enable the documented configuration. Even so, the recommendation creates a direct remote payload execution path and violates reproducible dependency management.

Attack Path

  1. A user copies the documented MCP configuration into an agent configuration.
  2. The user inserts valid API credentials.
  3. The agent starts the MCP server by running npx -y @zhiyuya/mcp-server.
  4. npx resolves the package version from the current package registry at execution time.
  5. A malicious or compromised current release, transitive dependency, package namespace, or registry mirror supplies attacker-controlled JavaScript.

...[truncated 818 chars]

Remediation
View remediation

Remediation Suggestions

  • Do not use npx -y with an unpinned package in operational configuration.
  • Verify the package name and publisher through the provider's authenticated documentation.
  • Pin an exact reviewed version, not a tag or version range.
  • Install dependencies through a committed lockfile and enforce package integrity hashes.
  • Disable lifecycle scripts during installation where feasible, then explicitly allow only reviewed scripts.
  • Use a trusted registry and protect against dependency confusion or registry-configuration overrides.
  • Run the MCP server in a sandbox or container with a read-only filesystem, restricted network egress, no access to unrelated home-directory files, and a non-privileged account.
  • Supply a narrowly scoped, revocable API key only after package verification.
  • Document the package's source, version, integrity digest, required permissions, and update-review process.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (16)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

声明描述的是覆盖专利、商标、软著三类知识产权的综合性工具,且强调“全方位保护与运营”。但代码仅实现专利撰写辅助:收集技术交底书信息,生成权利要求书、说明书框架和摘要,并保存输出文件。没有任何商标检索/申请、软著登记材料生成、知识产权管理、运营、保护、监测或分析等功能。因此,实际行为明显比声明范围窄,且主功能与声明的综合IP工具存在实质性不一致。代码中的本地文件读写属于实现细节,不是问题核心。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

描述范围明显大于代码实际功能。该脚本专注于专利领域中的查新检索:解析关键词、构造检索式、调用智慧芽专利API、列出免费专利检索网站、生成专利检索报告并保存。本代码没有任何商标检索、商标注册/监测、软件著作权登记、知识产权运营管理等实现。因此其实际行为只覆盖声明中的一小部分(专利),且不构成“专利、商标、软著三类知识产权全方位保护与运营工具”,属于实质性描述不符。

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · references/api-integration.md (reported line 379)May include surrounding context.

python
# 在 .gitignore 中添加
config.json
.env
*.key

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The natural-language content of the skill, including its description and operating instructions, is consistently presented only in Chinese. Under the policy, forcing a specific language without user opt-in or a documented justification is a locale/language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

文件标题及全文内容均以中文编写,未说明这是面向特定中文用户群体的区域性文档,也未给出其他语言选项。根据规则,若技能内容在语言/locale 上形成默认强制而没有用户选择或合理说明,可视为自然语言政策问题。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The file title and all instructional content are presented entirely in Chinese, with no indication that users may choose another language or that the content is intentionally limited to a Chinese-speaking audience. Under the policy, a skill that effectively requires a specific language without opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Tainted flow: 'filepath' from input (line 450, user input) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/patent-draft-helper.py (reported line 321)May include surrounding context.

python
filename = f"{self.data.get('title', 'patent')}_{name}_{timestamp}.md"
            filepath = os.path.join(output_dir, filename)
            
            with open(filepath, 'w', encoding='utf-8') as f:
                f.write(content)
            
            saved_files[name] = filepath

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · references/api-integration.md (reported line 88)May include surrounding context.

md
"page_size": page_size
            }
            
            response = requests.post(url, json=payload, headers=headers, timeout=30)
            
            if response.status_code == 200:
                return response.json()

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · references/api-integration.md (reported line 190)May include surrounding context.

md
"page_size": page_size
            }
            
            response = requests.post(url, json=payload, headers=headers, timeout=30)
            
            if response.status_code == 200:
                return response.json()

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/prior-art-search.py (reported line 91)May include surrounding context.

python
"page_size": page_size
            }
            
            response = requests.post(url, json=payload, headers=headers, timeout=30)
            
            if response.status_code == 200:
                return response.json()

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The user-facing documentation is entirely in Chinese, including the title, description, and usage instructions, with no indication that other languages are supported or that Chinese is a required locale. Under the policy rule for natural-language violations, this can be considered a language constraint without user opt-in or justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file consists solely of Chinese-language instructions and templates, with no indication that users can choose another language or that the content is intentionally limited to a Chinese-speaking or China-specific audience. Under the policy rule for language or locale constraints, forcing a specific language without opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The file presents the skill content entirely in Chinese from the title onward, with no indication that users may request another language or locale. Under the stated policy, language constraints should either be optional or explicitly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file contains instructional content only in Chinese, starting with the title and continuing throughout the document. Under the policy rule for natural-language violations, forcing a specific language without user opt-in can be a locale-policy issue when no alternative or justification is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The module docstring, CLI descriptions, status messages, and report text are presented in Chinese, which effectively forces a specific language/locale for users. Under the policy, locale constraints should either be optional or clearly justified; this file does not offer a language choice or state that it is intentionally limited to Chinese-speaking users.

Content

No source excerpt is available for this finding.