T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/manage.py:12
- Finding
- Unrestricted Loading of a Hard-Coded Workspace Credential File<![CDATA[ ## Vulnerability Details **File Location**: `scripts/manage.py`, lines 12–19 **Vulnerability Type**: Unauthorized access to credential-bearing files **Risk Level**: High ### Vulnerable Code ```python # 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: _line = _line.strip() if _line and '=' in _line and not _line.startswith('#'): _k, _v = _line.split('=', 1) os.environ.setdefault(_k.strip(), _v.strip()) ``` ### Technical Analysis The Skill silently reads every key-value pair from a hard-coded `.env` file belonging to a specific workspace. Its documented functionality only requires a small set of Portainer-related settings, but the implementation imports all entries into the process environment without filtering. This exceeds least privilege because unrelated credentials may be present in the same file. The behavior is neither required by the declared stack-management functionality nor disclosed in `SKILL.md`. The hard-coded user-specific path also makes the Skill non-portable and risks crossing workspace or tenant boundaries when deployed in a shared environment. Although the current script only explicitly uses selected environment variables, importing unrelated secrets unnecessarily exposes them to the process and to any future code executed in that process. ### Attack Path 1. A user invokes the Skill on a host where `/home/node/.openclaw/workspace/liyj/.env` exists. 2. The Skill opens the file without explicit user authorization or an opt-in command-line option. 3. Every syntactically valid entry is imported into `os.environ`. 4. Unrelated credentials become accessible to the Skill process and any subsequently introduced or invoked code. 5. A separate flaw, malicious modification, or diagnostic behavior could then disclose or misuse those credentials. ### Impact ...[truncated 322 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the hard-coded automatic `.env` loading behavior. - Require callers to provide only the documented variables through the execution environment. - If file-based configuration is necessary, add an explicit `--env-file` option and require informed user consent. - Allowlist only `PORTAINER_API_KEY`, `PORTAINER_URL`, `PORTAINER_ENDPOINT`, `CLAW_STACK_ID`, and `CLAW_IMAGE`. - Reject unknown keys instead of importing the entire file. - Verify that any configuration file is owned by the expected user and is not group- or world-readable. - Avoid binding the Skill to a user-specific absolute path. ]]>
