Repository navigation
feat(security): devops k8s audit runs Popeye in the tool sandbox with a kube-api network profile that only reads the API server - #2467
Merged
Conversation
Owner
Author
Test resultsAfter the rebase onto
Fail-to-pass
Full output of devops ci fail-to-pass |
dan-petty
marked this pull request as ready for review
October 28, 2026 17:27
… the sandbox Plans #2132: Popeye runs in the tool sandbox, and reaches only the API server of one context through kubectl proxy and a socat relay.
…and the record names the network A ToolRequest selects the network profile kube-api with network=KubeApiNetwork(context=...). The request refuses the profile for a tool other than popeye, and for a request that names a program. BaseSecurityScanner.tool_network selects no network, and PopeyeScanner.tool_network selects kube-api for the context of its scan. DirectToolExecutor refuses a request that selects a profile, because a child process has the whole network of the host. The record of each run (ToolRun) names the network of the tool: host for the direct executor, none for the sandbox, and kube-api for the profile. Refs #2132
… through kubectl proxy and socat bubblewrap can only keep the whole network of the host or give a sandbox no network, and the allow-lists of the sandbox apply only to containers. So a request that selects the network profile kube-api runs as one command through run_subprocess: - Outside the sandbox, a shell starts kubectl proxy on a Unix socket in a scratch directory, for the context of the request, under setpriv --pdeathsig KILL. The proxy refuses the methods POST, PUT, PATCH and DELETE, and the exec, attach, port-forward and proxy paths. - bubblewrap keeps --unshare-all and binds the scratch directory read-only. In the sandbox, socat relays 127.0.0.1:8001 to the socket, and the tool starts under prlimit with KUBECONFIG set to a kubeconfig that names the relay, the context and its namespace, and no credentials. kubectl config view --minify reads the context and its namespace from the kubeconfig of the user, as the proxy reads it. A context that the kubeconfig does not have stops the run before the proxy starts. A host without sh, socat, kubectl or setpriv runs no kube-api request, and the cause names the program. The sandbox binds /etc/passwd read-only for Popeye, which stops at start when it cannot find the user. Refs #2132
…api profile and fails when Popeye did not run PopeyeScanner runs in SandboxToolExecutor when it gets no executor. So devops k8s audit, the agent tool scan_popeye and the scanner registry run Popeye in the sandbox with the network profile kube-api. A host that cannot start the sandbox runs no Popeye scan, and the scan reports a coverage gap with the cause. run_popeye_scan takes no workdir. Popeye starts in a new empty directory, because the sandbox shows the tool the directory that a scan starts in, and Popeye needs no file there. Before, a run from the home directory showed the home directory to Popeye. devops k8s audit says that the audit did not run, with the status and the reason, and exits 1, when Popeye did not run. Before, it read only the list of findings and reported a pass. Refs #2132
… of a tool run, and install socat in the devcontainer SECURITY.md describes the network profile kube-api: only Popeye selects it, kubectl proxy outside the sandbox refuses the methods that write and the paths past the API server, socat relays the loopback port in the sandbox, and the limits of the deny list. It names the network field of the record and the scanners that still use the direct executor. docs/SELF_IMPROVEMENT.md names the network field of tool_runs. The devcontainer image installs socat, which a kube-api run needs, and docs/DEVCONTAINER_USAGE.md says why. Refs #2132
…name no namespace in the kubeconfig of the sandbox #2436 gives Popeye -A when a scan names no namespace. The k8s audit test now expects that command. Every Popeye command names its scope with -A or -n, so the kubeconfig of the sandbox no longer copies the namespace of the context. The OpenSpec change and the docstring of run_popeye_scan say that a scan with no namespace covers every namespace.
… the host and refuses a network profile, as the direct executor does The direct executor recorded the network host and refused a network profile, but ToolExecutorFake(require_commit=False, require_files=False) recorded none and refused nothing. The refusal is now in record_tool_run, which every executor and the fake call. The fake takes network, and the contract suite holds the direct executor and its fake to the same network and the same refusal. docs/TESTING.md says that a Popeye scan with no executor runs in the sandbox, and what ScannerFake records.
… only to a request that selects the kube-api profile SandboxToolExecutor.command wrapped any request in the relay that it got, so a caller that held a relay could give a tool other than Popeye the API server. It now refuses a relay for a request that selects no network profile, and a kube-api request with no relay.
…l paths and methods The test compared the rejected methods and paths with copies of their values, so a typo in both passed. It now takes the filters from the command that the run gives kubectl proxy, and holds them to the paths and methods that kubectl proxy v1.37.1 refused and let through.
…o SARIF name, and record the review fixes in the OpenSpec change The docstring of the tool executor names network next to executor as a field with no SARIF name. Task 2.1 names the parametrized test that holds the context of the request, and section 5 records the fixes after the review. The design says that a profile.json from before the change does not load, because devops-cli keeps no backward compatibility before 1.0.0.
The archive moves the change to openspec/changes/archive/2026-10-28-2132-popeye-kube-api-sandbox/ and merges its deltas into the agent-scan-tools, review-tool-runs and review-tool-sandbox specs. It adds the k8s-audit spec.
dan-petty
force-pushed
the
feat/2132-popeye-kube-api-sandbox
branch
from
October 28, 2026 17:31
a07d875 to
c0d204c
Compare
dan-petty
pushed a commit
that referenced
this pull request
Oct 28, 2026
🤖 I have created a release *beep* *boop* --- ## [0.10.0](v0.9.0...v0.10.0) (2026-10-28) ### Features * **review:** devops review intake hands the findings of a session on merged code to roadmap intake ([#2455](#2455)) ([a5c7b82](a5c7b82)) * **security:** devops k8s audit runs Popeye in the tool sandbox with a kube-api network profile that only reads the API server ([#2467](#2467)) ([e02c3fb](e02c3fb)) * **security:** the App's installation tokens carry only the permissions the roadmap jobs use ([#2482](#2482)) ([9599ef2](9599ef2)), closes [#2473](#2473) ### Bug Fixes * **config:** a config file that is not valid YAML stops the load with an error that quotes none of its text ([#2468](#2468)) ([91fe5dc](91fe5dc)) * **config:** config set reports an unknown key as unknown, not as a key that needs a value ([#2465](#2465)) ([8b650a6](8b650a6)) * **devcontainer:** run the checkout's devops in devcontainer terminals ([#2460](#2460)) ([abd2d41](abd2d41)) * **k8s:** loki runs from the grafana-community chart on loki 3.7.9, out of reach of CVE-2026-21729 ([#2470](#2470)) ([96c50c9](96c50c9)) * **security:** a credential keyword at the end of a line no longer masks the first word of the next line ([#2461](#2461)) ([b754a73](b754a73)) * **security:** a credential value is masked also when the next line starts with a parenthesis ([#2477](#2477)) ([ece25ca](ece25ca)), closes [#2471](#2471) * **security:** pin kubeconform and replace Checkov with Trivy's misconfiguration scan ([#2464](#2464)) ([960e357](960e357)) * **security:** refuse GCONV_PATH, SHELLOPTS, BASHOPTS and PS4 from a caller, and archive the merged security changes ([#2453](#2453)) ([1f9231d](1f9231d)) ### Code Refactoring * **ai:** chat_structured is the one structured-output path ([#2452](#2452)) ([3509732](3509732)) * **github:** pr check-readiness reads one merge-readiness verdict from github/ ([#2456](#2456)) ([16442c4](16442c4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.
devops k8s audit, the agent toolscan_popeyeand the scanner registry ran Popeye with no sandbox. Popeye ran as a child process of devops-cli, with the environment, the files and the full network of the user. This change runs Popeye in the tool sandbox with one network profile,kube-api, that reaches only the Kubernetes API server, and only to read.kube-api. AToolRequestselects it withnetwork=KubeApiNetwork(context=...). The request refuses the profile for a tool other thanpopeyeand for a request that names aprogram. OnlyPopeyeScannerselects the profile.DirectToolExecutorrefuses a request that selects a network profile, andSandboxToolExecutor.commandrefuses a relay for a request that selects no profile.SandboxToolExecutorruns akube-apirequest through a relay. Outside the sandbox,kubectl proxylistens on a Unix socket in the scratch directory, with the kubeconfig and the credentials of the user. It refuses the methods POST, PUT, PATCH and DELETE, and the exec, attach, port-forward and proxy paths. In the sandbox, bubblewrap keeps--unshare-all, andsocatrelays127.0.0.1:8001to the socket. Popeye reads a kubeconfig that has no credentials and that names only that port and the context. A host withoutsh,socat,kubectlorsetprivruns nokube-apirequest, and the error names the program.ToolRun) names its network:host,noneorkube-api.PopeyeScannerruns inSandboxToolExecutorwhen it gets no executor.run_popeye_scantakes noworkdir: Popeye starts in a new empty directory, so the sandbox shows Popeye no tree of the user. The sandbox binds/etc/passwdread-only for Popeye, because Popeye stops at start when it cannot find the user.devops k8s auditsays that the audit did not run, and exits 1, when Popeye did not run. It reports a pass only when Popeye ran and found nothing.socat.SECURITY.md,docs/SELF_IMPROVEMENT.md,docs/DEVCONTAINER_USAGE.mdanddocs/TESTING.mddescribe the profile and thenetworkfield of the record.This is decision 2 of the tracker #772.
Closes #2132
Change:
openspec/changes/archive/2026-10-28-2132-popeye-kube-api-sandbox/