Skip to content

ContainerCodeExecutor docs say non-root, but the container runs as the image's default user (root for python:3.11-slim) #7712

Open

Description

@EmanueleCell4

The code executor guide says:
"ContainerCodeExecutor starts a Docker container as a non-root user, with the network off and Linux capabilities dropped."

`ContainerCodeExecutor` starts a Docker container as a non-root user, with the
network off and Linux capabilities dropped. If you are moving off
`UnsafeLocalCodeExecutor`, this is the shortest step that puts a real boundary

The network and capability hardening is there, but containers.run doesn't set user=, and neither do the exec_run calls:

self._container = self._client.containers.run(
image=self.image,
detach=True,
tty=True,
# Harden the sandbox for untrusted, model-generated code: no network
# (blocks metadata/SSRF/exfil), drop all Linux capabilities, and
# forbid privilege escalation. Networking can be re-enabled via
# `network_enabled=True` when the executed code is trusted.
network_disabled=not self.network_enabled,
cap_drop=['ALL'],
security_opt=['no-new-privileges'],
)

So the model's code runs as whatever user the image defaults to. For the image in the doc's own example (python:3.11-slim) that's root:

#6074 added the network and capability hardening; the user part seems to be the piece that didn't land. Maybe it's just the docs, but since this is described as the step that "puts a real boundary" between model code and the host, passing e.g. user="65534:65534" (or making it configurable) seems like the better fix than editing the sentence.

Found while testing a docs-vs-code checker I'm building (Elliot), then verified by hand.

Activity

  1. Samecho commented on Oct 24, 2026

    @Samecho
    Contributor

    May I send a small guide correction so it no longer promises a non-root user? The container and exec calls leave user unset, so the guide should describe the image's configured user. I would leave runtime user selection separate, since forcing a UID could affect custom images.

  2. EmanueleCell4 commented on Oct 24, 2026

    @EmanueleCell4
    Author
  3. added 2 commits that reference this issue on Oct 24, 2026
    da7cc8e
    5dc64f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions