Mar 4, 2026·6 min read·2 visits
OpenClaw Docker containers run as root (UID 0) by default. If an attacker gains Remote Code Execution (RCE) via the AI assistant, they immediately possess root access within the container, facilitating system modification and potential host escape. Fixed in recent updates by introducing a non-root 'sandbox' user.
OpenClaw, a popular open-source AI assistant, was found to execute critical containerized processes with full root privileges. This configuration violates the principle of least privilege and significantly lowers the barrier for attackers to achieve persistence or container escape following a compromise. The vulnerability affects multiple Dockerfiles used for end-to-end testing and sandboxing.
OpenClaw is an open-source personal AI assistant capable of executing tasks and managing workflows. To perform these tasks securely, it relies on containerized environments (Docker) for sandboxing and end-to-end (E2E) testing. However, a security audit revealed that multiple Dockerfiles within the project's repository were configured to execute processes as the root user (UID 0) by default.
This configuration represents a critical violation of the principle of least privilege (CWE-250). In a properly hardened container environment, applications should run as a dedicated, unprivileged user to limit the blast radius of a potential compromise. By running as root, the OpenClaw application removes standard operating system barriers that would otherwise contain an attacker.
The affected components include Dockerfile.sandbox, Dockerfile.sandbox-browser, and several testing configurations in the scripts/e2e directory. These environments are often used to execute untrusted code or parse complex inputs, making them high-value targets for exploitation.
The root cause of this vulnerability is the omission of the USER instruction in the project's Dockerfiles. By design, Docker containers execute processes as root unless a specific user is created and selected. This default behavior prioritizes developer convenience over security, requiring explicit intervention to harden.
In the vulnerable versions of OpenClaw, the base images (derived from node:22-bookworm) were used without defining a non-privileged user context. Consequently, the ENTRYPOINT and CMD instructions executed the AI assistant's core logic with full administrative permissions inside the container namespace.
Furthermore, the issue was compounded by file permission management. During the build process, files were copied into the image while the context was root. This resulted in the application files being owned by root, which historically discouraged developers from switching users, as a non-root user would lack permission to modify logs or configuration files created during the build steps.
The following analysis compares the vulnerable Docker configuration with the hardened version introduced in the patch. The key difference lies in the explicit creation of a service user and the reassignment of process ownership.
Vulnerable Configuration (Before Patch):
The original Dockerfile.sandbox lacked any user management instructions. The Node.js application started implicitly as UID 0.
# Dockerfile.sandbox (Vulnerable)
FROM node:22-bookworm
WORKDIR /app
COPY . .
# Application runs as ROOT by default here
CMD ["npm", "run", "start:sandbox"]Patched Configuration (After Patch):
The fix, applied in commit 28e1a65ebc580f07533966f5693f4df0a18d7085, introduces a dedicated sandbox user. It creates the user, ensures the home directory exists, and explicitly switches the context before the application starts.
# Dockerfile.sandbox (Fixed)
FROM node:22-bookworm
# 1. Create a non-root user
RUN useradd --create-home --shell /bin/bash sandbox
WORKDIR /home/sandbox
COPY . .
# 2. Switch context to the non-root user
USER sandbox
# Application now runs as 'sandbox' (non-root)
CMD ["npm", "run", "start:sandbox"]> [!NOTE]
> While the main sandbox files were patched, researchers noted that some E2E testing Dockerfiles (e.g., scripts/e2e/Dockerfile) may still require manual verification to ensure they have also been updated.
Exploitation of this vulnerability typically follows a post-compromise trajectory. An attacker must first achieve code execution within the container, likely through a separate vulnerability such as a malicious AI skill, a dependency confusion attack, or command injection via untrusted input.
Once code execution is achieved, the impact of the root privilege becomes immediate. In a standard attack flow against a non-root container, the attacker would first need to escalate privileges (PE) to gain full control. In OpenClaw's vulnerable configuration, this step is bypassed entirely.
Attack Flow:
id and receives uid=0(root) gid=0(root).The security impact of running as root is high, specifically affecting the confidentiality and integrity of the containerized environment. While the vulnerability exists within a container, it significantly weakens the isolation boundary between the application and the host kernel.
Key Impacts:
/proc and /sys filesystems in ways that unprivileged users cannot.Estimated CVSS v3.1 Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H (Score: ~8.5-9.0). The Scope (S) is marked as Changed (C) because root privileges inside a container can lead to impacts on the underlying host or other containers in the same network.
The primary remediation is to update OpenClaw to the latest version, which includes the Dockerfile patches. Administrators should verify that their deployment images are built from the patched Dockerfiles which include the USER sandbox directive.
Immediate Mitigation Strategies:
--user flag: docker run --user 1000:1000 openclaw/image.securityContext: runAsUser: 1000 and runAsNonRoot: true.--read-only) wherever possible, mounting writable volumes only for specific directories that require it (e.g., /tmp or log directories).--cap-drop=ALL and only add back strictly necessary ones. This limits what even a root user can do inside the container.CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
OpenClaw OpenClaw | < Feb 2026 Hygiene Patch | Commit 28e1a65 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-250 |
| CWE Name | Execution with Unnecessary Privileges |
| CVSS (Est.) | 8.5 (High) |
| Attack Vector | Network / Local |
| Privileges Required | None |
| Exploit Status | PoC Available |
The software performs an operation at a privilege level that is higher than the minimum level required, increasing the potential for damage.