Back to skill

Security audit

Tianji Data

Security checks for vulnerabilities and agentic risk

Overview

This skill mostly collects Chinese market data, but it also contains under-disclosed alerting code that can send messages to a fixed Feishu user and uses an unsafe subprocess pattern.

Install only after reviewing or removing market_watcher.py notification behavior. At minimum, remove the hard-coded Feishu recipient, replace python3 -c interpolation with a direct safe API call, require explicit opt-in for outbound alerts, narrow the trigger terms, document the exact network endpoints and write paths, and store state in a private application directory with cleanup rules.

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

T09 · Insecure Skill Coding Practices

Error
Location
market_watcher.py:133
Finding

Arbitrary Python Code Execution Through Alert Message Interpolation

Content
View full analysis
bool: """Push an alert to Feishu through the message tool.""" try: from message_tool import message # Dynamic import to avoid circular dependencies import subprocess result = subprocess.run( ['python3', '-c', f'from tools import message; message(action="send", channel="feishu", target="user:ou_fd61d5ebc9af22913aa4c21c8e3cac14", message="{alert_msg}")'], capture_output=True, text=True, timeout=15, cwd='/workspace' ) return result.returncode == 0 except Exception: return False ``` ### Technical Analysis The function embeds `alert_msg` directly into Python source code and executes the resulting source using `python3 -c`. Although `subprocess.run` is invoked without `shell=True`, this does not prevent code injection because the Python interpreter itself processes the attacker-controlled string as executable source. An alert containing quotes, line breaks, backslashes, or Python syntax can terminate the intended string literal and append arbitrary statements. A representative payload shape is: ```python '"); __import__("os").system("ATTACKER_COMMAND"); #' ``` Once interpolated, the child interpreter executes the injected statement with the same operating-system identity, environment, filesystem access, and network permissions as the watcher process. ### Attack Path 1. An attacker gains control over, or influences, a value passed to `push_to_feishu(alert_msg)`. 2. The attacker supplies text that closes the `message` argument string and injects additional Python statements. 3. The function inserts that text into the source supplied to `python3 -c`. 4. The newly launched Pyth ...[truncated 1055 chars]
Remediation
View remediation
bool: try: from tools import message message( action="send", channel="feishu", target=target, message=alert_msg, ) return True except Exception: return False ``` If a separate process is operationally required: 1. Create a fixed child script containing no dynamically generated source. 2. Pass message content through standard input or a JSON data file. 3. Parse the input strictly as data in the child process. 4. Never interpolate data into `-c`, `eval`, `exec`, shell commands, or source templates. 5. Run the child with minimum filesystem and network privileges. 6. Add tests containing quotes, backslashes, newlines, semicolons, and code-like payloads to verify that all content remains inert data. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
market_watcher.py:165
Finding

Predictable Temporary State File Allows Symlink-Based File Overwrite

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
market_watcher.py:138
Finding

Hard-Coded Feishu Recipient Can Cause Unauthorized Message Disclosure

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (14)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill specifically references Tencent quote retrieval and other external finance sources, but the top-level manifest does not clearly declare this concrete network behavior. Hidden or under-disclosed external connectivity is risky in agent systems because it obscures what third parties receive requests and what kind of data processing the skill actually performs.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The skill specifically references Tencent quote retrieval and other external finance sources, but the top-level manifest does not clearly declare this concrete network behavior. Hidden or under-disclosed external connectivity is risky in agent systems because it obscures what third parties receive requests and what kind of data processing the skill actually performs.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

The skill specifically references Tencent quote retrieval and other external finance sources, but the top-level manifest does not clearly declare this concrete network behavior. Hidden or under-disclosed external connectivity is risky in agent systems because it obscures what third parties receive requests and what kind of data processing the skill actually performs.

Content

No source excerpt is available for this finding.

Vague Triggers

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The manifest uses very broad trigger words like 'search', 'skill', and 'data', which overlap with ordinary conversation and can cause accidental invocation. In the context of a skill that performs external data retrieval and local writes, overly broad activation language expands the attack surface by making unintended execution much more likely.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill can send Feishu messages to a hardcoded user target via an external subprocess, which is an outbound side effect not justified by the advertised generic data/search purpose. In context, this is more dangerous because it enables covert exfiltration, unsolicited notification, or unauthorized actions under the guise of a benign market-data skill.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
83% confidence
Finding

The skill documents outbound data collection, local file writes under /workspace/data/tianji-system/data/, and code imports referencing market-data modules, but it declares no explicit tool scope or permissions. In an agent environment, missing capability boundaries can let a seemingly simple data skill use network, filesystem, or shell access without clear operator consent, increasing the risk of unintended data access or misuse.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring and later user-facing strings are entirely in Chinese, indicating the skill is designed to communicate in a fixed language. The policy for this category requires flagging language/locale constraints when the skill does not provide a user choice or explicit opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code presents its purpose, usage, and runtime messages entirely in Chinese, and later prints/pushes Chinese-only alert text. That constitutes a language/locale constraint in natural language without offering the user any choice or documenting a justified region-specific requirement.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The implementation materially exceeds the declared data/search scope by performing active market surveillance, generating trading-oriented recommendations, and preparing outbound alerts. This capability mismatch is dangerous because users or host systems may grant the skill broader trust than intended, leading to unexpected actions and reduced scrutiny of sensitive behavior.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
81% confidence
Finding

The file creates a persistent alert queue directory and later stores prior market state and alert records locally despite the skill being described only as data/search. While persistence is often legitimate, undisclosed local storage increases privacy, integrity, and surprise-risk because data may accumulate without retention controls or user awareness.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The code path supports sending Feishu notifications without any explicit runtime confirmation, recipient review, or user-facing warning. In this skill context, silent outbound transmission is riskier because the manifest suggests passive data/search behavior, so operators may not expect externally visible actions or message delivery.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
96% confidence
Finding

The code builds a Python -c command by directly interpolating alert_msg into source text executed by a subprocess. If any part of alert_msg can contain quotes or crafted payloads derived from market data or caller input, this creates code-injection risk in the spawned interpreter, not just a harmless message send.

Content

Scanner excerpt · market_watcher.py (reported line 138)May include surrounding context.

python
from message_tool import message
        # 动态导入(避免循环依赖)
        import subprocess
        result = subprocess.run(
            ['python3', '-c',
             f'from tools import message; message(action="send", channel="feishu", target="user:ou_fd61d5ebc9af22913aa4c21c8e3cac14", message="{alert_msg}")'],
            capture_output=True, text=True, timeout=15,

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The file’s natural-language content, including the module header and function documentation, is entirely in Chinese. Under the policy, forcing a specific language without opt-in can be a locale/language policy violation when no alternative or justification is provided.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module and function documentation describe returned quote fields such as turnover-related values, but the actual parser returns 'turnover_yi' at L112 while the executable example at L142 accesses d['turnover']. This is an active contradiction between the example usage and the implemented return structure, indicating the documented/intended interface does not match the real code.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.