Back to skill

Security audit

liuyuxin - Local Guide

Security checks for vulnerabilities and agentic risk

Overview

This local recommendation skill is mostly coherent, but it contains unsafe shell-command paths that could let crafted search or card content run local commands.

Review before installing. The EXA and Feishu integrations are disclosed, but the skill should be patched to remove shell=True, avoid echoing generated JSON through a shell, validate Feishu recipient IDs, and avoid long-term plaintext API keys in shell startup files.

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/search_module.py:58
Finding

Shell Command Injection in the EXA Search Fallback

Content
View full analysis

Vulnerability Details

File Location: scripts/search_module.py, lines 58–59
Vulnerability Type: Shell command injection
Risk Level: High

Vulnerable Code:

python
cmd = f"mcporter call exa.web_search_exa query='{query}' numResults={num_results}"
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)

Technical Analysis

The fallback implementation interpolates query and num_results into a command string that is executed with shell=True. The query value can be assembled from caller-controlled location and recommendation-type values by multi_round_search().

Enclosing query in single quotes does not make the command safe. An input containing a single quote can terminate the quoted argument and append shell operators or additional commands. The system shell then interprets the injected syntax because shell=True is enabled.

The vulnerable path is used when the skill_orchestrator import is unavailable and the code falls back to invoking mcporter through subprocess.

Attack Path

  1. An attacker supplies a crafted location or recommendation type containing a single quote followed by shell syntax.
  2. multi_round_search() incorporates the supplied value into a search query.
  3. search_exa() receives that query.
  4. If the orchestrator-backed search interface is unavailable, the fallback constructs a shell command using the untrusted query.
  5. The injected single quote terminates the intended quoted argument.
  6. subprocess.run(..., shell=True) causes the shell to interpret and execute the appended command.
  7. The injected command runs with the operating-system privileges of the Agent or Skill process.

Impact Assessment

Successful exploitation permits arbitrary local command execution under the account running the Skill. Depending on that account's permissions, an attacker could read or modify accessible files, steal environment-based credential ...[truncated 273 chars]

Remediation
View remediation

Remediation Suggestions

Remove shell interpretation and pass arguments directly to subprocess.run():

python
result = subprocess.run(
    [
        "mcporter",
        "call",
        "exa.web_search_exa",
        f"query={query}",
        f"numResults={int(num_results)}",
    ],
    capture_output=True,
    text=True,
    check=True,
)

Additionally:

  • Validate that num_results is an integer within an expected range.
  • Avoid attempting to secure this implementation solely through manual shell escaping.
  • Handle subprocess.CalledProcessError and command timeouts explicitly.
  • Prefer the structured Python search API whenever available.
  • Add regression tests using queries containing apostrophes, semicolons, command substitutions, and newline characters to confirm they are treated only as data.

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:475
Finding

Unsafe Shell-Based JSON Piping Instruction

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, line 475
Vulnerability Type: Command injection through unsafe shell interpolation
Risk Level: High

Vulnerable Code:

bash
echo '{JSON data}' | python3 scripts/send_feishu_card.py {receive_id} {reply_to}

Technical Analysis

The Skill documentation directs the Agent to construct a shell pipeline by substituting generated JSON, receive_id, and reply_to values into a command template.

Search-derived recommendation data can contain apostrophes and other shell-significant characters. If generated JSON is placed directly inside the documented single-quoted echo argument, an apostrophe can terminate the quote and cause subsequent content to be interpreted as shell syntax. The unquoted recipient and reply identifiers introduce an additional injection surface if those values are not strictly validated.

This issue depends on the documented template being materialized and executed through a shell. The Python sender itself safely reads JSON from standard input; the vulnerability is in the shell-based invocation method prescribed by the Skill.

Attack Path

  1. An attacker supplies malicious place data, or malicious content enters the recommendation output through a searched source.
  2. The generated JSON retains shell-significant content, such as an apostrophe followed by shell operators.
  3. The Agent substitutes that JSON into the documented single-quoted echo command. Alternatively, a malicious recipient or reply identifier is substituted without quoting.
  4. The resulting command is executed by a shell.
  5. Attacker-controlled syntax escapes the intended argument and is interpreted as an additional shell command.
  6. The injected command executes with the privileges of the Agent process.

Impact Assessment

Exploitation can result in arbitrary local command execution under the Agent's operating-system account. This may expose files, API c ...[truncated 371 chars]

Remediation
View remediation

Remediation Suggestions

Do not interpolate JSON or identifiers into a shell command. Invoke the script using a structured process API and provide serialized JSON directly through standard input:

python
import json
import subprocess

subprocess.run(
    [
        "python3",
        "scripts/send_feishu_card.py",
        receive_id,
        reply_to,
    ],
    input=json.dumps(data),
    text=True,
    check=True,
)

When reply_to is optional, omit that argument rather than passing an empty shell value.

Additional hardening should include:

  • Validate receive_id against expected Feishu identifier formats, such as approved oc_ or ou_ prefixes and a conservative character set.
  • Validate reply_to against the expected Feishu message-ID format.
  • Keep recommendation JSON as structured data throughout the invocation process.
  • If a command-line example must be retained, use a securely created input file and pass only a safely quoted file path; do not embed generated JSON in shell source.
  • Add tests containing apostrophes, newlines, command substitutions, and shell metacharacters in place names and recommendation text.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (23)

Tainted flow: 'APP_ID' from os.environ.get (line 12, credential/environment) → requests.post (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/feishu_card.py (reported line 21)May include surrounding context.

python
print("❌ 未配置飞书应用信息,请设置环境变量 FEISHU_APP_ID 和 FEISHU_APP_SECRET", file=sys.stderr)
        return None
    
    r = requests.post(
        "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal",
        json={"app_id": APP_ID, "app_secret": APP_SECRET}
    )

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · README.md (reported line 54)May include surrounding context.

�� Dashboard**

  • 登录后进入 Dashboard
  • 或点击右上角头像 → Dashboard
  1. 获取 API Key

    • 左侧菜单找到 "API Keys"
    • 点击 "Create new API Key"
    • 输入名称(如 local-guide)
    • 点击 Create 并复制生成的 Key
  2. 配置环境变量

    bash
    # Linux/Mac
    export EXA_API_KEY=your-api-key-here
    
    # 添加到 ~/.bashrc 永久保存
    echo 'export EXA_API_KEY=your-api-key-here' >> ~/.bashrc
    source ~/.bashrc
    
    # Windows PowerShell
    $env:EXA_API_KEY="your-api-key-here"
    

免费额度: EXA 每月提供 1000 次免费搜索请求

飞书卡片(可选)

如需飞书卡片输出功能:

bash
export FEISHU_APP_ID=your-feishu-app-id
export FEISHU_APP_SECRET=your-feishu-app-secret

🚀 使用示例

text
# 美食推荐
本地通 美食 南海桂城
本地通推荐 小吃 佛山市南海区桂城
本地通 糖水 广州天河

# 景点推荐
本地通 好玩 佛山南海
本地通推荐 景�

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

A recommendation skill should primarily gather and present results, but this one accepts command-line message targets and invokes a separate delivery script, making it capable of acting on external recipients rather than only returning results to the current user. That mismatch can facilitate unauthorized message delivery, cross-channel data leakage, or abuse of platform credentials.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

A recommendation skill should primarily gather and present results, but this one accepts command-line message targets and invokes a separate delivery script, making it capable of acting on external recipients rather than only returning results to the current user. That mismatch can facilitate unauthorized message delivery, cross-channel data leakage, or abuse of platform credentials.

Content

No source excerpt is available for this finding.

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · SKILL.md (reported line 47)May include surrounding context.

"API Keys" 2. 或直接访问:https://exa.ai/dashboard/api-keys 3. 点击 "Create new API Key" 按钮 4. 输入 Key 名称(如:local-guide) 5. 点击 "Create" 生成 Key 6. 复制生成的 API Key(格式类似:xxxxx-xxxxx-xxxxx-xxxxx)

步骤 4:配置环境变量

bash
# Linux / Mac
export EXA_API_KEY=你复制的API_Key

# 添加到配置文件永久保存
echo 'export EXA_API_KEY=你复制的API_Key' >> ~/.bashrc
source ~/.bashrc

# Windows PowerShell
$env:EXA_API_KEY="你复制的API_Key"

# Windows CMD
set EXA_API_KEY=你复制的API_Key

免费额度说明:

  • EXA 提供免费试用额度
  • 每月有 1000 次免费搜索请求
  • 超出后需付费订阅

验证配置:

bash
# 检查环境变量是否设置成功
echo $EXA_API_KEY

# 测试 EXA 搜索
python3 scripts/search_module.py

触发词

  • 本地通推荐 [类型] [地名]
  • 本地通 [类型] [地名]
  • [地名] 本地通 [类型]

支持的类型:

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

This fallback implementation grants shell execution capability in a search skill, and the executed command directly embeds user-controlled search text. In the context of a local-recommendation skill, this extra capability is unnecessary and materially increases the blast radius from simple search input to arbitrary command execution.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

This is a concrete tool-parameter abuse case: attacker-controlled input is forwarded into a shell command, allowing abuse of the subprocess tool beyond its intended purpose. Because the skill is expected to process arbitrary search terms from users, the danger is elevated: a normal search interface becomes a command execution primitive.

Content

Scanner excerpt · scripts/search_module.py (reported line 59)May include surrounding context.

python
# 兜底实现
    import subprocess
    cmd = f"mcporter call exa.web_search_exa query='{query}' numResults={num_results}"
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    return result.stdout

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · README.md (reported line 44)May include surrounding context.

md
3. **获取 API Key**
   - 左侧菜单找到 "API Keys"
   - 点击 "Create new API Key"
   - 输入名称(如 local-guide)
   - 点击 Create 并复制生成的 Key

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · README.md (reported line 44)May include surrounding context.

md
3. **获取 API Key**
   - 左侧菜单找到 "API Keys"
   - 点击 "Create new API Key"
   - 输入名称(如 local-guide)
   - 点击 Create 并复制生成的 Key

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill declares no explicit tool scope or permission boundary, yet its instructions clearly rely on environment variables, network access, and shell execution. That creates an over-privileged design where a caller or runtime may grant broader capabilities than users would reasonably expect from a recommendation skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The manifest description defines only Chinese trigger phrases such as “本地通推荐、本地人推荐、老字号” and does not indicate that other languages are supported. This is a natural-language policy concern because the skill appears to require a specific language for activation without user opt-in or an explicit locale limitation.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
81% confidence
Finding

This duplicated finding points to the same behavior: encouraging persistent storage of the EXA API key in environment startup files. While common, it still weakens secret hygiene because it normalizes durable plaintext credential storage without discussing safer alternatives.

Content

Scanner excerpt · SKILL.md (reported line 35)May include surrounding context.

md
1. 在 Dashboard 左侧菜单找到 **"API Keys"**
2. 或直接访问:https://exa.ai/dashboard/api-keys
3. 点击 **"Create new API Key"** 按钮
4. 输入 Key 名称(如:`local-guide`)
5. 点击 **"Create"** 生成 Key
6. 复制生成的 API Key(格式类似:`xxxxx-xxxxx-xxxxx-xxxxx`)

Session Persistence

Medium
Category
Rogue Agent
Confidence
81% confidence
Finding

This duplicated finding points to the same behavior: encouraging persistent storage of the EXA API key in environment startup files. While common, it still weakens secret hygiene because it normalizes durable plaintext credential storage without discussing safer alternatives.

Content

Scanner excerpt · SKILL.md (reported line 35)May include surrounding context.

md
1. 在 Dashboard 左侧菜单找到 **"API Keys"**
2. 或直接访问:https://exa.ai/dashboard/api-keys
3. 点击 **"Create new API Key"** 按钮
4. 输入 Key 名称(如:`local-guide`)
5. 点击 **"Create"** 生成 Key
6. 复制生成的 API Key(格式类似:`xxxxx-xxxxx-xxxxx-xxxxx`)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The implementation steps instruct the system to recognize only the Chinese pattern “本地通推荐 [类型] [地名]” and enforce consistent output everywhere, but they do not offer any language selection or explain a region-specific constraint. This effectively hard-codes a language requirement in the skill behavior.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill is described as a local recommendation assistant, but it contains a reusable Feishu messaging module that can send interactive messages to chats or users. This capability is unrelated to the stated purpose and creates an unnecessary outbound communication channel that could be repurposed for spam, covert notifications, or data exfiltration if other parts of the skill supply sensitive content.

Content

No source excerpt is available for this finding.

External Transmission

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

python
print("❌ 未配置飞书应用信息,请设置环境变量 FEISHU_APP_ID 和 FEISHU_APP_SECRET", file=sys.stderr)
        return None
    
    r = requests.post(
        "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal",
        json={"app_id": APP_ID, "app_secret": APP_SECRET}
    )

External Transmission

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

python
print("❌ 未配置飞书应用信息,请设置环境变量 FEISHU_APP_ID 和 FEISHU_APP_SECRET", file=sys.stderr)
        return None
    
    r = requests.post(
        "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal",
        json={"app_id": APP_ID, "app_secret": APP_SECRET}
    )

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

This function can send arbitrary interactive card content to Feishu recipients, creating a general outbound messaging primitive. In the context of a local recommendation skill, that extra capability is unnecessary and broadens abuse potential by enabling unauthorized notifications, phishing-style messages, or transmission of sensitive outputs to external chats if invoked by other components.

Content

Scanner excerpt · scripts/feishu_card.py (reported line 67)May include surrounding context.

python
url = f"https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type={receive_id_type}"
        body = {"receive_id": receive_id, "msg_type": "interactive", "content": json.dumps(card)}

    r = requests.post(url, headers=headers, json=body)
    result = r.json()
    
    if result.get("code") == 0:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The module description is written as a Chinese-localized skill with no indication that language is user-selectable or region-limited by design. Under the policy, forcing a specific language or locale without opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The query parameter is treated as trusted when constructing a shell command, with no escaping, validation, or disclosure to the user that their input may reach a system shell. An attacker can supply quote-breaking or shell metacharacter payloads to run unintended commands.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
99% confidence
Finding

The fallback path builds a shell command by interpolating the untrusted query string and executes it with shell=True. This creates a command injection path where crafted input can break out of the quoted argument and execute arbitrary shell commands on the host.

Content

Scanner excerpt · scripts/search_module.py (reported line 59)May include surrounding context.

python
# 兜底实现
    import subprocess
    cmd = f"mcporter call exa.web_search_exa query='{query}' numResults={num_results}"
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    return result.stdout

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The natural-language content of the skill is entirely Chinese, but the README does not state that the skill is intended only for Chinese-speaking users or offer any language choice. Under the policy, forcing a specific language without opt-in can be a language/locale policy issue.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

This markdown file includes setup steps for EXA and Feishu credentials, including commands that place secrets into environment variables and persist them in shell startup files. While the document explains how to configure the keys, it does not warn users to keep these values private, avoid committing them to source control, or handle them as sensitive credentials.

Content

No source excerpt is available for this finding.