Back to skill

Security audit

EMR Analyzer

Security checks for vulnerabilities and agentic risk

Overview

This skill is a plausible big-data diagnostics helper, but it runs host-level shell commands over sensitive logs and configs and contains a real command-injection risk if invoked on attacker-controlled log filenames.

Install only if you trust the target hosts and can run it with least-privilege read-only access. Avoid sudo unless absolutely necessary, do not run it in log directories writable by untrusted users or services, and redact sensitive logs/configs before analysis where possible. The package should be fixed to remove shell=True, safely handle filenames, document sensitive-data handling, and correct the broken CONFIG_PATHS reference before production use.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/analyze_logs.py:150
Finding

Arbitrary Command Execution Through Malicious Log Filenames

Content
View full analysis
/dev/null") return stdout, stderr if code != 0 else "" else: # 目录,找最新的日志文件 stdout, stderr, code = run_cmd(f"ls -t {log_path}*.log 2>/dev/null | head -3") if not stdout: # 尝试 .out 文件 stdout, stderr, code = run_cmd(f"ls -t {log_path}*.out 2>/dev/null | head -3") if stdout: files = stdout.split('\n')[:3] all_logs = [] for f in files: content, _, _ = run_cmd(f"tail -{lines//3} '{f}' 2>/dev/null") all_logs.append(content) return '\n'.join(all_logs), "" return "", f"No log files found in {log_path}" ``` ### Technical Analysis The `run_cmd` function executes command strings with `shell=True`. In `get_log_files`, filenames returned by `ls` are treated as trusted data and inserted directly into another shell command: ```python run_cmd(f"tail -{lines//3} '{f}' 2>/dev/null") ``` Single quotes around `f` do not provide adequate protection. A filename containing a single quote can terminate the quoted filename and introduce shell metacharacters and additional commands. Becau ...[truncated 2293 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (23)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description presents a broader diagnostic tool with capabilities including service status inspection, configuration/parameter retrieval, and tuning, in addition to error analysis and optimization suggestions. The supplied code only implements log reading from fixed filesystem paths, regex-based error detection, error summarization, and static fix suggestions. It supports several listed services and does provide task/log error analysis with recommendations, but it does not check whether services are running, inspect or retrieve service configuration parameters, or perform tuning beyond generic advice. Therefore the description overstates this code chunk’s implemented capabilities, creating a material description-to-behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description presents a broad big-data diagnostic tool covering status checks, parameter retrieval/tuning, and task error analysis for many services. This code chunk only reads local configuration files for a subset of services (yarn, hdfs, hive, spark, impala, hbase, kafka, zookeeper, flink, starrocks), extracts a small number of hardcoded parameters, and returns simple heuristic tuning suggestions for some services. It does not inspect runtime service state, parse logs, analyze task failures, or support several declared platforms such as Trino, Tez, Ranger, OpenLDAP, and Hue. Additionally, the script's main() references CONFIG_PATHS, which is not defined, suggesting the advertised 'all services' behavior would fail. Therefore the actual behavior is materially narrower than the declared purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The code does match one part of the description: service status checking for a set of big data services on Linux. However, the declared purpose describes a broader diagnostic tool that also supports parameter configuration retrieval and tuning, task error analysis, and optimization recommendations. None of those capabilities appear in this code chunk. The actual code only runs shell commands to inspect processes, ports, systemd status, and versions, and returns status JSON. Because the declared description materially overstates the implemented functionality in this supplied code chunk, this is a description/behavior mismatch.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
98% confidence
Finding

This is a true tool-parameter abuse issue because shell execution is combined with untrusted or weakly validated parameters. In particular, lines comes from sys.argv and is interpolated into shell commands like tail -{lines}, so an attacker could supply shell syntax instead of a number and execute arbitrary commands under the script's privileges.

Content

Scanner excerpt · scripts/analyze_logs.py (reported line 158)May include surrounding context.

python
def run_cmd(cmd):
    """执行命令"""
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=60)
        return result.stdout.strip(), result.stderr.strip(), result.returncode
    except Exception as e:
        return "", str(e), 1

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
97% confidence
Finding

This is a true tool-parameter abuse issue because the skill accepts a user-provided service name, derives command execution paths from it, and performs multiple shell-based operations through a generic helper using shell=True. In an agent/tooling environment, even a seemingly limited diagnostic script becomes risky because shell execution against local system resources can be repurposed or extended into arbitrary command execution if input handling, path trust, or future code changes weaken assumptions.

Content

Scanner excerpt · scripts/check_config.py (reported line 115)May include surrounding context.

python
def run_cmd(cmd):
    """执行命令"""
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
        return result.stdout.strip(), result.stderr.strip(), result.returncode
    except Exception as e:
        return "", str(e), 1

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
96% confidence
Finding

This is a classic tool-parameter abuse pattern: a diagnostic tool executes shell commands on the underlying host, and command strings are assembled dynamically. In the context of an agent skill for infrastructure analysis, this is more dangerous because the tool is specifically designed to inspect privileged system state and may run with broad access on production nodes.

Content

Scanner excerpt · scripts/check_service_status.py (reported line 33)May include surrounding context.

python
def run_cmd(cmd):
    """执行命令并返回输出"""
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
        return result.stdout.strip(), result.stderr.strip(), result.returncode
    except Exception as e:
        return "", str(e), 1

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill clearly instructs execution of shell commands and Python scripts on target Linux hosts, but it does not declare any tool scope or allowed-tools boundary. That creates an authorization and containment gap: an agent could invoke shell access more broadly than users or the platform expect, especially when handling sensitive logs, configs, or privileged environments.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill is explicitly designed to inspect logs and configuration files, both of which often contain secrets, tokens, connection strings, usernames, internal IPs, and topology details. Failing to warn about this sensitivity makes inadvertent exposure more likely and is more dangerous here because the skill targets production big-data infrastructure and encourages broad diagnostics.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Broad activation phrases like general requests to 'analyze cluster service status' can cause accidental invocation in normal conversation, especially in multi-skill environments. Because this skill can drive shell-based diagnostics on production systems, ambiguous triggering raises the risk of unintended command execution and unnecessary exposure of operational data.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The error-analysis examples are extremely broad and encourage processing arbitrary pasted log text without clear limits, which may include credentials, tokens, hostnames, or internal architecture details. In a shell-capable diagnostic skill, ambiguous triggers plus sensitive log handling increase the chance of over-collection and disclosure of operational secrets.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
86% confidence
Finding

The skill states that SSH access is needed and recommends sudo privileges, which materially increases the blast radius of any misuse, prompt confusion, or downstream script weakness. In the context of production diagnostics across many services, elevated privileges can expose sensitive configs and logs, allow service disruption, and amplify any accidental or malicious command execution.

Content

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

md
## 注意事项

1. **权限要求**: 需要 SSH 访问目标服务器,建议有 sudo 权限
2. **日志轮转**: 旧日志可能被压缩,需要 zcat/gunzip 查看
3. **配置变更**: 修改配置后需要重启服务才能生效
4. **生产环境**: 调优前建议在测试环境验证

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language description and all user-facing messages/comments are in Chinese, indicating a fixed language choice without any opt-in or alternative locale support. Under the language/locale policy, forcing a specific language without user choice is a policy concern unless explicitly documented as region-specific.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script's diagnostic purpose is log inspection, but it implements broad shell command execution to perform that task. Because those command strings incorporate variable content and are executed through the shell, the skill has an unnecessarily powerful execution surface that can be abused for arbitrary command execution if inputs or paths are manipulated.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script executes shell commands via subprocess.run(..., shell=True) to list and tail service logs, which is a safety-relevant operation because it invokes the shell and reads potentially sensitive system log data. While there is an internal docstring saying 'execute command', there is no user-facing warning, confirmation, or disclosure that the tool will run shell commands against local log paths.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
97% confidence
Finding

The script invokes subprocess.run with shell=True on command strings, which is dangerous because shell metacharacters in any interpolated value can alter command execution. In this file, later callers build shell commands from variables such as service-derived paths and the user-supplied lines argument, so the shell usage creates a real command-injection risk rather than a purely stylistic concern.

Content

Scanner excerpt · scripts/analyze_logs.py (reported line 158)May include surrounding context.

python
def run_cmd(cmd):
    """执行命令"""
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=60)
        return result.stdout.strip(), result.stderr.strip(), result.returncode
    except Exception as e:
        return "", str(e), 1

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
95% confidence
Finding

The script centralizes shell execution in run_cmd() using subprocess.run(..., shell=True), and later builds command strings with interpolated values such as config file paths and service-derived selections. Using a shell for routine file checks and grep pipelines creates command-injection risk if any interpolated value becomes attacker-controlled or if configuration/path assumptions are violated; in an agent skill context this is more dangerous because the tool may run with elevated local access against sensitive system files.

Content

Scanner excerpt · scripts/check_config.py (reported line 115)May include surrounding context.

python
def run_cmd(cmd):
    """执行命令"""
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
        return result.stdout.strip(), result.stderr.strip(), result.returncode
    except Exception as e:
        return "", str(e), 1

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script accepts a service name from argv and then uses shell-based command execution throughout the config-check flow via subprocess.run(..., shell=True). Although this is part of the script's implementation, there is no user-facing disclosure, prompt, or warning that the tool will execute shell commands on the host system while processing the request.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
95% confidence
Finding

The helper executes arbitrary shell strings with shell=True, which is dangerous because several callers build commands via string interpolation rather than passing argument lists. In this script, service names can influence version commands and any future expansion of SERVICES or external input paths would make command injection straightforward, especially since the tool is intended to run host-level diagnostic commands on Linux systems.

Content

Scanner excerpt · scripts/check_service_status.py (reported line 33)May include surrounding context.

python
def run_cmd(cmd):
    """执行命令并返回输出"""
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
        return result.stdout.strip(), result.stderr.strip(), result.returncode
    except Exception as e:
        return "", str(e), 1

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

This code builds and runs a shell command derived from service_name, which ultimately comes from sys.argv[1]. Although the script's purpose is service checking, there is no user-facing disclosure that it will invoke shell commands on the host, and this operation is only described generically in internal docstrings/comments.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The entire skill description and user interaction examples are presented only in Chinese, with no indication that the skill supports other languages or that Chinese is a required locale. Under the policy, forcing a specific language without user opt-in can be a natural-language policy violation unless the locale restriction is explicit and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The top-level docstring is written only in Chinese, and the inline instructional text/comments are likewise Chinese-only. This imposes a language choice without any opt-in or documented justification for a locale-specific audience, which can violate language/locale policy expectations.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
99% confidence
Finding

The script's command-line help and iteration logic imply it can enumerate supported services from a CONFIG_PATHS mapping, but no such variable exists in the file. This is an active code/documentation contradiction because the presented usage behavior cannot occur as written and will fail at runtime.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The top-level natural-language description and comments force a specific language context for users and maintainers. Under the policy, language-specific instructions should offer user choice or clearly justify the locale constraint.

Content

No source excerpt is available for this finding.