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

Closed

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
    ContributorAuthor
  3. added 2 commits that reference this issue on Oct 24, 2026
    da7cc8e
    5dc64f8
  4. Samecho commented on Oct 25, 2026

    @Samecho
    Contributor

    I opened #7713 before your reply came through, so both PRs now cover the same paragraph. Sorry for the crossed wires. Would you prefer to continue with #7714? I want to avoid asking the team to review the same correction twice.

  5. EmanueleCell4 commented on Oct 25, 2026

    @EmanueleCell4
    ContributorAuthor
  6. Samecho commented on Oct 26, 2026

    @Samecho
    Contributor

    Thanks, let's continue with #7714. I've closed #7713 so there's only one PR to review. I would appreciate the co-author credit. Please use Co-authored-by: samecho <zhayutong@gmail.com>.

  7. added
    agent engine[Component] This issue is related to Vertex AI Agent Engine
    core[Component] This issue is related to the core interface and implementation
    and removed
    agent engine[Component] This issue is related to Vertex AI Agent Engine
    on Oct 26, 2026
  8. added a commit that references this issue on Oct 26, 2026
    f32580f
  9. EmanueleCell4 commented on Oct 26, 2026

    @EmanueleCell4
    ContributorAuthor

    Done, added you as co-author on #7714. Thanks!

  10. sanketpatil06 commented on Oct 27, 2026

    @sanketpatil06

    Thanks, @EmanueleCell4 and @Samecho, for working this out together and combining it into one PR. We'll take #7714 forward and the team will review it shortly. If changes are needed, we'll leave feedback on the PR.

  11. added a commit that references this issue on Oct 27, 2026
    7a64c7c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementation

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions