Back to skill

Security audit

Java Performance Analyzer

Security checks for vulnerabilities and agentic risk

Overview

This skill is a real Java diagnostics tool, but it uses unsafe high-impact defaults for SSH credentials, remote installation, live JVM control, and an exposed management API.

Install only if you fully trust the publisher and target environment. Prefer SSH keys or a secret manager instead of passwords, do not store SSH passwords in agent memory, bind Arthas to localhost behind an SSH tunnel, remove or restrict arbitrary Arthas commands, verify downloaded binaries, and stop/clean up Arthas after each session.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/install-arthas.sh:25
Finding
Remote Shell Command Injection Through Unvalidated Installation Parameters<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install-arthas.sh`, lines 25-71 **Vulnerability Type**: Remote shell command injection **Risk Level**: High ### Vulnerable Code ```bash SSH_HOST="$1" SSH_USER="$2" SSH_PASS="$3" ARTHAS_DIR="$4" PROCESS_NAME="$5" # Check whether Arthas is installed CHECK_RESULT=$(sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "ls -la $ARTHAS_DIR/arthas-boot.jar 2>/dev/null || echo NOT_FOUND") if [[ "$CHECK_RESULT" != *"NOT_FOUND"* ]]; then echo "Arthas is installed: $ARTHAS_DIR/arthas-boot.jar" else sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "mkdir -p $ARTHAS_DIR && cd $ARTHAS_DIR && curl -O https://arthas.aliyun.com/arthas-boot.jar" fi JAVA_PID=$(sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "ps -ef | grep java | grep $PROCESS_NAME | grep -v grep | awk '{print \$2}' | head -1") ATTACHED=$(sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "ps -ef | grep arthas | grep $JAVA_PID | grep -v grep || echo NOT_ATTACHED") sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "cd $ARTHAS_DIR && nohup java -jar arthas-boot.jar $JAVA_PID --target-ip 0.0.0.0 --http-port 8563 > arthas.log 2>&1 &" ``` ### Technical Analysis The script places `ARTHAS_DIR` and `PROCESS_NAME`, which are supplied as positional command-line arguments, directly inside double-quoted command strings sent to a remote shell over SSH. Local assignment quoting does not make these values safe after interpolation into the remote command. Shell metacharacters such as semicolons, command substitutions, pipes, redirections, and logical operators can alter the command interpreted by the remote shell. The vulnerable variables are used in several command contexts: - `ARTHAS_DIR` is inserted into `ls`, `mkdir`, `cd`, `java`, and log-file paths. - `PROCESS_NAME` is inserted into a shell pipeline containing `grep`. - Values derived through these commands are later reused in additional remote commands. No allowlist validation or shell-safe remote ...[truncated 1088 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate all externally supplied parameters against strict allowlists: - Restrict process names to expected alphanumeric characters, periods, underscores, and hyphens. - Require the installation directory to be an absolute path and reject shell metacharacters. 2. Do not build remote shell commands through direct interpolation. 3. Pass values as positional parameters to a fixed remote script, for example by invoking `sh -s --` and reading arguments as `$1`, `$2`, and so on. 4. If shell command construction cannot be avoided, apply a well-tested shell-escaping routine to every interpolated value. 5. Replace `ps | grep` process matching with a safer mechanism such as `pgrep` and pass the pattern as a separately quoted argument. 6. Reject empty values, control characters, newline characters, command substitutions, redirections, and shell operators. 7. Avoid using a privileged SSH account. Run the installer under a dedicated account with only the permissions required to attach to the intended JVM. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/install-arthas.sh:35
Finding
SSH Password Exposure Through Process Arguments and Persistent Memory Guidance<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install-arthas.sh`, lines 35-85; `SKILL.md`, lines 44-47 and 60-70 **Vulnerability Type**: Insecure credential handling and plaintext secret retention **Risk Level**: High ### Vulnerable Code From `scripts/install-arthas.sh`: ```bash CHECK_RESULT=$(sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "ls -la $ARTHAS_DIR/arthas-boot.jar 2>/dev/null || echo NOT_FOUND") sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "mkdir -p $ARTHAS_DIR && cd $ARTHAS_DIR && curl -O https://arthas.aliyun.com/arthas-boot.jar" JAVA_PID=$(sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "ps -ef | grep java | grep $PROCESS_NAME | grep -v grep | awk '{print \$2}' | head -1") ATTACHED=$(sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "ps -ef | grep arthas | grep $JAVA_PID | grep -v grep || echo NOT_ATTACHED") HTTP_CHECK=$(sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "curl -s -o /dev/null -w '%{http_code}' http://localhost:8563/api || echo FAILED") sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "tail -20 $ARTHAS_DIR/arthas.log" ``` The skill instructions also direct the agent to inspect persistent memory for credentials: ```markdown Before analysis, check whether `MEMORY.md` already contains: - SSH address, username, password - Java process name - Arthas/MCP configuration status ``` The documented installation interface requires the password as a positional argument: ```bash scripts/install-arthas.sh <ssh-host> <ssh-user> <ssh-password> <arthas-dir> <process-name> ``` ### Technical Analysis The installer receives the SSH password as a command-line argument and repeatedly supplies it to `sshpass` through the `-p` option. Command-line secrets can become visible through process inspection, debugging output, command histories, audit systems, monitoring agents, CI logs, or wrapper-process telemetry. The skill documentation additionally treats the SSH password as information that may be retained in `MEMORY.md`. N ...[truncated 1468 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace password authentication with SSH public-key authentication. 2. Use `ssh-agent` or an equivalent secret broker so private credentials are not placed in process arguments. 3. Do not accept the SSH password as a positional script argument. 4. If password authentication is unavoidable: - Prompt through a protected terminal. - Use an appropriately protected file descriptor or secret-manager integration. - Clear temporary variables immediately after use. 5. Explicitly prohibit storing SSH passwords in `MEMORY.md` or any other persistent agent memory. 6. Store only non-secret connection metadata, such as host aliases, ports, and process names. 7. Redact credentials from shell history, process telemetry, debug logs, CI output, and audit traces. 8. Use a dedicated, minimally privileged SSH account rather than `root`. 9. Rotate any password previously passed through this interface or retained in workspace memory. ]]>

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/install-arthas.sh:69
Finding
Unauthenticated Arthas Management API Exposed on All Network Interfaces<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install-arthas.sh`, lines 69-71; `scripts/arthas-mcp-stdio.js`, lines 161-168 and 217-218 **Vulnerability Type**: Unauthenticated privileged management interface exposure **Risk Level**: Critical ### Vulnerable Code The installer binds Arthas to all network interfaces: ```bash # Start Arthas, attach it to the JVM, and enable the HTTP API sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "cd $ARTHAS_DIR && nohup java -jar arthas-boot.jar $JAVA_PID --target-ip 0.0.0.0 --http-port 8563 > arthas.log 2>&1 &" ``` The MCP wrapper exposes a tool for arbitrary Arthas commands: ```javascript { name: 'arthas_command', description: 'Execute any Arthas command', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Complete Arthas command' } }, required: ['command'] } } ``` ```javascript case 'arthas_command': command = args.command; break; ``` The command is sent over plaintext HTTP without authentication: ```javascript const options = { hostname: ARTHAS_HOST, port: ARTHAS_PORT, path: '/api', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, timeout: 30000 }; ``` ### Technical Analysis Binding Arthas with `--target-ip 0.0.0.0` makes its HTTP management endpoint listen on every available interface rather than only the loopback interface. This conflicts with the documented design in which the service should be reached through an SSH tunnel. No API authentication, authorization token, TLS configuration, or source-address restriction is configured by the project. The MCP wrapper also includes an unrestricted `arthas_command` capability instead of limiting operations to a narrow diagnostic allowlist. Arthas is attached directly to a live JVM and supports highly privileged diagnostic and state-changing operations. The project reference lists commands such as: ...[truncated 1999 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Bind Arthas only to the loopback interface: ```bash --target-ip 127.0.0.1 ``` 2. Block port 8563 at the host firewall, cloud security group, container configuration, and network perimeter. 3. Require access through an authenticated SSH tunnel. 4. Verify after startup that the listening socket is restricted to `127.0.0.1`. 5. Enable Arthas authentication where supported and use strong, independently managed credentials. 6. Do not expose the management endpoint through public ingress, reverse proxies, or unrestricted internal networks. 7. Remove `arthas_command` from the default MCP tool set. 8. Replace arbitrary command execution with a narrow allowlist of read-only diagnostic operations. 9. Add per-command authorization and explicitly deny powerful commands such as `ognl`, `retransform`, state-changing `vmoption` operations, and unrestricted file-output commands. 10. Apply execution limits, output-size limits, concurrency limits, and audit logging to permitted diagnostic calls. 11. Use a dedicated application account with minimal filesystem and network permissions. ]]>

T03 · Remote Payload Retrieval and Execution

Warning
Location
scripts/install-arthas.sh:39
Finding
Unpinned and Unverified Remote JAR Download Is Executed on the Target Server<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install-arthas.sh`, lines 39-42 and 69-71 **Vulnerability Type**: Mutable remote payload retrieval and missing integrity verification **Risk Level**: Medium ### Vulnerable Code ```bash if [[ "$CHECK_RESULT" != *"NOT_FOUND"* ]]; then echo "Arthas is installed: $ARTHAS_DIR/arthas-boot.jar" else echo "Downloading Arthas..." sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "mkdir -p $ARTHAS_DIR && cd $ARTHAS_DIR && curl -O https://arthas.aliyun.com/arthas-boot.jar" echo "Arthas download completed" fi ``` The downloaded file is subsequently executed: ```bash sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "cd $ARTHAS_DIR && nohup java -jar arthas-boot.jar $JAVA_PID --target-ip 0.0.0.0 --http-port 8563 > arthas.log 2>&1 &" ``` ### Technical Analysis The installer downloads an executable JAR from an unversioned URL and executes it without checking a cryptographic digest or trusted signature. The URL can return different content at different times, meaning the effective code executed by the skill can change after the skill itself has been reviewed. HTTPS protects transport under normal conditions but does not provide artifact immutability. It does not mitigate every relevant threat, including: - Compromise of the download server or release infrastructure - Unauthorized upstream artifact replacement - DNS or certificate-authority compromise - Misconfiguration of an intermediary - A mutable URL being updated to a different release - A corrupted or incomplete response being retained The `curl` invocation also omits explicit failure handling such as `--fail`, and the script does not pin an expected release version. ### Attack Path 1. An attacker compromises or influences the server, DNS resolution, TLS trust path, or release process associated with the download URL. 2. The unversioned URL returns a modified `arthas-boot.jar`. 3. The installer saves the file without verifying its expec ...[truncated 755 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin a specific, reviewed Arthas release rather than using an unversioned mutable URL. 2. Download the artifact from the canonical release repository. 3. Store the expected SHA-256 digest in the installer and verify it before execution: ```bash printf '%s %s\n' "$EXPECTED_SHA256" arthas-boot.jar | sha256sum --check - ``` 4. Prefer signature verification with a pinned and independently trusted release-signing key. 5. Use strict download options such as: ```bash curl --fail --show-error --silent --location --proto '=https' --tlsv1.2 ``` 6. Download to a newly created, access-restricted temporary file and move it into place only after successful verification. 7. Abort immediately if the download, checksum, signature, ownership, or permission checks fail. 8. Set restrictive ownership and file permissions before execution. 9. Record the installed version and verified digest for auditability. 10. Run the downloaded component under a minimally privileged account rather than `root`. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (18)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The declared purpose suggests a performance-analysis assistant, but the actual behavior includes remote host login, password-based automated authentication, downloading software onto the target, attaching to a live JVM, and exposing a service port. That mismatch is dangerous because users may consent to diagnostics without understanding that the skill performs privileged remote actions that can alter production systems and expand attack surface.

Missing User Warnings

High
Confidence
97% confidence
Finding
The skill explicitly requests SSH host, username, password, and process details, then uses those secrets for automated remote access, but it provides no credential-safety guidance, minimization policy, masking, storage limits, or warning about production sensitivity. This is dangerous because it normalizes plaintext secret collection and increases the risk of credential leakage, misuse, replay, or accidental retention in logs or memory.

Context-Inappropriate Capability

High
Confidence
98% confidence
Finding
The skill exposes a generic `arthas_command` tool that forwards arbitrary user-supplied Arthas commands directly to the remote Arthas API with no allowlist, validation, or safety gating. In the context of a remote JVM diagnostics wrapper, this breaks the intended narrow diagnostic scope and enables potentially destructive, privacy-invasive, or destabilizing operations beyond the predefined performance-analysis tools.

Missing User Warnings

High
Confidence
98% confidence
Finding
Arbitrary Arthas command execution is accepted from input and sent verbatim to the remote API without any user-facing warning or safety review. Since Arthas supports commands that can inspect sensitive runtime state, decompile code, dump data, or alter JVM behavior, this creates a powerful unsafeguarded remote diagnostic channel whose danger is amplified by the skill's remote-analysis purpose.

Missing User Warnings

High
Confidence
96% confidence
Finding
The script starts a persistent remote Java background process with `nohup` and enables an HTTP management interface, but gives no explicit warning that it is opening a long-lived administrative surface on the target host. In the context of a JVM diagnostic tool, this increases the chance an operator unintentionally leaves a sensitive management endpoint running and reachable.

Lp3

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding
The skill instructs the agent to use shell/environment capabilities for SSH, process inspection, SCP, and remote diagnostics, but it does not declare any explicit tool scope or allowed-tools boundary. This increases the risk of overbroad execution and makes it harder to constrain what commands the agent may run when handling sensitive production systems and credentials.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger conditions include broad phrases like '帮我排查 xxx 问题' and '分析下 xxx 性能', which can match ordinary troubleshooting requests and invoke a skill capable of remote shell access and production JVM manipulation. Because this skill can handle credentials and perform invasive diagnostics, accidental activation materially raises the chance of unauthorized or surprising actions.

Natural-Language Policy Violations

Medium
Confidence
88% confidence
Finding
文件整体说明、触发短语和交互模板均固定为中文,没有说明可根据用户语言偏好切换。这会造成语言/locale 策略风险,特别是在多语言环境下,技能表现为默认强制中文而非用户选择。

Missing User Warnings

Medium
Confidence
88% confidence
Finding
The reference advertises sensitive-inspection features such as `sysenv`, decompilation (`jad` elsewhere in the document), and an unrestricted `arthas_command` passthrough without clear warnings or guardrails. In a remote troubleshooting skill, this increases the chance of exposing secrets, proprietary code, credentials, or other sensitive runtime data during routine analysis.

Context-Inappropriate Capability

Medium
Confidence
93% confidence
Finding
The cheat sheet includes `mc` and `retransform`, which enable compiling and hot-swapping code in a live JVM. In a skill framed as performance diagnosis, exposing mutation capabilities materially expands the agent from observation into runtime modification, creating risk of unauthorized code changes, persistence, service instability, or abuse if the agent can invoke these commands remotely.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
`vmoption --set` and `logger --level` allow live JVM/runtime mutation rather than passive inspection. In the context of a remote analysis skill, these commands can alter application behavior, weaken operational safeguards, increase log exposure, or destabilize production systems without being necessary for routine diagnostics.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The `heapdump` tool writes a heap dump to an arbitrary path supplied by the caller, and heap dumps can contain credentials, tokens, PII, and application secrets resident in memory. Because the tool provides no warning, confirmation, path restriction, or retention controls, it can create sensitive forensic artifacts on disk that increase exposure risk and may consume significant storage on production systems.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The script takes the SSH password as a positional argument and passes it to `sshpass`, which commonly exposes credentials through shell history, process listings, audit logs, and CI/job telemetry. This creates a significant risk of credential disclosure even if the remote connection itself succeeds securely.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
The script downloads a JAR from the network onto a remote host and executes multiple remote shell commands over SSH. While some progress output is printed, there is no explicit warning that the script will modify the remote system by creating directories and fetching software, which is a safety-relevant operation affecting system integrity.

Session Persistence

Medium
Category
Rogue Agent
Content
echo ""
    echo "=== 启动 Arthas ==="
    # 启动 Arthas 并附着,启用 HTTP API
    sshpass -p "$SSH_PASS" ssh "$SSH_USER@$SSH_HOST" "cd $ARTHAS_DIR && nohup java -jar arthas-boot.jar $JAVA_PID --target-ip 0.0.0.0 --http-port 8563 > arthas.log 2>&1 &"
    
    # 等待启动
    echo "等待 Arthas 启动..."
Confidence
93% confidence
Finding
Using `nohup` starts Arthas as a detached, persistent process on the remote host, allowing the management service to outlive the initiating session. In combination with the exposed HTTP API, this creates a lasting administrative foothold that may remain active beyond the intended troubleshooting window.

Context-Inappropriate Capability

Medium
Confidence
97% confidence
Finding
The script launches Arthas with `--target-ip 0.0.0.0`, exposing its HTTP management API on all network interfaces rather than limiting it to localhost. Because Arthas provides deep JVM inspection and control capabilities, broad exposure can let unintended remote parties access sensitive diagnostics or issue management actions if network controls are weak or absent.

Natural-Language Policy Violations

Low
Confidence
92% confidence
Finding
A language-specific document can violate organizational language/locale policy when it forces a single language without user opt-in or justification. This file contains only Chinese content and does not indicate that it is a region-specific resource or provide alternatives.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
All comments and user-visible output in the script are written in Chinese, which imposes a specific language on users without any opt-in or alternative. This can violate language or locale policy when a skill is expected to be usable across a broader audience.

Static analysis

Detected: suspicious.env_credential_access

Environment variable access combined with network send.

Critical
Code
suspicious.env_credential_access
Location
scripts/arthas-mcp-stdio.js:11