Back to skill

Security audit

飞书发票报销机器人管理

Security checks for vulnerabilities and agentic risk

Overview

This skill appears purpose-built for managing a Feishu invoice reimbursement bot, but it has review-worthy risks around command execution, secrets exposure, and host modification.

Review this skill before installing. Use it only in a trusted local environment, avoid pasting real Feishu secrets into chat or logs, pin and review dependencies, restrict BOT_DIR to a known safe directory, and do not run the start/config commands with elevated privileges until command construction and secret masking are fixed.

Vulnerability Patterns
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/manage.py:22
Finding

Shell Command Injection Through the BOT_DIR Environment Variable

Content
View full analysis
> {LOG_FILE} 2>&1" ) result = subprocess.run( ["tmux", "new-session", "-d", "-s", TMUX_SESSION, cmd], capture_output=True, text=True, ) ``` ### Technical Analysis `BOT_DIR` is obtained from an environment variable and interpolated directly into a command string without validation or shell quoting. The string is supplied to `tmux new-session` as the session command. Tmux executes such command strings through a shell, so shell metacharacters in `BOT_DIR` are interpreted as command syntax rather than as part of a directory name. Although `subprocess.run` itself receives an argument list, this does not prevent injection because the final argument is subsequently interpreted as a shell command by tmux. ### Attack Path 1. An attacker gains control over the environment used to invoke the management script, or persuades an operator or Agent to configure a malicious `BOT_DIR`. 2. The attacker assigns a value containing shell syntax, for example: ```bash export BOT_DIR='/tmp/nonexistent; touch /tmp/invoice-bot-compromised #' ``` 3. The operator or Agent invokes: ```bash python3 scripts/manage.py start ``` 4. The generated command becomes equivalent to: ```bash cd /tmp/nonexistent; touch /tmp/invoice-bot-compromised # && python3 invoice_orchestrator.py ... ``` 5. Tmux passes the command to a shell, which executes the injected command. ### Impact Assessment Successful exploitation provides arbitrary command execution with the privileges of the user running `manage.py`. An attacker could read or modify files available to that user, access Feishu credentials in `.env`, alter the external invoice bot, submit ...[truncated 225 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/manage.py:155
Finding

Plaintext Disclosure of Sensitive Configuration Values

Content
View full analysis
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
SKILL.md:66
Finding

Unpinned Third-Party Dependencies and Dynamically Resolved Package Execution

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Note
Location
scripts/manage.py:29
Finding

Bot Start Operation Performs Undeclared Automatic System Package Installation

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (27)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description presents this skill as a management interface for a Feishu/Lark invoice reimbursement bot, including operational controls and administrative tasks. The supplied code instead is a standalone script test_ocr.py whose purpose is to test OCR on a single invoice file, optionally output JSON, and perform QR verification. While the description does mention OCR debugging/testing, that is only one subset of the declared scope. The main code shown does not start or stop an agent, monitor a running bot, modify configuration, or inspect approval templates, nor does it interact with Feishu APIs or CLI management functions. Therefore the code materially underdelivers and has a different primary purpose from the declared skill description.

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 · scripts/manage.py (reported line 29)May include surrounding context.

python
LOG_FILE = BOT_DIR / "invoice_bot.log"
TMUX_SESSION = "invoice-bot"
ORCHESTRATOR = "invoice_orchestrator.py"
ENV_FILE = BOT_DIR / ".env"


def _ensure_tmux():

Credential Access

High
Category
Privilege Escalation
Confidence
88% confidence
Finding

The command is explicitly designed to view or modify the .env file, which contains operational secrets. In a local admin script this may be intentional, but when packaged as an agent skill, exposing credential-bearing configuration through a management interface meaningfully increases the risk of unauthorized secret access or tampering.

Content

Scanner excerpt · scripts/manage.py (reported line 171)May include surrounding context.

python
def cmd_config(key: str = None, value: str = None):
    """查看或修改 .env 配置"""
    if not ENV_FILE.exists():
        print(f"⚠️ .env 文件不存在: {ENV_FILE}")
        return

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 · scripts/manage.py (reported line 173)May include surrounding context.

python
def cmd_config(key: str = None, value: str = None):
    """查看或修改 .env 配置"""
    if not ENV_FILE.exists():
        print(f"⚠️ .env 文件不存在: {ENV_FILE}")
        return

    if key and value:

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill describes shell execution, environment-variable access, file reads, and file writes, but it does not declare an explicit permission or allowed-tools scope. That creates an under-specified trust boundary: a caller may invoke a skill that can manipulate bot processes, credentials, and configuration files without any machine-readable restriction or review gate.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill processes invoice images/PDFs and submits approval data through Feishu services, but it does not clearly disclose that potentially sensitive financial documents and metadata are transmitted to third-party services. This omission undermines informed consent and can create privacy, compliance, or data-handling risks for invoices that contain personal or corporate financial information.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill instructs users to configure and handle sensitive values such as FEISHU_APP_SECRET and to edit $BOT_DIR/.env, but it does not warn about credential exposure, secret storage hygiene, or the risks of modifying configuration files. In practice, this can lead users to paste secrets into chat, logs, shell history, or world-readable files, increasing the chance of credential compromise.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
86% confidence
Finding

Using npx skills add larksuite/cli -y -g without a pinned version makes installation non-reproducible and exposes users to supply-chain risk if the upstream package changes or is compromised. Because this skill manages a bot with access to invoices and Feishu credentials, a malicious or broken update could execute code during setup with meaningful access.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
86% confidence
Finding

The dependency section again references npx skills add larksuite/cli -y -g without pinning a version, repeating the same supply-chain exposure. Repetition in installation docs increases the chance users will follow the unsafe pattern in production setups.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The file explicitly instructs that invoice images be uploaded to Feishu approval attachments and file codes written into a field, which affects user data and privacy. The markdown contains no warning or disclosure that sensitive invoice information and attachments will be transmitted to an external approval system.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The guide shows how to retrieve and use a Feishu App Secret but does not warn that it is a sensitive credential, should never be committed to files/screenshots, and must be protected from logs or chat transcripts. In a skill focused on managing an invoice/OCR reimbursement bot, these credentials can enable unauthorized API access to messages, files, and approval workflows if mishandled.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Automatically installing tmux exceeds the declared scope of start/stop/monitor behavior and silently mutates the host system. This widens the attack surface and can violate least surprise and least privilege, especially for an agent skill expected to perform bounded operational tasks.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/manage.py (reported line 34)May include surrounding context.

python
def _ensure_tmux():
    """检查 tmux 是否可用,不可用时尝试安装"""
    if subprocess.run(["which", "tmux"], capture_output=True).returncode == 0:
        return True
    print("⏳ tmux 未安装,正在尝试安装...")
    result = subprocess.run(

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
93% confidence
Finding

The script automatically installs tmux via Homebrew when it is missing. For a management utility, invoking a package manager changes system state and executes externally provided software, which expands the tool's privilege and trust boundary beyond simple bot lifecycle management. In this skill context, that is riskier because the agent is supposed to manage an invoice bot, not modify the host environment.

Content

Scanner excerpt · scripts/manage.py (reported line 37)May include surrounding context.

python
if subprocess.run(["which", "tmux"], capture_output=True).returncode == 0:
        return True
    print("⏳ tmux 未安装,正在尝试安装...")
    result = subprocess.run(
        ["brew", "install", "tmux"],
        capture_output=True, text=True,
    )

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
97% confidence
Finding

The tmux session is started with a single shell command string built from BOT_DIR and log path values derived from environment/configurable paths. Because tmux executes the command through a shell, a malicious BOT_DIR value containing shell metacharacters could trigger command injection and arbitrary code execution. The skill context makes this more dangerous because it is an admin-style bot management script that may be run with elevated local privileges.

Content

Scanner excerpt · scripts/manage.py (reported line 65)May include surrounding context.

python
f"cd {BOT_DIR} && "
        f"python3 {ORCHESTRATOR} >> {LOG_FILE} 2>&1"
    )
    result = subprocess.run(
        ["tmux", "new-session", "-d", "-s", TMUX_SESSION, cmd],
        capture_output=True, text=True,
    )

Tainted flow: 'cmd' from os.environ.get (line 61, credential/environment) → subprocess.run (code execution)

Medium
Category
Data Flow
Confidence
98% confidence
Finding

This is a true tainted-data issue: BOT_DIR is sourced from the BOT_DIR environment variable and interpolated into a shell-like command passed to tmux. If an attacker can influence the environment, they can inject additional shell syntax and execute arbitrary commands, potentially gaining code execution under the privileges of the operator running the script.

Content

Scanner excerpt · scripts/manage.py (reported line 65)May include surrounding context.

python
f"cd {BOT_DIR} && "
        f"python3 {ORCHESTRATOR} >> {LOG_FILE} 2>&1"
    )
    result = subprocess.run(
        ["tmux", "new-session", "-d", "-s", TMUX_SESSION, cmd],
        capture_output=True, text=True,
    )

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

Medium
Category
Data Flow
Confidence
90% confidence
Finding

PID_FILE is derived from BOT_DIR, which comes from an environment variable, so the script can be tricked into writing a PID file to an attacker-chosen location. If run with elevated privileges, this becomes an arbitrary file write primitive that can overwrite or create files outside the intended bot directory. In this admin skill context, operator-run scripts are more likely to have access to sensitive filesystem locations.

Content

Scanner excerpt · scripts/manage.py (reported line 79)May include surrounding context.

python
pid = get_pid()
    if pid:
        with open(PID_FILE, "w") as f:
            f.write(str(pid))
        print(f"✅ 机器人已启动 (tmux session: {TMUX_SESSION}, PID: {pid})")
    else:

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/manage.py (reported line 104)May include surrounding context.

python
pass

    # 强制关闭 tmux session
    subprocess.run(
        ["tmux", "kill-session", "-t", TMUX_SESSION],
        capture_output=True,
    )

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/manage.py (reported line 137)May include surrounding context.

python
print("❌ 机器人未运行")

    # 2. 飞书 CLI 连接
    result = subprocess.run(
        ["lark-cli", "auth", "status"],
        capture_output=True, text=True, timeout=10,
    )

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The config command exposes environment configuration with insufficient safeguards and no strong warning, making accidental secret leakage likely. Because this script manages an invoice reimbursement bot, the .env may contain bot tokens, tenant credentials, webhook endpoints, or OCR service secrets, so disclosure could enable takeover or unauthorized API access.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The code claims to hide secrets but only masks lines containing the literal string 'SECRET'. Many sensitive .env values such as tokens, API keys, app IDs, webhook URLs, database passwords, or credentials under other names will be printed in full, leading to credential disclosure. This is especially dangerous in a bot-management skill where operators are likely to inspect configuration during debugging and may paste output into chats or tickets.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/manage.py (reported line 230)May include surrounding context.

python
def check_running() -> bool:
    """检查机器人是否在运行"""
    # 检查 tmux session
    result = subprocess.run(
        ["tmux", "has-session", "-t", TMUX_SESSION],
        capture_output=True,
    )

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This is a natural-language policy concern because the skill presents its usage instructions exclusively in a single language, which can force a locale on users without opt-in. The file does not indicate that the tool is restricted to a Chinese-speaking environment or provide an alternative language option.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
74% confidence
Finding

The skill description and trigger phrases are entirely Chinese-focused, centered on Chinese invoice reimbursement workflows, with no indication that users may opt into another language or locale. For SQP-3, a language or locale constraint should either offer user choice or be explicitly documented and justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

All headings, field names, and instructions are presented only in Chinese, with no note that the skill is region-specific or that users can choose another language. Under the stated policy, forcing a single language without opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.