Back to skill

Security audit

Mihomo CLI

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent Mihomo controller helper, but it can silently use a local bearer secret and send it over plaintext HTTP to a configurable controller host.

Review this before installing if you use a Mihomo API secret or a non-local controller. Keep the controller bound to localhost where possible, avoid passing secrets on the command line, and do not let an agent run switch, flush, restart, or raw API calls unless you explicitly asked for that network-impacting change.

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/mihomo-cli.sh:82
Finding
Bearer Secret Transmitted over Plaintext HTTP to a Configurable Controller<![CDATA[ ## Vulnerability Details **File Location**: `scripts/mihomo-cli.sh`, lines 82-96 **Vulnerability Type**: Plaintext transmission of sensitive authentication credentials **Risk Level**: High ### Vulnerable Code ```bash api_request() { local method="${1:-GET}" local endpoint="$2" local data="${3:-}" local url="http://$MIHOMO_API_HOST$endpoint" local curl_args=(-s) [ -n "$MIHOMO_SECRET" ] && curl_args+=(-H "Authorization: Bearer $MIHOMO_SECRET") if [ "$method" = "GET" ]; then curl "${curl_args[@]}" "$url" else curl "${curl_args[@]}" -X "$method" -H "Content-Type: application/json" "$url" ${data:+-d "$data"} fi } ``` Related controller and credential inputs are accepted from the environment near lines 13-15: ```bash MIHOMO_CONFIG_PATH="${MIHOMO_CONFIG:-}" MIHOMO_API_HOST="${MIHOMO_HOST:-127.0.0.1:9090}" MIHOMO_SECRET="${MIHOMO_SECRET:-}" ``` The controller may also be supplied through command-line options near lines 228-231: ```bash -h|--host) MIHOMO_API_HOST="$2" shift 2 ;; ``` ### Technical Analysis Every API URL is constructed with the fixed `http://` scheme. When a Mihomo secret is available, the script adds it to the request as an `Authorization: Bearer` header. This is reasonably safe from passive network interception when the destination is strictly a loopback interface, but the script does not enforce that restriction. `MIHOMO_API_HOST` may be populated from the `MIHOMO_HOST` environment variable, the `--host` command-line option, or an `external-controller` value extracted from a detected configuration file. Consequently, the bearer secret can be sent over an unencrypted network connection to a non-loopback controller. There is no HTTPS support, certificate verification policy, non-loopback warning, or refusal to transmit credentials over plaintext HTTP. Reading and using the secret is necessary for authenticated Mihomo administration, but transmitting it without transpor ...[truncated 1825 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Enforce a loopback destination by default.** Accept only `127.0.0.1`, `localhost`, or `[::1]` unless the user explicitly enables remote-controller access. 2. **Refuse plaintext credential transmission to non-loopback hosts.** If a secret is configured and the destination is remote, terminate with an error rather than sending the bearer header over HTTP. 3. **Support HTTPS for remote controllers.** Allow a complete controller URL or a separate scheme setting, and retain curl's certificate and hostname verification defaults. 4. **Do not introduce insecure TLS bypasses.** Avoid `curl -k` or `--insecure`. If private certificate authorities are required, provide an explicit CA-file option. 5. **Require explicit remote-access consent.** Add a clearly named option such as `--allow-remote-controller`, ideally combined with mandatory HTTPS. 6. **Validate controller input.** Parse and validate the scheme, host, port, and allowed characters instead of concatenating an unrestricted value into a URL. 7. **Document the trust boundary.** State that environment variables, command-line controller values, and `external-controller` configuration entries determine where the bearer credential is sent. 8. **Reduce command-line secret exposure.** Prefer protected configuration files, standard input, or a credential store over `--secret`, since command-line arguments may be visible in shell history or process listings. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (24)

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
scripts/mihomo-cli.sh status
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Tool Parameter Abuse

High
Category
Tool Misuse
Content
- `GET /traffic` - WebSocket stream of traffic stats
- `GET /logs?level=debug|info|warning|error` - WebSocket stream of logs
- `GET /connections` - List active connections
- `DELETE /connections/:id` - Close specific connection

### Providers
- `GET /providers/proxies` - List all proxy providers
Confidence
89% confidence
Finding
The documented `DELETE /connections/:id` endpoint allows termination of arbitrary active connections, and the reference does not describe validation, authorization boundaries, or confirmation safeguards around selecting the connection identifier. In an agent context, a user or prompt could steer the tool into closing sensitive or critical sessions, causing denial of service or disrupting security-relevant traffic.

Lp3

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding
The skill instructs use of a bundled shell script but does not declare any explicit tool scope or permission boundaries. That creates an avoidable trust gap: an agent may invoke shell access for host inspection and Mihomo control without the skill clearly constraining what commands are permitted, increasing the chance of unintended system access or misuse.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The skill documents state-changing operations like proxy switching, cache flushing, and restart, but the quick-start command list presents them without a prominent user-facing warning about service interruption or network-impacting side effects. In this context, those actions can disrupt connectivity, change routing unexpectedly, or interrupt active sessions if an agent executes them too eagerly.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The documentation prominently includes state-changing endpoints such as restart, proxy switching, cache flushes, and connection termination without warning that these operations alter system state and may disrupt network connectivity. In an agent skill context, this increases the chance an automated assistant will invoke destructive actions without explicit user confirmation or understanding of side effects.

External Transmission

Medium
Category
Data Exfiltration
Content
### Switch Group
```bash
curl -X PUT -H "Authorization: Bearer $SECRET" \
  -H "Content-Type: application/json" \
  -d '{"name":"Proxy Name"}' \
  http://localhost:9090/proxies/GLOBAL
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The script automatically reads the Mihomo API secret from environment variables or the local config file and then uses it for authenticated API calls without any user-facing notice. In an agent-skill context, this silently expands the tool's privilege to perform authenticated local control actions, which can surprise users and enable unauthorized state-changing operations if the skill is invoked indirectly.

External Transmission

Medium
Category
Data Exfiltration
Content
[ -n "$MIHOMO_SECRET" ] && curl_args+=(-H "Authorization: Bearer $MIHOMO_SECRET")

    if [ "$method" = "GET" ]; then
        curl "${curl_args[@]}" "$url"
    else
        curl "${curl_args[@]}" -X "$method" -H "Content-Type: application/json" "$url" ${data:+-d "$data"}
    fi
Confidence
83% confidence
Finding
The helper transmits requests, including a bearer token when available, to whatever host is set in MIHOMO_HOST, command-line options, or extracted config, using plain HTTP. In this skill context, that means an agent can send sensitive local configuration-derived credentials and control requests to a non-local or attacker-controlled endpoint if the host is changed or the config is maliciously crafted.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The script exposes state-changing operations such as cache flush and service restart with no confirmation, dry-run mode, or warning about impact. In a local agent setting, a simple invocation can disrupt connectivity, alter proxy behavior, or interrupt the Mihomo service unexpectedly.

Missing User Warnings

Low
Confidence
83% confidence
Finding
The API reference shows use of an Authorization bearer secret but provides no guidance on protecting, redacting, or avoiding disclosure of that credential in logs, transcripts, or shell history. In a tool-using agent setting, secrets may be echoed, persisted, or mishandled unless the documentation explicitly warns about secure credential handling.

Static analysis

No suspicious patterns detected.