Back to skill

Security audit

Office Action Response · PatentMax

Security checks for vulnerabilities and agentic risk

Overview

This patent-drafting skill needs review because server-provided filenames can cause files to be saved outside your chosen folder.

Prefer a version that confines output paths and protects credentials when first created. Full patent materials are processed at api.ip930.com, and each task is listed at ¥15; confirm that external processing is acceptable for your confidential documents. Avoid sending API keys through chat.

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 metadata can escape the selected output directory

Content
View full analysis

Impact

For example, a title of ../outside causes a downloaded .docx file to be created in the output directory's parent when that directory is writable. Absolute titles can redirect writes to other existing writable directories. Existing-file collision avoidance and the fixed .docx suffix limit the impact; arbitrary overwrite and code execution are not established.

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

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
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 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):

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.

The drafting skill uploads full patent materials to an external service without disclosing remote processing in its manifest.

High
Category
Excessive Agency
Confidence
97% confidence
Finding

The client sends full office actions, application documents, specifications, and supplied references to an external service, but the supplied description presents a drafting capability without disclosing that transfer. These materials may contain confidential inventions or client information, and the --yes gate requests payment approval rather than explicit informed consent to external processing.

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 = "office-action-response"
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
89% confidence
Finding

Caching the trial key is legitimate, but the file is created and populated before chmod restricts its permissions. With a permissive umask, another local user can briefly read the credential, and a failure before chmod can leave it exposed; the environment-derived directory alone is not the vulnerability.

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
97% confidence
Finding

The actual unsafe input is the server-provided required_action.type, which is interpolated into a filename without validation. Traversal components can escape the selected output directory after unique_path normalizes the path, allowing a malicious or compromised service to create JSON files elsewhere with the process's permissions.

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 downloaded document's server-provided title or key is used directly as the beginning of a local filename. An absolute path or traversal sequence can escape the output directory, allowing a compromised service to place attacker-controlled bytes at an unintended writable path; sanitizing only stem does not prevent this.

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",

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]