Back to skill

Security audit

Claw Stack Manager

Security checks for vulnerabilities and agentic risk

Overview

This skill does what it claims at a high level, but it has under-disclosed, high-impact Docker and credential-handling behavior that users should review carefully before installing.

Install only if you are comfortable giving this skill strong Portainer control over the configured Docker endpoint. Before use, remove or review the hard-coded .env loading, rotate any Portainer key previously used with this implementation, avoid running update until the helper-container key exposure and ng-agent deletion behavior are fixed, and use a narrowly scoped Portainer API key where possible.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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 (5)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/manage.py:12
Finding

Unrestricted Loading of a Hard-Coded Workspace Credential File

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/manage.py:134
Finding

Portainer API Key Persisted in Docker Container Command Metadata

Content
View full analysis
/dev/null\n' f'echo ""\n' f'echo "R: 2/2 Deploying with updated config..."\n' f'curl -sS -X PUT -H "X-API-Key: {KEY}" ' f'-H "Content-Type: application/json" ' f'-d \'@-\' ' f'{HOST}/api/stacks/{stack_id}?endpointId={EP} << "PAYLOAD"\n' f'{payload}\n' f'PAYLOAD\n' f'echo ""\n' f'echo "R: Done."\n' ) else: script = ( 'apk add -q curl\n' f'echo "R: Stack already stopped, deploying..."\n' f'curl -sS -X PUT -H "X-API-Key: {KEY}" ' f'-H "Content-Type: application/json" ' f'-d \'@-\' ' f'{HOST}/api/stacks/{stack_id}?endpointId={EP} << "PAYLOAD"\n' f'{payload}\n' f'PAYLOAD\n' f'echo ""\n' f'echo "R: Done."\n' ) # Use unique name to avoid collision ts = datetime.now().strftime("%Y%m%d%H%M%S") container_name = f"claw-redep-{ts}" config = { "Image": "alpine:latest", "Cmd": ["/bin/sh", "-c", script.strip()], "HostConfig": {"NetworkMode": "host"}, "Labels": {"io.portainer.stack.name": f"redeployer-{stack_id}"} } ``` ### Technical Analysis The Portainer API key is interpolated directly into a generated shell script. That entire script is then assigned to the Docker container's `Cmd` field. Docker and Portainer retain container configuration metadata, including command arguments. Consequently, the plaintext API key can be recovered through container inspection, Portainer API responses, daemon backups, debugging output, or other management interfaces. The container is no ...[truncated 1108 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/manage.py:134
Finding

Shell Command Injection Through Unsafely Interpolated Configuration Values

Content
View full analysis
/dev/null\n' f'echo ""\n' f'echo "R: 2/2 Deploying with updated config..."\n' f'curl -sS -X PUT -H "X-API-Key: {KEY}" ' f'-H "Content-Type: application/json" ' f'-d \'@-\' ' f'{HOST}/api/stacks/{stack_id}?endpointId={EP} << "PAYLOAD"\n' f'{payload}\n' f'PAYLOAD\n' f'echo ""\n' f'echo "R: Done."\n' ) else: script = ( 'apk add -q curl\n' f'echo "R: Stack already stopped, deploying..."\n' f'curl -sS -X PUT -H "X-API-Key: {KEY}" ' f'-H "Content-Type: application/json" ' f'-d \'@-\' ' f'{HOST}/api/stacks/{stack_id}?endpointId={EP} << "PAYLOAD"\n' f'{payload}\n' f'PAYLOAD\n' f'echo ""\n' f'echo "R: Done."\n' ) ``` The generated value is subsequently executed by a shell: ```python config = { "Image": "alpine:latest", "Cmd": ["/bin/sh", "-c", script.strip()], "HostConfig": {"NetworkMode": "host"}, "Labels": {"io.portainer.stack.name": f"redeployer-{stack_id}"} } ``` ### Technical Analysis `HOST` and `KEY` originate from environment variables and are directly interpolated into a shell program without shell-safe argument separation or validation. The resulting string is executed by `/bin/sh -c`. Shell metacharacters embedded in these values can alter command structure. For example, a malicious `PORTAINER_URL` containing a command separator can append commands to the generated `curl` line. The hard-coded `.env` loader increases the available configuration source through which ...[truncated 1441 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/manage.py:108
Finding

Undeclared Forced Deletion of Potentially Unrelated Containers

Content
View full analysis
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
scripts/manage.py:134
Finding

Mutable Redeployer Image and Unpinned Runtime Package Installation

Content
View full analysis
/dev/null\n' f'echo ""\n' f'echo "R: 2/2 Deploying with updated config..."\n' f'curl -sS -X PUT -H "X-API-Key: {KEY}" ' f'-H "Content-Type: application/json" ' f'-d \'@-\' ' f'{HOST}/api/stacks/{stack_id}?endpointId={EP} << "PAYLOAD"\n' f'{payload}\n' f'PAYLOAD\n' f'echo ""\n' f'echo "R: Done."\n' ) else: script = ( 'apk add -q curl\n' f'echo "R: Stack already stopped, deploying..."\n' f'curl -sS -X PUT -H "X-API-Key: {KEY}" ' f'-H "Content-Type: application/json" ' f'-d \'@-\' ' f'{HOST}/api/stacks/{stack_id}?endpointId={EP} << "PAYLOAD"\n' f'{payload}\n' f'PAYLOAD\n' f'echo ""\n' f'echo "R: Done."\n' ) config = { "Image": "alpine:latest", "Cmd": ["/bin/sh", "-c", script.strip()], "HostConfig": {"NetworkMode": "host"}, "Labels": {"io.portainer.stack.name": f"redeployer-{stack_id}"} } ``` ### Technical Analysis The helper container uses the mutable `alpine:latest` image tag and installs `curl` from configured package repositories every time it runs. Neither the base image digest nor the package version is pinned. As a result, the executed dependency set can change after the Skill has been reviewed, without any modification to the Skill package. A compromised registry account, package repository, mirror, or mutable image tag could introduce malicious behavior into a container that receives host-network access and contains a Portainer API key ...[truncated 1020 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
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (10)

Tainted flow: 'req' from os.environ.get (line 49, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/manage.py (reported line 55)May include surrounding context.

python
if data is not None:
        req.data = json.dumps(data).encode()
    try:
        resp = urllib.request.urlopen(req, timeout=timeout)
        if raw:
            return resp.status, resp.read()
        return resp.status, json.loads(resp.read())

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

The script automatically loads credentials from a hard-coded .env path in the workspace. This creates implicit credential access behavior and couples privileged API use to a developer-specific file location, which can surprise operators and expose secrets if the workspace is shared or improperly protected.

Content

Scanner excerpt · scripts/manage.py (reported line 12)May include surrounding context.

python
import json, os, urllib.parse, urllib.request, sys
from datetime import datetime, timezone, timedelta

# Auto-load .env from workspace root
_env_path = '/home/node/.openclaw/workspace/liyj/.env'
if os.path.isfile(_env_path):
    with open(_env_path) as _f:

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

The .env parsing logic reads arbitrary key/value pairs from a local workspace file into process environment variables without user confirmation. In this privileged management script, that behavior can silently import sensitive credentials or attacker-controlled configuration that alters where privileged API requests are sent.

Content

Scanner excerpt · scripts/manage.py (reported line 13)May include surrounding context.

python
from datetime import datetime, timezone, timedelta

# Auto-load .env from workspace root
_env_path = '/home/node/.openclaw/workspace/liyj/.env'
if os.path.isfile(_env_path):
    with open(_env_path) as _f:
        for _line in _f:

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The code force-deletes containers matching 'ng-agent' even though that action is unrelated to the stated stack redeploy purpose. Deleting unrelated containers can cause denial of service, interfere with other agents or security tooling, and exceeds the principle of least privilege.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill exposes capabilities that can access environment variables, make network requests, and execute shell commands, but the manifest does not declare any tool scope or permission boundaries. For a stack-management skill that can stop and redeploy services through the Portainer API, this lack of explicit scope increases the chance of unintended or overly broad execution in an automation environment.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The documentation describes update and redeploy behavior that stops stacks and replaces running services, but it does not clearly warn operators about service interruption, replacement risk, or the operational impact of targeting the wrong stack. In this context, that omission is security-relevant because the skill performs high-impact infrastructure actions and could be invoked without adequate operator awareness or safeguards.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
90% confidence
Finding

The script embeds the Portainer API key and full stack payload into a shell script executed inside a temporary container over host networking. This transmits privileged credentials and configuration into another execution environment, increasing exposure through process inspection, logs, container metadata, or compromise of that helper container.

Content

Scanner excerpt · scripts/manage.py (reported line 142)May include surrounding context.

python
script = (
            'apk add -q curl\n'
            f'echo "R: 1/2 Stopping stack {stack_id}..."\n'
            f'curl -sS -X POST -H "X-API-Key: {KEY}" '
            f'{HOST}/api/stacks/{stack_id}/stop?endpointId={EP} >/dev/null\n'
            f'echo ""\n'
            f'echo "R: 2/2 Deploying with updated config..."\n'

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill claims to manage stacks, but it also directly restarts a specific container outside stack-scoped operations. This creates a broader operational capability than advertised, increasing the chance of unintended service disruption or misuse by callers who expect only stack-level actions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script performs impactful actions such as image pulls, stack stop/redeploy, and container restart without an interactive confirmation or a dry-run safeguard. In an agent skill context, this makes accidental or unintended destructive operations more likely, especially when invoked programmatically.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

The script fetches stack environment metadata from Portainer and logs the variable names. Even without values, variable names can disclose sensitive implementation details such as the presence of secret-bearing configuration, third-party integrations, or internal service names.

Content

No source excerpt is available for this finding.