Back to skill

Security audit

Docker Analyzer

Security checks for vulnerabilities and agentic risk

Overview

Docker Analyzer is a coherent Docker inspection helper, but its optimize command can let a crafted image name run arbitrary local code.

Review before installing. Use it only in a low-privilege environment and avoid passing untrusted image names, especially to optimize, until the heredoc/code injection issue is fixed. Expect it to read Docker image and container metadata from the local Docker environment.

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/docker_analyzer.sh:113
Finding
Arbitrary Python Code Execution Through Unsafely Interpolated Image Name## Vulnerability Details **File Location**: `scripts/docker_analyzer.sh`, lines 113–116 **Vulnerability Type**: Python code injection through an unquoted shell heredoc **Risk Level**: High ### Vulnerable Code ```bash python3 << PYEOF import subprocess, json image = "$image" try: ``` ### Technical Analysis The `optimize` command reads an image name from its first command-line argument and stores it in the shell variable `image`. It then uses an unquoted heredoc delimiter (`PYEOF`) to construct a Python program. Because the delimiter is unquoted, Bash performs parameter expansion within the heredoc before passing its contents to Python. The attacker-controlled value of `$image` is therefore inserted directly into Python source code inside a double-quoted string. An image argument containing a double quote can terminate that string and append arbitrary Python statements. A payload with the following structure demonstrates the injection primitive: ```text "; __import__("os").system("malicious-command"); # ``` After shell expansion, Python interprets the injected expression as executable source code. Execution occurs before the subsequent Docker operation can validate whether the supplied value is a legitimate image reference. The use of a list-form argument in the later `subprocess.check_output` call does not mitigate this earlier source-code injection. ### Attack Path 1. An attacker gains the ability to control or influence the image argument supplied to `docker-analyzer optimize`. 2. The script assigns that argument to the `image` shell variable. 3. Bash expands `$image` while processing the unquoted heredoc. 4. A crafted quote terminates the intended Python string and introduces attacker-selected Python statements. 5. The Python interpreter parses and executes those statements with the privileges of the Docker Analyzer process. 6. The injected code can invoke operating-system commands, read accessible fi ...[truncated 915 chars]
Remediation
## Remediation Suggestions Do not interpolate shell-controlled data into generated Python source. Pass the image name as a positional argument and quote the heredoc delimiter so that Bash performs no expansion: ```bash python3 - "$image" &lt;&lt;'PYEOF' import json import subprocess import sys image = sys.argv[1] try: out = subprocess.check_output( [ "docker", "history", "--no-trunc", "--format", "{{json .}}", image, ], stderr=subprocess.STDOUT, ).decode() # Continue processing the result. except Exception as exc: print("Error: {}".format(exc)) PYEOF ``` Additional hardening measures: 1. Preserve list-form subprocess invocation and never use `shell=True` for the image value. 2. Optionally validate image references against the syntax accepted by Docker as defense in depth, but do not treat validation as a substitute for separating data from code. 3. Add regression tests using image values containing quotes, backslashes, command substitutions, newlines, semicolons, and Python comment characters. 4. Run the analyzer with the least-privileged account possible and avoid unnecessary root or Docker daemon access. 5. Review future heredocs and embedded-language blocks to ensure all delimiters are quoted whenever shell expansion is unnecessary.
Vulnerability Patterns
  • 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
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (10)

Tool Parameter Abuse

High
Category
Tool Misuse
Content
cmd = l.get("CreatedBy", "")
        if "RUN" in cmd: run_count += 1
        if "COPY" in cmd or "ADD" in cmd: copy_count += 1
        if "apt-get install" in cmd and "rm -rf /var/lib/apt" not in cmd:
            suggestions.append("Clean apt cache after install: add '&& rm -rf /var/lib/apt/lists/*'")
        if "pip install" in cmd and "--no-cache-dir" not in cmd:
            suggestions.append("Add --no-cache-dir to pip install")
Confidence
100% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
cmd = l.get("CreatedBy", "")
        if "RUN" in cmd: run_count += 1
        if "COPY" in cmd or "ADD" in cmd: copy_count += 1
        if "apt-get install" in cmd and "rm -rf /var/lib/apt" not in cmd:
            suggestions.append("Clean apt cache after install: add '&& rm -rf /var/lib/apt/lists/*'")
        if "pip install" in cmd and "--no-cache-dir" not in cmd:
            suggestions.append("Add --no-cache-dir to pip install")
Confidence
100% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
cmd = l.get("CreatedBy", "")
        if "RUN" in cmd: run_count += 1
        if "COPY" in cmd or "ADD" in cmd: copy_count += 1
        if "apt-get install" in cmd and "rm -rf /var/lib/apt" not in cmd:
            suggestions.append("Clean apt cache after install: add '&& rm -rf /var/lib/apt/lists/*'")
        if "pip install" in cmd and "--no-cache-dir" not in cmd:
            suggestions.append("Add --no-cache-dir to pip install")
Confidence
95% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
cmd = l.get("CreatedBy", "")
        if "RUN" in cmd: run_count += 1
        if "COPY" in cmd or "ADD" in cmd: copy_count += 1
        if "apt-get install" in cmd and "rm -rf /var/lib/apt" not in cmd:
            suggestions.append("Clean apt cache after install: add '&& rm -rf /var/lib/apt/lists/*'")
        if "pip install" in cmd and "--no-cache-dir" not in cmd:
            suggestions.append("Add --no-cache-dir to pip install")
Confidence
100% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
if "RUN" in cmd: run_count += 1
        if "COPY" in cmd or "ADD" in cmd: copy_count += 1
        if "apt-get install" in cmd and "rm -rf /var/lib/apt" not in cmd:
            suggestions.append("Clean apt cache after install: add '&& rm -rf /var/lib/apt/lists/*'")
        if "pip install" in cmd and "--no-cache-dir" not in cmd:
            suggestions.append("Add --no-cache-dir to pip install")
    if run_count > 5:
Confidence
95% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Chaining Abuse

High
Category
Tool Misuse
Content
if "RUN" in cmd: run_count += 1
        if "COPY" in cmd or "ADD" in cmd: copy_count += 1
        if "apt-get install" in cmd and "rm -rf /var/lib/apt" not in cmd:
            suggestions.append("Clean apt cache after install: add '&& rm -rf /var/lib/apt/lists/*'")
        if "pip install" in cmd and "--no-cache-dir" not in cmd:
            suggestions.append("Add --no-cache-dir to pip install")
    if run_count > 5:
Confidence
75% confidence
Finding
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Lp3

Medium
Category
MCP Least Privilege
Confidence
80% confidence
Finding
The skill metadata declares a Python runtime and static analysis detected shell capability, but the manifest does not define any tool scope such as permissions or allowed-tools. In agent environments, omitted scope can result in broader-than-necessary execution authority, increasing the risk that downstream commands interact with the host or Docker daemon without explicit limitation.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The listed commands are extremely generic (`run`, `info`, `status`, `help`) and provide no constraints on inputs, target images, or safety boundaries. In a skill that analyzes Docker images, vague triggers can cause an agent to invoke risky execution paths or pass attacker-controlled arguments into shell-backed tooling with insufficient validation.

Unrestricted Tool Access

Medium
Category
Excessive Agency
Content
## Usage

Run any command: `docker-analyzer <command> [args]`

---
> **Disclaimer**: This skill is an independent, original implementation. It is not affiliated with, endorsed by, or derived from the referenced open-source project. No code was copied. The reference is for context only.
Confidence
91% confidence
Finding
The usage text explicitly states 'Run any command,' which signals unconstrained command dispatch. In the context of a Docker analysis skill with shell capability, this can enable arbitrary command execution or unsafe argument forwarding, potentially exposing the host, local files, secrets, or the Docker socket if the implementation maps the command string directly to a shell or CLI.

Missing User Warnings

Low
Confidence
83% confidence
Finding
The inspect command retrieves and displays Docker image metadata including entrypoint, command, exposed ports, labels, and the presence of environment variables. Although this is read-only behavior, it surfaces potentially sensitive system/application configuration and the script provides no user-facing warning or caution beyond basic usage text.

Static analysis

No suspicious patterns detected.