fix: Port code executor container and pod isolation defaults to v1 - #6807
Open
GWeale wants to merge 2 commits into
Open
fix: Port code executor container and pod isolation defaults to v1#6807GWeale wants to merge 2 commits into
GWeale wants to merge 2 commits into
Conversation
Ports upstream commit 8207880 to the v1 branch. The pod that GkeCodeExecutor creates to run model-generated code did not set automount_service_account_token, and Kubernetes defaults it to true, so the pod received a token for the namespace's default ServiceAccount. Code executed in the sandbox could use it to call the cluster's API server. The pod spec now sets automount_service_account_token=False, so no token is projected into the pod. Behaviour change: executed code that today calls the Kubernetes API from inside the cluster loses that access. Nothing in ADK does this.
Ports upstream commit 0a9ce0f to the v1 branch. ContainerCodeExecutor started its container with default Docker networking and no capability restrictions, so the model-generated code it runs could reach the network, acquire Linux capabilities, and gain privileges through setuid binaries. Every other ADK code executor is isolated: GkeCodeExecutor runs under gVisor with all capabilities dropped, and the Vertex AI and Agent Engine executors run in managed server-side sandboxes. The container now starts with networking disabled, all Linux capabilities dropped, and no-new-privileges set. A new network_enabled field re-enables networking when the executed code is trusted. Breaking change: executed code no longer has network access by default, so anything that makes an HTTP request, resolves DNS, or installs a package fails until the executor is constructed as ContainerCodeExecutor(..., network_enabled=True). Dropping capabilities and setting no-new-privileges do not affect ordinary Python execution. Also adds docker>=7 to the test extra so that extra installs on its own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR ports two code executor fixes to the
v1branch:Container run settings (
0a9ce0f6)ContainerCodeExecutorruns its container with networking disabled, so executed code that makes an HTTP request, resolves DNS, or installs a package fails.ContainerCodeExecutor(image="...", network_enabled=True).cap_drop=['ALL']and theno-new-privilegesoption.docker>=7to thetestextra.Pod spec settings (
82078801)GkeCodeExecutorcreates setsautomount_service_account_token=False, so executed code has no in-cluster Kubernetes API access.