T03 · Remote Payload Retrieval and Execution
- Location
scripts/slow_query_analyzer.py:49- Finding
Runtime Execution of an Unpinned Remote Payload
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill has a legitimate ByteHouse slow-query purpose, but it runs unpinned remote code with all environment variables and saves potentially sensitive query-log data locally.
Review before installing. Use only in a restricted environment with read-only ByteHouse credentials, remove unrelated secrets from the environment, protect or delete generated output files, and prefer a pinned or preinstalled trusted MCP server instead of fetching from a mutable GitHub branch.
scripts/slow_query_analyzer.py:49Runtime Execution of an Unpinned Remote Payload
scripts/slow_query_analyzer.py:46Remote Child Process Inherits the Entire Parent Environment
The documented behavior does not match the observed capabilities: it omits local persistence of analysis outputs and overstates features like execution-plan viewing and historical trend analysis. This is dangerous because operators may approve or invoke the skill under false assumptions, while the undeclared output files can retain sensitive query text and metadata on disk.
Copying the entire process environment and passing it to a child process launched from a remote GitHub-sourced MCP server unnecessarily exposes all available secrets, not just ByteHouse credentials. This is especially risky here because the child executable is fetched from a remote repository at runtime, so any compromise or unexpected behavior in that dependency could harvest unrelated tokens, cloud credentials, or internal configuration from the environment.
print()
# 从环境变量获取配置
env = os.environ.copy()
# MCP Server参数
server_params = StdioServerParameters(
The natural-language instructions and descriptions in this file are entirely Chinese, which effectively forces a specific language for users. Under the stated policy, language restrictions should either provide user choice or be clearly justified as region-specific.
The skill uses environment variables, MCP access, and writes files, but it does not declare any tool scope or permissions boundaries. This weakens least-privilege controls and makes it harder for an agent runtime or reviewer to understand and constrain what the skill may access or modify.
The skill description and trigger conditions are broad enough that an agent may invoke it for loosely related requests. In this context, accidental invocation is risky because the skill connects to a database-backed MCP service and may process or export sensitive query information unnecessarily.
The keyword trigger list lacks constraints and negative examples, so generic phrases such as '查询优化' or '性能分析' may cause over-triggering. Because this skill can access database telemetry and write reports, ambiguous activation increases the chance of unnecessary sensitive-data handling.
The documentation states that analysis outputs are saved as JSON files but does not warn that these files may contain sensitive query text, identifiers, timing metadata, and potentially embedded secrets from SQL statements. In a database-analysis skill, that omission is particularly dangerous because query logs often expose business logic, schema details, and user data access patterns.
The manifest describes capabilities including '查看查询执行计划' and '分析查询历史趋势', which imply EXPLAIN-plan retrieval and trend analysis across time. In code, the script performs three fixed read-only queries over system.query_log limited to the last hour (L78-L173) and then emits hard-coded suggestions; it never invokes EXPLAIN or performs multi-period/history trend analysis.
The manifest says the tool is used for '查询性能优化建议', which suggests recommendations derived from observed slow-query characteristics. However, the code appends three predetermined suggestions without analyzing the returned query data, so the advertised optimization analysis is only superficially implemented.
The README explicitly states that analysis results are written to timestamped JSON files in an output directory, but it does not warn users that potentially sensitive query text, execution details, or metadata will persist on disk. In a database performance-analysis context, those artifacts can contain sensitive operational or data-access information and may be retained, copied, or exposed unintentionally.
This code file reads the full process environment via os.environ.copy(), which includes sensitive variables such as BYTEHOUSE_PASSWORD, and passes that environment to a spawned subprocess. While the script tells the user to set the variables, it does not explicitly disclose that credentials will be inherited by the MCP server process.
The script persists analysis results that include slow query log contents to a local JSON file, and query text can contain sensitive business logic, identifiers, literals, or even secrets embedded in SQL. In a database analysis skill, this context makes the issue more dangerous because operational query logs frequently contain confidential metadata and are written unredacted to disk.