Back to skill

Security audit

X5 Protocol Client

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent X5 API client, but it handles app secrets and has concrete disclosure and command-generation risks users should review before installing.

Install only if you are comfortable with an agent handling X5 app IDs, app keys, request bodies, and arbitrary target URLs. Avoid putting real app keys on the command line or in shared .x5 files, do not run --list --json on files containing secrets, verify every destination URL before sending, and treat generated cURL output from untrusted .x5 files as unsafe unless manually reviewed and properly escaped.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/x5_client.py:430
Finding

Application Secrets Exposed Through JSON List Output

Content
View full analysis
str: """Format the result for display.""" if json_mode: return json.dumps(result, indent=2, ensure_ascii=False) ``` ### Technical Analysis Each parsed request object contains the `appkey` directive from the `.x5` file: ```python elif key_lower == 'appkey': result['appkey'] = value ``` When `--list --json` is used, the program places the complete `requests` collection into the result and serializes it without filtering sensitive fields. Consequently, application secret keys are written to standard output alongside non-sensitive request metadata. Other execution modes use `_safe_request()` to construct a restricted output object, but list mode bypasses that protection. This behavior is unnecessary for listing requests because the human-readable list only requires fields such as name, method, URL, and optional headers. The documentation recommends using `--json` for programmatic consumption, making accidental disclosure to agent context, CI logs, terminal captures, or automation systems reasonably likely. ### Attack Path 1. An attacker supplies or modifies an `.x5` file containing an application credential in its `@appkey` directive. 2. A user or agent invokes the documented list operation with JSON output: ```bash python3 scripts/x5_client.py --file request.x5 --list --json ``` 3. The parser stores the secret in each request dictionary. 4. List mode passes the complete dictionaries to `format_output()`. 5. `json.dumps()` writes the application key to standard output. 6. T ...[truncated 648 chars]
Remediation
View remediation
dict: return { 'name': req.get('name'), 'method': req.get('method'), 'url': req.get('url'), 'headers': req.get('headers', {}), } if args.list: result = { 'mode': 'list', 'requests': [_safe_list_request(req) for req in requests], } print(format_output(result, args.json)) return ``` - Consider redacting other potentially sensitive values, particularly authorization headers, cookies, and API tokens in custom headers. - Apply centralized output sanitization so new output modes cannot accidentally bypass secret filtering. - Add automated tests confirming that `appkey`, authorization headers, and representative secret values never appear in either JSON or human-readable list output. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/x5_client.py:290
Finding

Shell Command Injection Through Generated cURL Commands

Content
View full analysis
str: """Generate an equivalent cURL command.""" parts = [f"curl -X POST '{url}'"] parts.append(" -H 'Content-Type: application/x-www-form-urlencoded'") for key, value in custom_headers.items(): parts.append(f" -H '{key}: {value}'") parts.append(f" --data-raw '{form_data}'") return ' \\\n'.join(parts) ``` ### Technical Analysis The function attempts to quote the URL, custom header names, header values, and request data by surrounding them with single quotes. It does not escape embedded single-quote characters. The URL and custom headers may originate from an externally supplied `.x5` file or CLI arguments. A malicious value containing a single quote can terminate the intended shell argument and inject shell metacharacters or additional commands. The Python program does not execute the generated command itself, so exploitation requires the user or an agent to execute or paste the generated cURL command. Nevertheless, command generation is a declared feature, and its output is presented as an equivalent command suitable for execution. For example, an attacker-controlled URL conceptually shaped as: ```text https://example.invalid/'; attacker_command; echo ' ``` breaks out of the quoted URL when the generated string is interpreted by a POSIX shell. Similar injection is possible through custom header names or values. ### Attack Path 1. An attacker prepares an `.x5` file containing a URL or custom header with an embedded single quote and shell syntax. 2. The victim invokes cURL-generation mode: ```bash python3 scripts/x5_client.py --file attacker-supplied.x5 --curl ``` 3. `generate_curl()` inserts the attacker-controlled value ...[truncated 930 chars]
Remediation
View remediation
str: parts = [ "curl", "-X", "POST", shlex.quote(url), "-H", shlex.quote("Content-Type: application/x-www-form-urlencoded"), ] for key, value in custom_headers.items(): parts.extend(["-H", shlex.quote(f"{key}: {value}")]) parts.extend(["--data-raw", shlex.quote(form_data)]) return " ".join(parts) ``` - Reject carriage returns and line feeds in header names and values to prevent malformed or misleading generated commands. - Validate header names against the HTTP token grammar. - Prefer returning a structured argument array for programmatic consumers instead of executable shell text. - Clearly label generated commands as untrusted when their inputs came from an external file. - Add tests covering single quotes, command substitutions, semicolons, newlines, backticks, spaces, and other shell metacharacters in URLs and headers. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Rogue AgentSelf-Modification, Session Persistence
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (8)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Send X5 protocol requests directly from the terminal using `scripts/x5_client.py`.

Tainted flow: 'req' from pathlib.Path.read_text (line 440, file read) → urllib.request.urlopen (network output)

High
Category
Data Flow
Confidence
80% confidence
Finding

File contents flow to a network sink. This may indicate data exfiltration of sensitive files.

Content

Scanner excerpt · scripts/x5_client.py (reported line 218)May include surrounding context.

python
start = time.time()

    try:
        with urllib.request.urlopen(req, timeout=timeout / 1000) as resp:
            duration_ms = int((time.time() - start) * 1000)
            status = resp.status
            status_text = resp.reason or 'OK'

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill clearly instructs use of a Python client that reads local files, invokes shell commands, and sends network requests, but it declares no tool scope or permissions boundary. In an agent environment, that omission increases the chance the skill can be invoked with broader-than-necessary capabilities, leading to unintended file access or outbound requests without clear user awareness.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The quick-start examples encourage sending appid/appkey and request bodies directly to remote endpoints, but the skill does not prominently warn users that credentials and payloads will be transmitted over the network. This is especially risky because examples include plain HTTP localhost usage and normalize passing secrets on the command line, which can leak via shell history, process listings, logs, or accidental targeting of non-local endpoints.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

Multiple requests per file:

x5
### Create Resource
@name = createResource
@appid = my_app
@appkey = my_key

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

This code performs an outbound HTTP POST using the provided URL and transmits the encoded request body, which may contain user or system data. While the module docstring says it sends API requests, there is no runtime confirmation, visible log before transmission, or explicit warning about network transmission or potential data exposure.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
85% confidence
Finding

The generated cURL command embeds the full encoded request payload directly in the command line, which may include sensitive request bodies and material derived from credentials. Users commonly paste, log, save, or share cURL commands, so this feature can unintentionally leak secrets or proprietary API data outside the intended execution context.

Content

Scanner excerpt · scripts/x5_client.py (reported line 288)May include surrounding context.

python
return raw_body


# ─── cURL Generation ───────────────────────────────────────────────────────────

def generate_curl(url: str, form_data: str, custom_headers: dict[str, str]) -> str:
    """Generate an equivalent cURL command."""

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The CLI accepts an App Key directly as an argument and also parses appkey values from files, which are credentials or secret material. Although the code uses the key for signature generation, it does not warn users that passing secrets on the command line or in request files may expose them via shell history, process listings, or local storage.

Content

No source excerpt is available for this finding.