Back to skill

Security audit

Excel 全栈处理技能

Security checks for vulnerabilities and agentic risk

Overview

This is mostly a normal Excel helper, but it needs review because one test script can import code from an outside hard-coded path and the package has unsafe install and spreadsheet-output handling.

Review before installing. Do not run scripts/test_toolkit.py until the hard-coded sys.path entry is removed. Install dependencies in an isolated environment with pinned versions from a trusted index, treat generated XLSX files from untrusted CSV/JSON/PDF inputs as potentially formula-bearing, and require explicit confirmation before any Feishu cloud read/write/append operation.

Vulnerability Patterns
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/excel_toolkit.py:45
Finding
Spreadsheet Formula Injection in Generated Excel Workbooks<![CDATA[ ## Vulnerability Details **File Location**: `scripts/excel_toolkit.py`, lines 45–47 **Vulnerability Type**: Spreadsheet formula injection **Risk Level**: High ### Vulnerable Code ```python # Write headers and data ws.append(list(df.columns)) for row in df.itertuples(index=False): ws.append(list(row)) ``` The affected function is reachable through conversion and report-generation operations: ```python df = read_data(src) if dst.endswith('.csv'): df.to_csv(dst, index=False, encoding='utf-8-sig') elif dst.endswith('.xlsx'): write_report(df, dst) ``` ### Technical Analysis The `write_report` function copies column names and cell values from a pandas `DataFrame` directly into an XLSX workbook. It does not distinguish ordinary text from values beginning with formula-control characters such as: - `=` - `+` - `-` - `@` When attacker-controlled CSV or JSON data contains such a value, `openpyxl` can store it as an active spreadsheet formula rather than inert text. The generated workbook therefore crosses a trust boundary: content from an untrusted source becomes executable spreadsheet syntax. Depending on the spreadsheet application and its security configuration, malicious formulas can: - Cause outbound requests that disclose data through attacker-controlled URLs. - Display deceptive values or links. - Reference external workbooks or resources. - Abuse application-specific formula or external-data features. - Trigger legacy command-execution behavior in vulnerable or permissively configured spreadsheet environments. ### Attack Path 1. An attacker creates a CSV or JSON document containing a malicious cell, such as a value beginning with `=`. 2. A user runs the toolkit's `convert` or `report` command on the attacker-controlled document. 3. `read_data` imports the malicious value into a `DataFrame`. 4. `write_report` passes the value directly to `ws.append` without neutralization. 5. The toolkit saves the value as an active formula in the ...[truncated 1026 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Sanitize all externally sourced headers and string values before writing them to a spreadsheet. 2. Treat strings beginning with `=`, `+`, `-`, or `@` as potentially dangerous. 3. Prefix dangerous values with an apostrophe or explicitly force the destination cell to use a string data type. 4. Apply protection to both data cells and column headers. 5. Make formula support opt-in rather than enabled implicitly for imported data. 6. Document whether formula preservation is expected for XLSX-to-XLSX operations. Example defensive helper: ```python def neutralize_spreadsheet_formula(value): if isinstance(value, str) and value.startswith(("=", "+", "-", "@")): return "'" + value return value ``` Apply it before writing: ```python ws.append([neutralize_spreadsheet_formula(v) for v in df.columns]) for row in df.itertuples(index=False): ws.append([neutralize_spreadsheet_formula(v) for v in row]) ``` Add regression tests covering malicious values in both headers and cells, and verify that reopening the resulting workbook returns literal text rather than formula cells. ]]>

T07 · Tool Hijacking and Spoofing

Error
Location
scripts/test_toolkit.py:5
Finding
Arbitrary Module Execution Through Hard-Coded Import Path Precedence<![CDATA[ ## Vulnerability Details **File Location**: `scripts/test_toolkit.py`, lines 5–6 **Vulnerability Type**: Python module import hijacking **Risk Level**: High ### Vulnerable Code ```python sys.path.insert(0, r'C:\Users\Administrator\.openclaw\workspace\linlan-skills\excel-skills\scripts') from excel_toolkit import read_data, write_report, merge_sheets ``` ### Technical Analysis The test script inserts an absolute external directory at index zero of `sys.path`. Index zero has the highest import precedence, so Python searches this external location before normal package and local project locations. The subsequent import executes the top-level code of whichever `excel_toolkit.py` Python finds first in that directory. Consequently, the documented regression test may execute a different module from the bundled and audited `scripts/excel_toolkit.py`. This creates a module-preloading vulnerability when the external directory is: - Writable by another user or process. - Left over from a previous installation. - Replaced by an attacker-controlled junction, symbolic link, or directory. - Populated with a malicious `excel_toolkit.py`. - Used on the original developer's system while containing modified code. Python imports execute module-level statements immediately. An attacker does not need to provide the expected functions if malicious actions occur before the import fails. ### Attack Path 1. The target system contains the hard-coded directory, or an attacker creates it where permissions allow. 2. The attacker places a malicious `excel_toolkit.py` in that directory or redirects the directory to attacker-controlled content. 3. A user follows the README instruction and runs `python scripts/test_toolkit.py`. 4. The test script places the external directory first in `sys.path`. 5. Python imports the attacker's `excel_toolkit.py` instead of the project-local module. 6. Top-level attacker code executes with the privileges and environment of the user running ...[truncated 652 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Remove the hard-coded external path and load the module from a path derived from the test script itself. For example: ```python from pathlib import Path import sys SCRIPT_DIR = Path(__file__).resolve().parent sys.path.insert(0, str(SCRIPT_DIR)) from excel_toolkit import read_data, write_report, merge_sheets ``` For stronger isolation: 1. Convert the project into an installable Python package. 2. Use package-relative imports under a test framework such as `pytest`. 3. Run tests in a clean virtual environment. 4. Assert that the imported module originates from the expected project directory: ```python import excel_toolkit expected = (SCRIPT_DIR / "excel_toolkit.py").resolve() actual = Path(excel_toolkit.__file__).resolve() assert actual == expected, f"Unexpected module loaded: {actual}" ``` 5. Avoid inserting user-specific, workspace-specific, or globally writable directories at the beginning of `sys.path`. ]]>

T08 · Insecure Dependencies

Warning
Location
README.md:54
Finding
Unpinned Dependencies Installed from a Third-Party Package Mirror<![CDATA[ ## Vulnerability Details **File Location**: `README.md`, line 54 **Additional Location**: `SKILL.md`, line 20 **Vulnerability Type**: Dependency supply-chain exposure **Risk Level**: Medium ### Vulnerable Code From `README.md`: ```powershell python -m pip install pandas openpyxl pdfplumber -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com ``` From `SKILL.md`: ```powershell pip install openpyxl pandas -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com ``` ### Technical Analysis The installation instructions do not constrain dependencies to reviewed versions or verify package hashes. Each installation can therefore retrieve whichever release the package index currently serves. The instructions also direct users to a third-party mirror and explicitly designate that host as trusted. This expands the supply-chain trust boundary beyond the project and the canonical package index. Although HTTPS is used, `--trusted-host` weakens pip's normal host-verification expectations and is unnecessary when valid HTTPS certificate verification is available. No evidence was found that the named packages or mirror are currently malicious. The vulnerability is the unsafe and non-reproducible dependency acquisition process, which permits an upstream account compromise, malicious release, mirror compromise, or repository inconsistency to affect users after this project has been audited. The dependency lists are also inconsistent: `README.md` includes `pdfplumber`, while `SKILL.md` installs only `openpyxl` and `pandas`, despite the toolkit importing `pdfplumber` for PDF conversion. ### Attack Path 1. An attacker compromises an upstream package release process, package-maintainer account, or third-party mirror. 2. The compromised source serves a malicious version of `pandas`, `openpyxl`, `pdfplumber`, or one of their transitive dependencies. 3. A user follows the documented installation command at a later date. ...[truncated 962 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Create a reviewed dependency lock file with exact versions. 2. Generate and enforce cryptographic hashes for all direct and transitive dependencies. 3. Use pip's hash-checking mode, for example: ```text pandas==<reviewed-version> --hash=sha256:<verified-hash> openpyxl==<reviewed-version> --hash=sha256:<verified-hash> pdfplumber==<reviewed-version> --hash=sha256:<verified-hash> ``` ```powershell python -m pip install --require-hashes -r requirements.txt ``` 4. Prefer the canonical Python Package Index unless an organizationally managed and verified mirror is required. 5. Remove `--trusted-host` when the package source supports correctly validated HTTPS. 6. If a mirror must be used, document its governance, synchronization policy, and integrity controls. 7. Keep dependency declarations consistent across `README.md`, `SKILL.md`, and the lock file. 8. Add automated dependency vulnerability and provenance scanning to the release process. 9. Recommend installation in an isolated virtual environment without administrator privileges. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding
描述覆盖面明显大于代码实际能力。代码确实实现了部分已声明功能:文件读取、格式转换、样式化报表、多Sheet合并、PDF表格转Excel。但声明中的若干重要能力在代码中不存在,例如飞书云端表格、爬虫数据导出,以及更广义的工作簿编辑和数据清洗/分析能力。这里不属于危险的额外未声明能力,而是描述夸大、与实际实现不完全一致,因此应判定为描述与行为不匹配。

Natural-Language Policy Violations

Medium
Confidence
76% confidence
Finding
The entire skill README is presented only in Chinese, with no indication that users may choose another language or that the skill is intended exclusively for a Chinese-language context. This can be a natural-language policy issue when a skill effectively forces a specific language without opt-in or justification.

Natural-Language Policy Violations

Medium
Confidence
84% confidence
Finding
The top-level description is written as a Chinese-only skill description (`Excel全栈处理技能`) with no indication that language can be selected by the user. Under the stated policy, forcing a specific language or locale without opt-in is a natural-language policy concern unless the locale restriction is explicitly justified.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The skill includes write and append examples for Feishu cloud spreadsheets without requiring explicit confirmation, warning about external data transmission, or emphasizing that remote state will be modified. In an agent setting, this can lead to unintended exfiltration of sensitive spreadsheet contents or unauthorized modification of collaborative documents.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
Natural-language strings throughout the module, including the top-level description and CLI messages, are exclusively in Chinese, which imposes a fixed language on users. The policy allows locale constraints only when users can opt in or the restriction is clearly justified as region-specific, neither of which is present here.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
This code saves generated workbooks directly to the destination path, and similar write operations occur in the convert/report/merge flows. Although completion messages are printed after success, there is no prior disclosure or warning that the command will create or overwrite files at the specified path.

Missing User Warnings

Low
Confidence
84% confidence
Finding
This markdown file documents commands that generate or write Excel outputs such as report generation, sheet merging, and PDF-to-Excel conversion, but it does not warn users that these actions create or overwrite files. Under the markdown-specific warning criterion, behaviours affecting user data or local files should be disclosed clearly.

Static analysis

No suspicious patterns detected.