Back to skill

Security audit

库存慧眼 / Inventory Eye

Security checks for vulnerabilities and agentic risk

Overview

This inventory skill is mostly purpose-aligned, but it can change business inventory records and export data to arbitrary writable file paths without strong safeguards.

Review this before installing if the agent will run with access to important local files or production inventory records. Use a dedicated data directory and sandbox if possible, avoid arbitrary export paths, and require explicit confirmation before import, update, delete, inbound, outbound, or export actions.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/inventory_store.py:347
Finding

Arbitrary File Overwrite Through an Unrestricted Export Destination

Content
View full analysis

Vulnerability Details

File Location: scripts/inventory_store.py:347-369
Vulnerability Type: Arbitrary file write and overwrite
Risk Level: High

python
data = read_json_input(args)
output_path = None
if data and data.get("output"):
    output_path = data["output"]
elif args.file:
    output_path = args.file

if not output_path:
    output_path = os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        "..", "output",
        f"inventory_export_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv",
    )

os.makedirs(os.path.dirname(os.path.abspath(output_path)), exist_ok=True)

fieldnames = [
    "sku_id", "name", "category", "quantity", "unit_cost", "selling_price",
    "safety_stock", "warehouse", "expiry_date", "last_inbound_date",
    "last_outbound_date", "created_at", "updated_at",
]

with open(output_path, "w", encoding="utf-8-sig", newline="") as f:

Technical Analysis

The export destination is obtained directly from the user-controlled JSON output property or the --file command-line argument. The path is not canonicalized or restricted to IE_DATA_DIR or another dedicated export directory.

The code creates missing parent directories and opens the destination in w mode. Consequently, an existing file is truncated before CSV data is written. Absolute paths, relative traversal paths such as ../../target, and paths traversing writable symbolic links are not rejected.

This behavior also conflicts with the security declaration at SKILL.md:268, which states that file operations are limited to the directory specified by IE_DATA_DIR.

Attack Path

  1. An attacker supplies or induces an export request containing a chosen destination, for example through the output JSON property or --file.
  2. The Agent invokes the export action with that attacker-controlled path.
  3. The script resolves no security boundary and creates the destination's pare ...[truncated 682 chars]
Remediation
View remediation

Remediation Suggestions

  1. Place all exports in a dedicated directory under IE_DATA_DIR.
  2. Canonicalize both the permitted base directory and requested destination with os.path.realpath().
  3. Use os.path.commonpath() to verify that the canonical destination remains inside the permitted export directory.
  4. Reject absolute paths, traversal components, symbolic-link destinations, and non-regular existing files.
  5. Do not overwrite existing files by default. Use exclusive creation mode or require explicit, trusted confirmation.
  6. Write to a securely created temporary file in the same directory and atomically rename it after a successful export.
  7. Apply restrictive directory and file permissions appropriate for inventory data.
  8. Add tests covering absolute paths, .. traversal, symbolic links, pre-existing files, and paths outside IE_DATA_DIR.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/inventory_store.py:369
Finding

CSV Formula Injection Through Unescaped Inventory Fields

Content
View full analysis

Vulnerability Details

File Location: scripts/inventory_store.py:49-51, scripts/inventory_store.py:238-249, and scripts/inventory_store.py:369-372
Vulnerability Type: CSV formula injection
Risk Level: Medium

python
return {
    "sku_id": format_sku(sku["sku_id"]),
    "name": str(sku["name"]).strip(),
python
for key, val in data.items():
    if key in ("created_at",):
        continue
    if key == "sku_id":
        s[key] = format_sku(val)
    elif key == "quantity":
        s[key] = max(0, int(float(val)))
    elif key in ("unit_cost", "selling_price"):
        s[key] = round(float(val), 2)
    elif key == "safety_stock":
        s[key] = max(0, int(float(val)))
    elif key in ("expiry_date", "last_inbound_date", "last_outbound_date"):
        parsed = parse_date(val)
        if parsed:
            s[key] = parsed
    else:
        s[key] = val
python
with open(output_path, "w", encoding="utf-8-sig", newline="") as f:
    writer = csv.DictWriter(f, fieldnames=fieldnames, extrasaction="ignore")
    writer.writeheader()
    writer.writerows(skus)

Technical Analysis

Inventory text fields originating from CSV imports or JSON updates are stored and later passed directly to csv.DictWriter. No output encoding neutralizes values beginning with spreadsheet formula prefixes such as =, +, -, or @. Leading tab and carriage-return characters are also not considered.

CSV quoting only preserves field boundaries; it does not prevent spreadsheet applications from interpreting cell contents as formulas. A malicious value in fields such as name, category, warehouse, or sku_id can therefore become an active formula when a user opens the exported file in formula-capable spreadsheet software.

Actual formula capabilities and prompts vary by spreadsheet product and security configuration, but the exported file crosses a data-to-code interpre ...[truncated 1171 chars]

Remediation
View remediation

Remediation Suggestions

  1. Introduce a centralized CSV-cell sanitization function for every exported string field.
  2. After accounting for leading whitespace, neutralize cells beginning with =, +, -, @, tab, carriage return, or other prefixes recognized by supported spreadsheet applications.
  3. Use a documented defensive representation, such as prepending an apostrophe, when spreadsheet compatibility is required.
  4. Preserve the original value in JSON storage if needed, but apply neutralization at the CSV export boundary.
  5. Consider offering a non-executable export format, such as JSON, for untrusted inventory content.
  6. Warn users that exported CSV files can contain untrusted data and should not have formulas or external content enabled.
  7. Add regression tests for all dangerous prefixes, quoted fields, leading whitespace, multiline values, and values imported through both CSV and JSON update paths.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (21)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill advertises capabilities like slow-moving and expiry analysis, while the documented implementation appears incomplete or inconsistent and also includes subscription-gating behavior not reflected in the summary. This is primarily a trust and transparency issue: users may rely on analyses that are absent or incomplete, leading to operational mistakes based on false assumptions.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The skill advertises capabilities like slow-moving and expiry analysis, while the documented implementation appears incomplete or inconsistent and also includes subscription-gating behavior not reflected in the summary. This is primarily a trust and transparency issue: users may rely on analyses that are absent or incomplete, leading to operational mistakes based on false assumptions.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The skill advertises capabilities like slow-moving and expiry analysis, while the documented implementation appears incomplete or inconsistent and also includes subscription-gating behavior not reflected in the summary. This is primarily a trust and transparency issue: users may rely on analyses that are absent or incomplete, leading to operational mistakes based on false assumptions.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill invokes environment-variable access and file read/write behavior but does not declare an explicit tool scope or permissions boundary. That creates an authorization ambiguity where the runtime may grant broader capabilities than users or reviewers expect, increasing the risk of unintended file access or persistence beyond the documented inventory workflow.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

L014 明确写明“你始终使用中文与用户沟通”,这属于对语言/locale 的强制要求。文件中未提供用户选择其他语言的选项,也未说明该技能仅面向特定中文地区或因合规原因必须使用中文,因此构成自然语言策略违规。

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill documents inbound and outbound commands that change inventory quantities but provides no strong user warning or mandatory confirmation for these state-changing actions. In an inventory context, accidental execution can directly corrupt stock records, disrupt replenishment decisions, and create financial or operational losses.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Broad trigger phrases such as generic references to stock movements can cause accidental invocation of write-capable workflows. In this skill, misclassification is more dangerous because some matched intents lead to inbound/outbound operations that modify inventory data, potentially causing unauthorized or erroneous stock changes.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

L276 再次规定“始终使用中文与用户沟通”,重复强化了单一语言强制策略。该要求没有任何用户 opt-in 机制,也没有限定为明确的区域专用工具说明,因此符合语言/locale 策略违规特征。

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The phrase “库存状况怎么样?” is a natural-language request that can easily occur in ordinary conversation and is not clearly scoped as an explicit skill invocation. In an agent environment, this raises the risk of unintended activation, causing the skill to access local inventory data or generate business-sensitive summaries when the user did not mean to invoke this specific skill.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The prompt “哪些商品该补货了?” is similarly broad and conversational, making it easy to match during general business discussion rather than deliberate skill use. If triggered unintentionally, the agent could analyze local stock records and expose operational information such as low-stock items, sales velocity assumptions, or replenishment priorities.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The entire guide is written in Chinese and is described as reference material for an AI assistant answering user questions, which can effectively constrain responses to a specific language. There is no indication that the user can choose another language, nor any documented business or regional justification for this locale restriction.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

User-facing descriptions, help text, docstrings, and error/output messages throughout the file are written exclusively in Chinese, which imposes a specific language/locale on users. The file does not offer any language choice, opt-in, or explicit documentation that the tool is intentionally limited to a Chinese-speaking regional context.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest frames the skill as a monitoring tool for restocking, slow-moving items, and near-expiry stock, which suggests analytics or visibility-oriented behavior. This file instead implements full CRUD, CSV import/export, and inbound/outbound stock mutation workflows, substantially expanding from monitoring into operational inventory management.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The delete path permanently removes inventory records immediately after receiving a sku_id, with no confirmation step, soft-delete, undo, or audit safeguard in this function. In an agent or automated-tool context, accidental or prompted invocation could cause irreversible business-data loss and operational disruption.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The declared actions include import, add, update, delete, export, inbound, and outbound, which enable creating, modifying, deleting, and exporting inventory data. Those behaviors go beyond a lightweight monitoring skill description and indicate an inventory administration tool instead.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file contains user-facing natural-language descriptions entirely in Chinese, including the module docstring and later CLI help/output text, with no indication that language is configurable or limited to a China-specific deployment. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The command description and argument help strings are presented only in Chinese, and the rest of the script's user-facing messages follow the same pattern. Because the file provides no opt-in or alternative locale handling, it effectively enforces a specific language on all users.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file contains user-facing natural-language descriptions entirely in Chinese, including the module docstring describing the skill's behavior. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is explicitly documented and justified, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The command-line description and help strings are presented only in Chinese, and the rest of the emitted status/error messages in the file also assume Chinese output. Because the file does not provide a language selection mechanism or explicit justification for a Chinese-only locale, this conflicts with the language/locale policy criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This is a natural-language policy issue because the file presents its interface and outputs entirely in a specific language. The code does not indicate that Chinese is optional, configurable, or required for a documented region-specific use case.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This Python file's top-level docstring and all user-facing documentation are written only in Chinese, indicating the skill is designed around a single language/locale. The policy for SQP-3 flags language or locale constraints when the skill does not offer a user language choice or clearly justify the restriction.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.