T09 · Insecure Skill Coding Practices
- Location
query_db.py:13- Finding
Hardcoded MySQL Root Credentials Exposed in Source and Process Arguments
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is meant for database lookup, but it ships powerful hardcoded database access and unsafe command construction that could expose or alter internal data.
Install only in an environment where you control the datax host and the MySQL instance. Before use, rotate the exposed password, remove hardcoded credentials, replace root with a dedicated read-only account, enforce an allowlist for SELECT/SHOW/DESCRIBE-style operations, avoid embedding SQL in SSH shell strings, and require confirmation before sharing database results to Feishu.
query_db.py:13Hardcoded MySQL Root Credentials Exposed in Source and Process Arguments
query_db.py:13Database Queries Execute with Unnecessary Root Privileges
query_db.py:33Remote Shell Command Injection Through Unescaped Query Parameters
query_db.py:31SQL Injection and Failure to Enforce the Documented Read-Only Policy
The skill explicitly supports querying user-related data and later states results may be sent to Feishu, but it does not warn about privacy, data minimization, or outbound data transfer. This creates a real risk of exfiltrating sensitive personal or business data from an internal database into a chat system without informed user confirmation or policy checks.
The module is presented as a database query tool, but it can execute arbitrary SQL, including INSERT, UPDATE, DELETE, DROP, and administrative statements, against a production-like remote MySQL instance using root credentials. In this context, the mismatch is dangerous because callers may assume read-only behavior while the code permits destructive or privilege-altering operations.
The code hardcodes MySQL root credentials directly in source, exposing a highly privileged secret to anyone with file access and encouraging reuse of insecure defaults. In this context, compromise of the script or repository immediately grants broad database access and combines with arbitrary SQL execution to enable full data loss or theft.
The trigger phrases are broad and colloquial, making accidental invocation more likely in normal conversation. In this context, accidental activation can lead to unintended access to an internal development host and database, which is more sensitive than a harmless content-generation action.
The skill claims it is read-only and only executes SELECT statements, but the documented examples and workflow include non-SELECT operations such as SHOW and DESC. This mismatch is dangerous because agents or users may rely on the safety claim and permit broader SQL execution than intended, weakening guardrails around database access.
Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.
## 相关文件
- 技能位置:`~/.openclaw/workspace/skills/dev-machine-database/SKILL.md`
- 脚本位置:`~/.openclaw/workspace/skills/dev-machine-database/query_db.py`
- 配置位置:`~/.openclaw/workspace/TOOLS.md` (开发机配置)
The skill includes a generic SSH execution primitive, not just database access, which materially broadens the attack surface. Given that command strings are composed from variables and SQL text, any injection flaw or future feature expansion could turn this into arbitrary command execution on the remote development machine.
This code executes SSH commands and remotely runs docker exec/mysql against a development machine, which can access and expose database contents. Although the functions have internal docstrings, there is no user-facing warning, confirmation prompt, or disclosure that remote commands will be executed and database data retrieved.
The subprocess call itself is not shell=True, but it forwards a fully attacker-controllable remote command string to SSH, which is then interpreted by the remote shell. Because higher-level functions interpolate SQL, table names, and database names directly into that command, this creates a command-injection path on the remote host and extends the tool's power beyond simple database queries.
def ssh_command(cmd, timeout=30):
"""执行 SSH 命令"""
try:
result = subprocess.run(
["ssh", DEV_MACHINE, cmd],
capture_output=True,
text=True,
The module description and user-facing messages are presented exclusively in Chinese, which can amount to a language/locale policy issue when no user opt-in or alternative is offered. There is no indication that this skill is intentionally restricted to a Chinese-speaking or region-specific audience.