T09 · Insecure Skill Coding Practices
- Location
scripts/mx_stock_simulator.py:50- Finding
Configurable API destination can expose the API key and account requests
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill fits a simulated stock-trading purpose, but it needs Review because it can submit or cancel simulated trades and send the API key to a configurable URL without enough safeguards.
Install only if you trust the 妙想 API key and environment configuration. Keep MX_API_URL set to the documented HTTPS service, use a limited or revocable API key if possible, and do not let the agent run buy, sell, or cancel requests unless you have clearly confirmed the exact action. Be aware that account and order responses are saved locally as raw JSON in the OpenClaw workspace.
scripts/mx_stock_simulator.py:50Configurable API destination can expose the API key and account requests
scripts/mx_stock_simulator.py:30Sensitive account and transaction responses are stored without explicit access restrictions
scripts/requirements.txt:1Third-party dependency is installed without a version or integrity constraint
The request destination is built from the MX_API_URL environment variable and used directly in requests.post while sending the apikey header and trading/account payloads. If an attacker can influence the runtime environment, they can redirect sensitive requests to an attacker-controlled host, exfiltrating credentials and financial data and potentially capturing trade instructions.
}
try:
response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
Buy, sell, and cancel operations are executed immediately from parsed natural-language input with no confirmation step, dry-run preview, or secondary approval. In an agent setting, ambiguous phrasing, prompt injection, or accidental invocation can therefore trigger destructive financial actions and mass cancellation of orders.
The skill declares capabilities that involve environment access, outbound network requests, and file output, but it does not constrain them with explicit tool scope such as permissions or allowed-tools. In a trading-oriented skill, that omission is dangerous because an agent could access secrets, transmit them to a remote endpoint, and write sensitive account data to disk without clear sandbox limits or user-visible restrictions.
The skill enables buy, sell, and especially one-click cancel operations, but it does not present an explicit warning or confirmation requirement for destructive account actions. In a financial-trading context, even a simulator can cause account state changes, strategy disruption, or unintended mass cancellation if an agent misinterprets a user request.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
{ }curl -X POST "${MX_API_URL}/api/claw/mockTrading/positions" \
-H "apikey: ${MX_APIKEY}" \
-H "Content-Type: application/json" \
-d '{}'
This request sends trade instructions to an external API and can cause state-changing buy or sell operations. In the absence of stronger guardrails like confirmation, domain allowlisting, and action scoping, an agent could execute unauthorized or mistaken trades using the user's API key.
useMarketPrice=false 时,price参数必填,且需符合市场规则:沪市价格小数位不超过2位,深市价格小数位不超过3位;当 useMarketPrice=true 时,price参数会被忽略,系统会自动以行情最新价进行买入。curl -X POST "${MX_API_URL}/api/claw/mockTrading/trade" \
-H "apikey: ${MX_APIKEY}" \
-H "Content-Type: application/json" \
-d '{
This request can cancel one order or all pending orders through an external API, making it a destructive state-changing action. In a trading workflow, mass cancellation without strong confirmation and scoping is risky because a prompt misunderstanding could disrupt the user's active strategy or erase pending execution opportunities.
600519、000001,系统会自动识别并补全市场号;另外股票代码在type为order时必传。curl -X POST "${MX_API_URL}/api/claw/mockTrading/cancel" \
-H "apikey: ${MX_APIKEY}" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
| fltOrderStatus | 否 | 0=全部(默认),2=已报,4=已成 等 |
curl -X POST "${MX_API_URL}/api/claw/mockTrading/orders" \
-H "apikey: ${MX_APIKEY}" \
-H "Content-Type: application/json" \
-d '{
User-facing docstrings, prompts, and output messages are entirely in Chinese, and the skill does not indicate that Chinese is optional or required for a region-specific reason. Under the policy, forcing a specific language without user opt-in is a natural-language policy concern.
The script persistently writes account balances, holdings, orders, and trade results to /root/.openclaw/workspace/mx_data/output without user notice or consent. These files may contain sensitive financial data and, in shared or multi-tenant environments, could be exposed to other processes, backups, or later compromise.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
}
try:
response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
The manifest and module docstring state that the skill supports 历史成交查询, which implies querying completed trade history. However, the intent parser maps phrases like '成交记录' and '历史成交' to the 'orders' intent, and the main handler only calls /api/claw/mockTrading/orders, which is presented as 委托查询 rather than a historical fills endpoint. This is a semantic mismatch between the advertised capability and implemented behavior.
The dependency file specifies requests without a version constraint, which makes builds non-reproducible and can cause deployment of unexpectedly vulnerable or breaking releases. In a stock trading simulator that performs authenticated API operations, dependency drift in a core HTTP client increases the chance of exposure to known or future transport, redirect, credential-handling, or verification issues.
requests
Because requests is unpinned, it is impossible to verify whether the installed version includes fixes for its many published security advisories. This is especially concerning in a skill that interacts with trading APIs and may handle credentials, account data, and transaction requests, where a vulnerable HTTP library could contribute to credential leakage, TLS/verification issues, or unsafe request handling.
No suspicious patterns detected.