Security Audit Findings

Nov 22, 2026, 10:01 AM·gpt-6-thinking

Security audit: bkisonka/claw2

Repository: github.com/bkisonka/claw2
Audit date: November 22, 2026
Scope: Authentication bypass, Docker isolation, host compromise, API security, and AI-agent execution.

The repository implements a self-hosted AI assistant with a Node.js gateway, web interface, Telegram integration, and Docker-based execution of agent skills.

Two important security concerns have emerged from the source review:

  1. Authentication boundary inconsistency: In JWT registration mode, POST /chat is classified as a public path, despite executing the assistant's chat-processing logic. The effect depends on whether a separate gateway API key is enabled.
  2. Docker host-control exposure: The deployment grants its Docker API proxy container creation and other management capabilities. Compromising the gateway could therefore potentially compromise the Docker host, even though the gateway does not mount docker.sock directly.

The first issue concerns access to the assistant; the second concerns escalation from the assistant's gateway to its host.

Audit limitations: This is a source-code security review, not a successful exploit demonstration. Docker escape, remote exploitation, and privilege escalation need to be distinguished from risky configuration and excessive privileges.

Findings and severity

Finding Severity Assessment
Docker API proxy permits host-level operations Critical Confirmed dangerous configuration
JWT bypass on POST /chat High Confirmed code path; requires registration mode and no separate API-key protection
Skill approval through the unauthenticated chat path High Confirmed code path under the same conditions
Symlink-based filesystem boundary bypass High Confirmed missing canonical-path validation; exploitation requires a suitable symlink
Unrestricted per-user configuration overrides High Confirmed; impact depends on multi-user deployment
Cross-site request forgery with authentication disabled High Plausible browser attack; not dynamically verified
Remote access relies on a proxy-supplied header Medium-High Configuration-dependent authentication weakness
JWT revocation and inactive-account checks Medium Missing checks identified
Unbounded request reading in the LLM-room handler Medium Confirmed availability risk when the handler is reachable

1. Critical: Docker API proxy can permit host compromise

Affected file: compose.yml, lines 66-89

The configuration grants the proxy:

- CONTAINERS=1
- IMAGES=1
- INFO=1
- NETWORKS=1
- SYSTEM=1
- LOGS=1
- POST=1

These permissions are substantially broader than the comments suggest.

In particular, CONTAINERS=1 combined with POST=1 permits Docker container-creation operations. The proxy's settings do not independently restrict the resulting container's privileges, host mounts, or namespace configuration.

This behavior is documented in the and has been verified in published Docker API proxy tests. <Cite refs={["turn955566view0","turn955566view1"]}/>

Potential impact: An attacker who gains code execution inside the gateway can use its Docker API access to request a container with dangerous privileges or host filesystem mounts. On a conventional rootful Docker host, this can result in host-level compromise.

The gateway's own runAgent() implementation includes useful restrictions, such as --cap-drop=ALL, --read-only, and --security-opt=no-new-privileges. However, those flags constrain only containers created through that application code. They do not constrain arbitrary requests made directly to the Docker proxy by a compromised gateway process.

This is not evidence that ordinary skill code can directly access the Docker API. The gateway and skills use different Docker networks, providing an additional boundary.

Recommended fix: Replace broad Docker API access with a sandbox-launcher service that validates each container-creation request, including mounts, image, user, privileges, namespaces, and network membership. Run that launcher under the least privileged Docker environment feasible.

Simply setting EXEC=0 does not solve this issue: dangerous container creation remains available.

2. High: JWT authentication bypass on the chat endpoint

Affected file: src/gateway/server.ts, lines 570-590 and 1007-1036

The public-path list includes:

const AUTH_PUBLIC_PATHS = new Set([
  "/api/register",
  "/api/login",
  "/api/logout",
  "/api/me",
  "/api/voice/capabilities",
  "/health",
  "/",
  "/chat",
  // ...
]);

Later, registration-mode authorization uses:

if (!isAuthPublicPath(p) && !authPayload) {
  // Return 401
}

But /chat is also the route handling:

if (req.method === "POST" && p === "/chat") {
  // Process assistant message
}

The problem is that the authorization exception checks only the path, not the HTTP method.

A public GET /chat page and a privileged POST /chat action are treated identically.

An unauthenticated request can therefore reach the chat handler when registration mode is active. Without a verified JWT, the code leaves userId as "default".

There is an important qualification: the separate gateway API-key check runs earlier. If gateway.auth.enabled is true and a valid API key is configured, this still blocks unauthorized access.

Recommended fix: Make authorization explicitly method-aware, limiting the public exception to GET /chat. All chat-execution requests should require an authenticated identity in registration mode, independently of any optional outer API key.

3. High: Skill approval inherits the authentication flaw

Affected file: src/gateway/server.ts, lines 1114-1146

The chat handler recognizes /allow <skill.js> as a user command. It then:

  • Checks whether the skill file exists.
  • Adds the skill to skills.allowlist.
  • Writes the modified YAML configuration.
  • Reloads the configuration immediately.

This action is based on the assumption that a chat message necessarily comes from an authenticated user.

Because the chat endpoint has the JWT exception described above, that assumption does not always hold.

Impact: When the authentication conditions permit unauthenticated chat access, a caller can also approve an existing skill without the intended user authorization. That undermines an important control separating model-generated code from approved executable code.

Recommended fix: Require explicit server-side authentication and authorization for skill approval. Ideally, move approval to a dedicated authenticated API route with an administrator permission check.

4. High: Filesystem sandbox bypass through symbolic links

Affected files:

The filesystem permission checks rely on resolve() and relative().

These functions normalize path syntax, but they do not resolve symbolic links.

For example, the application's path checker may approve a file that appears to be under:

/app/agents/output/

However, a symbolic link inside that directory could resolve to a different location in the gateway filesystem.

The same problem affects /files/. Its implementation uses lstatSync() to reject symbolic links, but only checks the final filesystem object. A symbolic link in a parent directory is not rejected.

Why this matters

The Docker skill sandbox can write into its output directory, which is bind-mounted into the gateway.

A malicious or compromised skill could potentially create a symbolic link that subsequently resolves to a sensitive gateway directory.

When the gateway processes the resulting path, the filesystem operation runs with the gateway's privileges, not the restricted skill container's privileges.

This creates a possible route to reading or modifying files outside the intended skill workspace.

The vulnerable path validation is confirmed. A complete exploitation chain has not been dynamically demonstrated.

Recommended fix: Resolve and validate the entire filesystem path, including parent components. Reject symlinks in untrusted paths and use race-resistant filesystem operations where available. Do not rely on lexical path normalization as a security boundary.

5. High: Registered users can override security-critical configuration

Affected files:

In registration mode, the application stores user-specific configuration in PostgreSQL.

The server merges that configuration with the gateway's base configuration using a general-purpose recursive merge.

There is no apparent server-enforced whitelist preventing users from overriding security-sensitive settings.

This includes settings governing:

  • Filesystem access via allowlist.paths.
  • Whether skills execute inside Docker via sandbox.useDocker.
  • Host filesystem permissions via sandbox.hostFs.
  • Outbound restrictions via sandbox.egress.
  • Other security-policy settings.

For example, the code explicitly supports:

if (mode === "full") {
  return [
    "--permission",
    "--allow-fs-read=*",
    "--allow-fs-write=*"
  ];
}

When a registered user submits configuration changes, the resulting effective configuration is subsequently passed into the orchestrator.

Impact: An ordinary registered user may be able to weaken filesystem and execution isolation for their own agent session. Because the gateway executes these operations in a shared server environment, the consequences can extend beyond that user's data.

On a Docker deployment, selecting host execution means execution inside the gateway container rather than directly on the physical machine. Nevertheless, it removes the additional sibling-container isolation.

Recommended fix: Separate administrator-controlled security policy from user preferences. User configuration must not be able to override filesystem boundaries, execution isolation, network policy, or secret-access controls.

For a multi-user service, this is a particularly important issue.

6. High: Cross-site requests can reach an authentication-disabled gateway

Affected files:

When authentication is disabled, the server attempts to prevent cross-site access by checking the HTTP Host header.

It also withholds permissive CORS headers.

However, CORS does not prevent every cross-origin request from being sent. It primarily controls whether browser JavaScript can read the response.

A malicious website can potentially send a simple request to a loopback service using an accepted content type such as text/plain.

The gateway's chat handler parses the body as JSON without requiring Content-Type: application/json.

Consequently, a browser-originated request may invoke an operation even if the attacker cannot read the response.

Browser private-network protections can affect exploitability, and I have not tested an actual browser exploit.

The default Compose configuration publishes the service on loopback, which is good for limiting network exposure, but it does not eliminate browser-to-loopback risks.

Recommended fix: Validate Origin and Fetch Metadata headers for state-changing operations. Require authentication or a CSRF-resistant token, including for local-only deployments.

7. Medium-High: Remote-access authentication depends on a request header

Affected files:

The remote HTTPS proxy injects:

X-Claw2-Via: remote-https

The gateway checks the companion access token only when this header indicates that the request arrived through remote HTTPS.

Otherwise, checkCompanionAccess() returns success.

This creates a deployment-dependent authentication boundary.

If an attacker can reach the underlying gateway HTTP listener directly, without passing through the intended HTTPS proxy, the companion access-token check will not apply.

The separate gateway API key can still protect the service when enabled.

The official HTTPS proxy overwrites the header, so merely spoofing this header through that proxy is not a demonstrated bypass.

Recommended fix: Ensure the backend cannot be reached independently of the trusted proxy. Prefer authentication determined by the listener or a verified proxy connection, rather than a request header alone.

8. Medium: JWTs are not revoked when account state changes

Affected files:

The JWT implementation uses a seven-day default expiration.

The repository's database schema supports account statuses:

'active', 'pending', 'suspended'

However, the login handler validates the password without checking whether the account is active.

The general token-verification function checks the JWT but does not subsequently verify the current account status.

Additionally:

  • The logout endpoint does not revoke the server-side token.
  • Changing a password does not invalidate existing tokens.
  • The inspected login handler has no dedicated rate limiting.

A stolen valid token can therefore remain usable until expiration, even after the account password changes.

Recommended fix: Enforce account status during login and authorization, introduce revocable sessions or token versions, and add rate limiting for authentication endpoints.

9. Medium: Unbounded or excessive request-body allocation

Affected files:

The LLM-room request-body parser buffers incoming chunks without checking a maximum total length.

The main gateway also permits chat bodies up to 512 MiB.

These sizes are excessive for ordinary chat messages and can become problematic when requests are processed concurrently.

A malicious or malfunctioning client could use large requests to exhaust process memory.

Recommended fix: Enforce small, endpoint-specific request limits and reject oversized requests while streaming, rather than after buffering.

10. Medium: Outbound fetch size limit is checked too late

Affected file: src/tools/web-fetch.ts, lines 84-92

The web_fetch tool contains:

const buf = await res.arrayBuffer();

if (buf.byteLength > maxBytes) {
  return {
    ok: false,
    error: "response too large"
  };
}

The entire HTTP response is downloaded into memory before the size restriction is enforced.

An attacker controlling a remote response may be able to exhaust gateway memory by returning a very large body.

Recommended fix: Stream the response with a running byte counter. Abort as soon as the configured limit is exceeded.


Can Docker actually be bypassed?

There are three different scenarios.

Scenario Assessment
Escape from a standard, restricted skill container directly into the host Not demonstrated
Escape the intended filesystem boundary by making the gateway follow attacker-controlled symlinks Potentially possible; code weakness identified
Gain host control after compromising the gateway and using its Docker API proxy High-risk path identified
Disable Docker skill isolation using editable configuration Possible for authorized configuration writers, including regular users in the inspected multi-user design

The repository contains legitimate Docker hardening measures:

--cap-drop=ALL
--security-opt=no-new-privileges
--read-only
--pids-limit
--memory
--tmpfs /tmp:rw,noexec,nosuid

Skills also use a dedicated internal Docker network, while the Docker API proxy is connected to the gateway's control network.

These protections materially reduce the attack surface.

However, the most consequential isolation boundary is not necessarily the Docker kernel. It is the boundary between untrusted skill execution, the gateway process, and the gateway's authority to create Docker containers.

The observed architecture exposes several ways that boundary can be weakened.

What I would fix first

Priority Change Reason
P0 Restrict Docker API access with validated container creation Prevent gateway compromise from becoming host compromise
P0 Remove arbitrary user overrides of security configuration Prevent ordinary users from disabling isolation
P0 Require JWT authorization on POST /chat Close the authentication exception
P0 Require administrator authorization for /allow Protect skill execution approvals
P1 Fix symlink traversal in filesystem tools and file serving Prevent the gateway from accessing files outside permitted roots
P1 Validate origins for state-changing requests Reduce browser-based attacks on local services
P1 Harden remote-access authentication boundaries Prevent bypass through alternative entry points
P2 Add account-status checks, JWT revocation, and login limits Improve account security
P2 Enforce streaming request and response size limits Reduce denial-of-service exposure

Final assessment

I would not currently recommend deploying claw2 as an Internet-accessible multi-user service without addressing the authentication, configuration isolation, and Docker API proxy issues.

For a single-user installation on an isolated machine, with the gateway API key enabled and the service exposed only on loopback, the risk is substantially lower.

The two most important findings are the JWT authorization exception on POST /chat and the ability of the gateway to request Docker container creation through a broadly permitted API proxy. The unrestricted per-user configuration merge is an additional serious concern for shared deployments.

There is no verified proof of a direct kernel-level Docker container escape in this review. The stronger concern is an application-level path across privilege boundaries that could defeat the intended isolation.

Reviewed repository revision: 6d91887e6ab168e0c28fd2edee13e6d25d543e8d, November 21, 2026. Findings are based on static source inspection; exploitability and severity would benefit from controlled integration tests against this exact revision.