Back to skill

Security audit

OA答复 · PatentMax

Security checks for vulnerabilities and agentic risk

Overview

The paid patent-drafting workflow is disclosed, but unsafe download paths and credential handling warrant review before installation.

Prefer a corrected version that confines downloads, restricts authenticated requests to approved HTTPS destinations, and securely stores keys. Full patent documents are sent to PatentMax and each report costs ¥15; confirm that external processing suits your confidentiality requirements.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/patentmax_oa.py
Finding

Remote document titles escape the authorized output directory

Content
View full analysis

Impact

A title such as '../outside' creates a document in the output directory's parent rather than inside it. Absolute titles can similarly select other writable locations. The resulting filename retains the generated stem and .docx suffix. unique_path() avoids ordinary existing-file overwrites but does not prevent directory escape.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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)

Tainted flow: 'req' from os.environ.get (line 146, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/patentmax_oa.py (reported line 151)May include surrounding context.

python
req.add_header("Content-Type", "application/json")
    req.add_header("Accept", "application/json")
    try:
        with urllib.request.urlopen(req, timeout=30) as response:
            payload = json.loads(response.read().decode("utf-8"))
    except urllib.error.HTTPError as exc:
        _, message = _server_error(exc.read().decode("utf-8", "replace"))

Tainted flow: 'req' from os.environ.get (line 217, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
95% confidence
Finding

API authentication is expected, but _open attaches the API key without enforcing HTTPS or restricting the destination to a trusted origin. A malicious endpoint configuration or cross-origin redirect could expose the key and confidential patent materials; this is conditional on destination manipulation, not evidence of deliberate exfiltration.

Content

Scanner excerpt · scripts/patentmax_oa.py (reported line 224)May include surrounding context.

python
req.add_header("Content-Type", "application/json")
    for key, value in (headers or {}).items():
        req.add_header(key, value)
    return urllib.request.urlopen(req, timeout=TIMEOUT)


def request(path, method="GET", body=None, headers=None, raw=False):

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

The substantive OA-response workflow matches the declared purpose. However, the implementation adds materially undisclosed data-disclosure and financial effects: full patent materials are sent to a third-party API, and report creation initiates a paid service transaction. The explicit --yes gate mitigates accidental billing but does not resolve the description mismatch. Ordinary document reading, output writing, polling, and credential caching are supporting implementation details rather than independent mismatches. The supplied code does not establish malicious intent or unrelated data collection.

Content

No source excerpt is available for this finding.

Code capability 'env' detected in scripts/patentmax_oa.py but not covered by declared permissions.

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'env' capability that is not covered by the declared 'allowed-tools' preapproval. Review the host runtime's actual enforcement policy; runtime permissions are unknown unless separately verified, and this declaration alone does not establish a permission ceiling.

Content

No source excerpt is available for this finding.

Code capability 'network' detected in scripts/patentmax_oa.py but not covered by declared permissions.

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'network' capability that is not covered by the declared 'allowed-tools' preapproval. Review the host runtime's actual enforcement policy; runtime permissions are unknown unless separately verified, and this declaration alone does not establish a permission ceiling.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% 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/patentmax_oa.py (reported line 112)May include surrounding context.

python
# 密钥版(TRIAL_SOURCE 为空):必须设 PATENTMAX_API_KEY。
TRIAL_SOURCE = "oa-response-cn"
TRIAL_GROUP = "oa-response"
TRIAL_REGISTER_URL = "https://api.ip930.com/features/api-platform"
KEY_FROM_TRIAL = False

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% 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/patentmax_oa.py (reported line 180)May include surrounding context.

python
if API_KEY:
        return API_KEY
    if not TRIAL_SOURCE:
        die("还没有设置 PatentMax 密钥。到 https://api.ip930.com/features/api-platform 注册(新用户送 ¥50 体验额度)"
            "并创建密钥,设成环境变量 PATENTMAX_API_KEY=pm_live_xxx 后,再运行同一条命令。", EXIT_INPUT)
    API_KEY = _load_trial_key() or _claim_trial_key()
    KEY_FROM_TRIAL = True

Tainted flow: '_trial_key_path()' from os.environ.get (line 117, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
96% confidence
Finding

The trial API key is written before chmod restricts access, so its initial permissions depend on the process umask and may temporarily permit other local users to read it. Permission-setting failures are silently ignored, and ordinary open also follows pre-existing symlinks.

Content

Scanner excerpt · scripts/patentmax_oa.py (reported line 165)May include surrounding context.

python
die("领取免费试用失败:服务端没有返回密钥,请稍后重试。", free_trial=True)
    try:
        os.makedirs(cache_root(), exist_ok=True)
        with open(_trial_key_path(), "w", encoding="utf-8") as fh:
            json.dump({"api_key": key, "expires_at": data.get("expires_at"), "source": TRIAL_SOURCE, "base_url": BASE_URL},
                      fh, ensure_ascii=False, indent=2)
        os.chmod(_trial_key_path(), 0o600)

Tainted flow: 'operation' from os.environ.get (line 612, credential/environment) → 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/patentmax_oa.py (reported line 347)May include surrounding context.

python
record.update({k: v for k, v in fields.items() if v is not None})
    try:
        os.makedirs(os.path.dirname(_task_path(operation)), exist_ok=True)
        with open(_task_path(operation), "w", encoding="utf-8") as fh:
            json.dump(record, fh, ensure_ascii=False, indent=2)
    except OSError:
        pass

Tainted flow: 'full' from os.environ.get (line 471, credential/environment) → 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/patentmax_oa.py (reported line 472)May include surrounding context.

python
kind = action.get("type")
    target = out_dir_of(operation, out_dir)
    full = unique_path(os.path.join(target, f"{REPORT_NAME}_待确认_{kind or '下一步'}.json"))
    with open(full, "w", encoding="utf-8") as fh:
        json.dump(action, fh, ensure_ascii=False, indent=2)
    out = {"status": "requires_action", "operation_id": operation, "type": kind, "details_file": full,
           "expires_at": action.get("expires_at"),

Tainted flow: 'claims_file' from os.environ.get (line 495, credential/environment) → 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/patentmax_oa.py (reported line 496)May include surrounding context.

python
})
    elif kind == "confirm_claims":
        claims_file = unique_path(os.path.join(target, f"{REPORT_NAME}_修改后的权利要求.txt"))
        with open(claims_file, "w", encoding="utf-8") as fh:
            fh.write(action.get("claims_text") or "")
        out.update({
            "selected_strategy": action.get("selected_strategy_id"),

Tainted flow: 'path' from os.environ.get (line 554, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
99% confidence
Finding

The actual issue is unsanitized server-provided document title or key data in the output filename, not environment access. An absolute path or traversal sequence can cause a malicious report response to create a downloaded .docx outside the selected directory; unique_path does not enforce directory containment.

Content

Scanner excerpt · scripts/patentmax_oa.py (reported line 555)May include surrounding context.

python
if not content:
            continue
        path = unique_path(os.path.join(target, f"{doc.get('title') or doc.get('key')}_{stem}.docx"))
        with open(path, "wb") as fh:
            fh.write(content)
        (files if doc.get("formal", True) else internal)[doc.get("title") or doc.get("key")] = path
    statement = result.get("statement_text") or ""

Tainted flow: 'statement_file' from os.environ.get (line 559, credential/environment) → 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/patentmax_oa.py (reported line 560)May include surrounding context.

python
(files if doc.get("formal", True) else internal)[doc.get("title") or doc.get("key")] = path
    statement = result.get("statement_text") or ""
    statement_file = unique_path(os.path.join(target, f"意见陈述书_{stem}.md"))
    with open(statement_file, "w", encoding="utf-8") as fh:
        fh.write(statement)
    full = unique_path(os.path.join(target, f"{REPORT_NAME}_{stem}_完整结果.json"))
    with open(full, "w", encoding="utf-8") as fh:

Tainted flow: 'full' from os.environ.get (line 562, credential/environment) → 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/patentmax_oa.py (reported line 563)May include surrounding context.

python
with open(statement_file, "w", encoding="utf-8") as fh:
        fh.write(statement)
    full = unique_path(os.path.join(target, f"{REPORT_NAME}_{stem}_完整结果.json"))
    with open(full, "w", encoding="utf-8") as fh:
        json.dump(payload, fh, ensure_ascii=False, indent=2)
    return {
        "status": "succeeded",

The skill uploads complete patent materials to an external report-generation service without declaring this processing model in its manifest.

Medium
Category
Excessive Agency
Confidence
96% confidence
Finding

The skill uploads complete application, office-action, and optional reference materials to an external service, while its supplied description does not disclose remote processing. The --yes gate explicitly addresses payment rather than disclosure of confidential documents, which can include unpublished inventions and privileged legal strategy.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
85% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · scripts/patentmax_oa.py (reported line 602)May include surrounding context.

python
die("对比文件最多给 10 篇;没给的系统会按通知书里的公开号自己去取。", EXIT_INPUT)
        body["input"]["cited_references"] = [cited_entry(p) for p in args.cited]
    if args.auto:
        body["input"]["auto_confirm"] = True
    if args.title:
        body["input"]["title_hint"] = args.title[:255]