Skip to content

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
dan-petty merged 12 commits into
mainfrom
feat/2132-popeye-kube-api-sandbox
Oct 28, 2026
Merged

dan-petty merged 12 commits into
mainfrom
feat/2132-popeye-kube-api-sandbox

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops k8s audit, the agent tool scan_popeye and 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.

  • The tool sandbox has one network profile, kube-api. A ToolRequest selects it with network=KubeApiNetwork(context=...). The request refuses the profile for a tool other than popeye and for a request that names a program. Only PopeyeScanner selects the profile. DirectToolExecutor refuses a request that selects a network profile, and SandboxToolExecutor.command refuses a relay for a request that selects no profile.
  • SandboxToolExecutor runs a kube-api request through a relay. Outside the sandbox, kubectl proxy listens 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, and socat relays 127.0.0.1:8001 to the socket. Popeye reads a kubeconfig that has no credentials and that names only that port and the context. A host without sh, socat, kubectl or setpriv runs no kube-api request, and the error names the program.
  • The record of each tool run (ToolRun) names its network: host, none or kube-api.
  • PopeyeScanner runs in SandboxToolExecutor when it gets no executor. run_popeye_scan takes no workdir: Popeye starts in a new empty directory, so the sandbox shows Popeye no tree of the user. The sandbox binds /etc/passwd read-only for Popeye, because Popeye stops at start when it cannot find the user.
  • devops k8s audit says 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.
  • The devcontainer image installs socat. SECURITY.md, docs/SELF_IMPROVEMENT.md, docs/DEVCONTAINER_USAGE.md and docs/TESTING.md describe the profile and the network field 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/

@dan-petty dan-petty added scope/k8s Kubernetes commands, Helm charts, pods, services, and policies scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 28, 2026
@dan-petty

dan-petty commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner Author

Test results

After the rebase onto origin/main (960e3573), the targeted tests pass. The run includes the scanner and k8s tests that main changed:

uv run devops ci test tests/security/test_kube_api_network_profile.py tests/test_tool_executor_contract.py tests/test_security_sarif.py tests/test_review_tool_runs.py tests/test_sandbox_tool_executor.py tests/commands/test_k8s_audit.py tests/test_secops.py tests/test_builtin_tools.py tests/test_k8s.py tests/test_scan_outcomes_and_gating.py tests/test_scanner_contract.py tests/test_subprocess_env_boundary.py tests/test_architectural_invariants.py tests/test_consolidation_security_scanner_base.py tests/test_suite_refuses_real_programs.py tests/test_scan.py tests/commands/test_k8s_validate.py tests/test_security_kubeconform.py tests/invariants/test_source_tree.py
868 passed in 54.67s

uv run devops openspec check passed, and uv run devops docs generate --sync-readme changed no file. The pre-push hook (devops ci, fast static checks) passed.

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main exited 0. On the base, the four changed test modules fail to collect, and six test_security_sarif record tests fail on the missing network field. All of these tests pass on the branch. The lines that did not pass on the base:

ℹ Quality gate root: /workspaces/devops-cli/.data/agent/worktrees/w-2132
  errored on base: tests.commands.test_k8s_audit (collection failure)
  errored on base: tests.security.test_kube_api_network_profile (collection failure)
  errored on base: tests.test_builtin_tools (collection failure)
  errored on base: tests.test_secops (collection failure)
  failed on base: tests.test_security_sarif::test_the_driver_names_the_version_of_its_records_when_no_result_names_one[8.20.0-record_versions1-8.20.0] (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  failed on base: tests.test_security_sarif::test_a_tool_with_records_and_no_result_gets_no_run (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  failed on base: tests.test_security_sarif::test_the_driver_names_the_version_of_its_records_when_no_result_names_one[None-record_versions0-8.21.2] (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  failed on base: tests.test_security_sarif::test_the_run_of_a_scanner_that_ran_holds_its_records_beside_its_invocation (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  failed on base: tests.test_security_sarif::test_the_driver_names_the_version_of_its_records_when_no_result_names_one[None-record_versions2-None] (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  failed on base: tests.test_security_sarif::test_the_run_of_a_tool_holds_each_record_of_that_tool_in_its_property_bag (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
6 failed on base (6 failed and 267 passed in tests/commands/test_k8s_audit.py, tests/security/test_kube_api_network_profile.py, tests/test_builtin_tools.py, tests/test_k8s.py, tests/test_secops.py, tests/test_security_sarif.py; 4 errored).
Elapsed: 42s
Full output of devops ci fail-to-pass
ℹ Quality gate root: /workspaces/devops-cli/.data/agent/worktrees/w-2132
  errored on base: tests.commands.test_k8s_audit (collection failure)
  errored on base: tests.security.test_kube_api_network_profile (collection failure)
  errored on base: tests.test_builtin_tools (collection failure)
  errored on base: tests.test_secops (collection failure)
  passed on base: tests.test_security_sarif::test_a_missing_policy_file_is_an_error
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[/abs/path/file.py:7-expected5]
  passed on base: tests.test_security_sarif::test_an_unnamed_driver_does_not_lose_the_run
  passed on base: tests.test_security_sarif::test_a_third_party_document_is_ingested_without_a_bespoke_parser
  passed on base: tests.test_security_sarif::test_a_non_numeric_security_severity_falls_back_to_the_level
  passed on base: tests.test_security_sarif::test_swapping_parts_or_changing_separator_or_canonicalisation_alters_fingerprint
  passed on base: tests.test_security_sarif::test_malformed_locations_never_raise[non-positive start line-locations6]
  passed on base: tests.test_security_sarif::test_every_emitted_level_is_one_sarif_defines
  passed on base: tests.test_security_sarif::test_a_rule_prefix_is_stripped_from_the_displayed_message
  passed on base: tests.test_security_sarif::test_a_driver_with_a_blank_name_falls_back
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[-expected2]
  passed on base: tests.test_security_sarif::test_a_report_deduplicates_and_correlates_scanner_output
  passed on base: tests.test_security_sarif::test_an_empty_policy_file_suppresses_nothing
  passed on base: tests.test_security_sarif::test_a_numeric_security_severity_outranks_the_coarser_level
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[  high  -HIGH]
  passed on base: tests.test_security_sarif::test_a_document_that_is_not_sarif_is_rejected[unsupported version-document2]
  passed on base: tests.test_security_sarif::test_a_cluster_reports_the_most_severe_assessment_any_tool_made
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[minor-LOW]
  passed on base: tests.test_security_sarif::test_a_document_round_trips_through_emission_and_ingestion
  passed on base: tests.test_security_sarif::test_a_scanner_that_ran_gets_a_run_even_with_no_results
  passed on base: tests.test_security_sarif::test_the_gate_threshold_is_inclusive[HIGH-HIGH-True]
  passed on base: tests.test_security_sarif::test_deduplication_keeps_genuinely_distinct_findings
  passed on base: tests.test_security_sarif::test_a_report_identifies_its_most_severe_finding
  passed on base: tests.test_security_sarif::test_local_rules_are_matched_before_inherited_ones
  passed on base: tests.test_security_sarif::test_results_reference_their_rule_by_index_and_id
  passed on base: tests.test_security_sarif::test_a_suppression_expiring_today_is_still_in_force
  passed on base: tests.test_security_sarif::test_clustering_does_not_merge_findings_into_one
  passed on base: tests.test_security_sarif::test_the_sarif_command_rejects_a_document_that_is_not_sarif
  failed on base: tests.test_security_sarif::test_the_driver_names_the_version_of_its_records_when_no_result_names_one[8.20.0-record_versions1-8.20.0] (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[src/app.py-expected1]
  passed on base: tests.test_security_sarif::test_a_tool_glob_scopes_a_suppression
  passed on base: tests.test_security_sarif::test_a_normalized_finding_converts_back_for_the_existing_renderers
  passed on base: tests.test_security_sarif::test_a_minimum_severity_filters_the_report
  passed on base: tests.test_security_sarif::test_a_document_that_is_not_sarif_is_rejected[missing runs-document3]
  passed on base: tests.test_security_sarif::test_paths_are_normalized_without_mangling_leading_dots[.github/workflows/ci.yml-.github/workflows/ci.yml]
  passed on base: tests.test_security_sarif::test_a_fingerprint_suppression_matches_exactly_one_finding
  passed on base: tests.test_security_sarif::test_an_empty_report_never_trips_the_gate
  passed on base: tests.test_security_sarif::test_an_unreadable_suppression_policy_stops_the_scan
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[:1-expected6]
  passed on base: tests.test_security_sarif::test_malformed_locations_never_raise[not a list-locations0]
  passed on base: tests.test_security_sarif::test_security_severity_scores_band_as_github_documents[7.0-HIGH]
  failed on base: tests.test_security_sarif::test_a_tool_with_records_and_no_result_gets_no_run (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  passed on base: tests.test_security_sarif::test_a_result_with_no_message_falls_back_to_its_rule_id
  passed on base: tests.test_security_sarif::test_an_unparseable_expiry_is_treated_as_expired
  passed on base: tests.test_security_sarif::test_a_gating_finding_keeps_its_security_severity_beside_outcomes
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[src/app.py:0-expected8]
  passed on base: tests.test_security_sarif::test_built_in_pattern_findings_never_carry_the_real_tools_driver_name
  passed on base: tests.test_security_sarif::test_a_fingerprint_distinguishes_two_objects_with_one_message
  passed on base: tests.test_security_sarif::test_fingerprints_survive_a_round_trip
  failed on base: tests.test_security_sarif::test_the_driver_names_the_version_of_its_records_when_no_result_names_one[None-record_versions0-8.21.2] (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  passed on base: tests.test_security_sarif::test_a_non_identifier_bracketed_prefix_is_not_taken_as_a_rule
  passed on base: tests.test_security_sarif::test_an_empty_report_has_no_highest_severity
  passed on base: tests.test_security_sarif::test_an_empty_logical_location_name_is_ignored
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[src/views.py:40-45-expected7]
  passed on base: tests.test_security_sarif::test_a_normalized_finding_serializes_with_its_fingerprint
  passed on base: tests.test_security_sarif::test_a_symbolic_locator_is_emitted_as_a_logical_location
  passed on base: tests.test_security_sarif::test_different_messages_get_different_derived_identifiers
  passed on base: tests.test_security_sarif::test_the_sarif_command_ingests_a_document
  passed on base: tests.test_security_sarif::test_security_severity_scores_band_as_github_documents[4.0-MEDIUM]
  passed on base: tests.test_security_sarif::test_a_run_whose_results_are_not_a_list_is_skipped
  passed on base: tests.test_security_sarif::test_a_clusters_representative_is_its_most_severe_finding
  passed on base: tests.test_security_sarif::test_a_fingerprint_distinguishes_the_same_rule_reported_by_two_tools
  passed on base: tests.test_security_sarif::test_sarif_fingerprint_key_pinned
  passed on base: tests.test_security_sarif::test_a_policy_extending_several_baselines_collects_all_of_them
  passed on base: tests.test_security_sarif::test_a_plain_string_message_is_read
  passed on base: tests.test_security_sarif::test_a_finding_without_a_symbol_keeps_its_fingerprint
  passed on base: tests.test_security_sarif::test_a_policy_inherits_rules_from_the_baseline_it_extends
  passed on base: tests.test_security_sarif::test_a_fingerprint_ignores_whitespace_differences_in_the_message
  passed on base: tests.test_security_sarif::test_the_sarif_command_applies_a_suppression_policy
  passed on base: tests.test_security_sarif::test_two_popeye_issues_on_two_resources_of_one_sanitizer_are_kept
  passed on base: tests.test_security_sarif::test_the_report_command_passes_when_nothing_meets_the_gate
  passed on base: tests.test_security_sarif::test_a_fingerprint_distinguishes_different_rules_in_one_file
  passed on base: tests.test_security_sarif::test_a_result_carries_a_versioned_fingerprint
  passed on base: tests.test_security_sarif::test_security_severity_scores_band_as_github_documents[9.0-CRITICAL]
  passed on base: tests.test_security_sarif::test_a_suppressions_key_that_is_not_a_list_is_rejected
  passed on base: tests.test_security_sarif::test_a_document_that_is_not_sarif_is_rejected[runs not a list-document4]
  passed on base: tests.test_security_sarif::test_findings_on_different_objects_do_not_cluster
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[warning-MEDIUM]
  passed on base: tests.test_security_sarif::test_a_malformed_result_is_skipped_rather_than_failing_the_document
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[error-HIGH]
  passed on base: tests.test_security_sarif::test_a_non_positive_line_emits_no_region
  passed on base: tests.test_security_sarif::test_a_document_is_written_to_disk_as_json
  passed on base: tests.test_security_sarif::test_an_absolute_path_is_made_relative_to_the_scan_root
  passed on base: tests.test_security_sarif::test_reading_a_written_document_recovers_its_findings
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[manifests/deploy.yml:Deployment/api-expected3]
  passed on base: tests.test_security_sarif::test_paths_are_normalized_without_mangling_leading_dots[src/app.py-src/app.py]
  passed on base: tests.test_security_sarif::test_a_severity_declared_on_the_result_is_honoured
  passed on base: tests.test_security_sarif::test_registry_results_are_flattened_with_their_tool_names
  passed on base: tests.test_security_sarif::test_a_rule_without_a_fingerprint_matches_by_pattern
  passed on base: tests.test_security_sarif::test_a_cyclic_inheritance_chain_terminates
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[HIGH-HIGH]
  passed on base: tests.test_security_sarif::test_malformed_locations_never_raise[empty list-locations1]
  passed on base: tests.test_security_sarif::test_the_report_command_rejects_an_unknown_scanner
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[informational-INFO]
  passed on base: tests.test_security_sarif::test_an_expired_suppression_stops_suppressing
  passed on base: tests.test_security_sarif::test_every_emitted_document_conforms_to_the_sarif_schema[document0]
  passed on base: tests.test_security_sarif::test_the_report_command_writes_sarif
  passed on base: tests.test_security_sarif::test_a_path_glob_scopes_a_suppression
  passed on base: tests.test_security_sarif::test_every_emitted_document_conforms_to_the_sarif_schema[document1]
  passed on base: tests.test_security_sarif::test_a_rule_carries_the_security_severity_github_ranks_by
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[unknown-INFO]
  passed on base: tests.test_security_sarif::test_reading_a_file_that_is_not_json_reports_the_file
  passed on base: tests.test_security_sarif::test_findings_at_different_lines_do_not_cluster
  passed on base: tests.test_security_sarif::test_deduplication_preserves_the_first_occurrence
  passed on base: tests.test_security_sarif::test_each_tool_gets_its_own_run
  passed on base: tests.test_security_sarif::test_invalid_yaml_reports_the_file
  passed on base: tests.test_security_sarif::test_a_multi_line_result_keeps_its_fingerprint_when_it_moves
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[CRITICAL-CRITICAL]
  passed on base: tests.test_security_sarif::test_a_run_with_no_results_contributes_nothing
  passed on base: tests.test_security_sarif::test_a_report_can_be_built_from_ingested_sarif
  passed on base: tests.test_security_sarif::test_a_repeated_rule_is_declared_once_and_referenced_twice
  passed on base: tests.test_security_sarif::test_a_bracketed_rule_prefix_is_recovered_from_the_title
  passed on base: tests.test_security_sarif::test_an_empty_policy_object_suppresses_nothing
  passed on base: tests.test_security_sarif::test_findings_from_different_tools_at_one_location_form_a_cluster
  passed on base: tests.test_security_sarif::test_a_windows_style_drive_letter_does_not_become_a_line_number
  passed on base: tests.test_security_sarif::test_an_empty_scan_still_produces_a_valid_document
  passed on base: tests.test_security_sarif::test_a_parent_is_resolved_relative_to_the_file_that_names_it
  passed on base: tests.test_security_sarif::test_a_baseline_reached_twice_is_loaded_once
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[critical-CRITICAL]
  passed on base: tests.test_security_sarif::test_a_failing_scanner_does_not_discard_the_others
  passed on base: tests.test_security_sarif::test_an_unrecognised_severity_is_not_silently_demoted
  passed on base: tests.test_security_sarif::test_an_absolute_path_outside_the_scan_root_is_left_alone
  passed on base: tests.test_security_sarif::test_security_severity_scores_band_as_github_documents[0.0-INFO]
  passed on base: tests.test_security_sarif::test_malformed_locations_never_raise[first entry not an object-locations2]
  passed on base: tests.test_security_sarif::test_a_report_serializes_for_json_consumers
  passed on base: tests.test_security_sarif::test_a_rule_resolved_only_by_index_is_still_found
  passed on base: tests.test_security_sarif::test_every_emitted_document_conforms_to_the_sarif_schema[document2]
  passed on base: tests.test_security_sarif::test_paths_are_normalized_without_mangling_leading_dots[./src/app.py-src/app.py]
  passed on base: tests.test_security_sarif::test_severity_ranking_orders_most_severe_first
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[BLOCKER-CRITICAL]
  passed on base: tests.test_security_sarif::test_the_report_command_fails_the_build_on_a_severe_finding
  passed on base: tests.test_security_sarif::test_a_non_gating_finding_is_a_recommendation_without_a_security_severity
  passed on base: tests.test_security_sarif::test_the_gate_threshold_is_inclusive[CRITICAL-HIGH-True]
  passed on base: tests.test_security_sarif::test_clusters_are_ranked_by_severity_then_corroboration
  passed on base: tests.test_security_sarif::test_security_severity_scores_band_as_github_documents[0.5-LOW]
  passed on base: tests.test_security_sarif::test_the_gate_threshold_is_inclusive[MEDIUM-HIGH-False]
  passed on base: tests.test_security_sarif::test_a_fingerprint_survives_the_finding_moving_to_a_new_line
  passed on base: tests.test_security_sarif::test_rules_that_are_not_a_list_are_ignored
  failed on base: tests.test_security_sarif::test_the_run_of_a_scanner_that_ran_holds_its_records_beside_its_invocation (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  failed on base: tests.test_security_sarif::test_the_driver_names_the_version_of_its_records_when_no_result_names_one[None-record_versions2-None] (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  passed on base: tests.test_security_sarif::test_an_unrecognised_level_falls_back_to_the_specified_default
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[src/app.py:42-expected0]
  passed on base: tests.test_security_sarif::test_an_out_of_range_rule_index_does_not_raise
  passed on base: tests.test_security_sarif::test_a_document_that_is_not_sarif_is_rejected[missing version-document1]
  passed on base: tests.test_security_sarif::test_a_run_that_is_not_an_object_is_skipped
  passed on base: tests.test_security_sarif::test_a_result_with_no_level_defaults_as_the_specification_says
  passed on base: tests.test_security_sarif::test_expired_rules_are_reported_for_review
  passed on base: tests.test_security_sarif::test_malformed_locations_never_raise[region without a start line-locations5]
  passed on base: tests.test_security_sarif::test_a_symbolic_locator_survives_the_round_trip
  passed on base: tests.test_security_sarif::test_a_derived_identifier_is_stable_across_cosmetic_differences
  passed on base: tests.test_security_sarif::test_a_non_mapping_rule_entry_is_ignored
  passed on base: tests.test_security_sarif::test_a_finding_with_no_title_falls_back_to_its_description
  passed on base: tests.test_security_sarif::test_the_gate_threshold_is_inclusive[INFO-INFO-True]
  passed on base: tests.test_security_sarif::test_golden_sarif_report_matches_and_validates_against_schema
  passed on base: tests.test_security_sarif::test_a_result_with_no_rule_id_at_all_still_gets_one
  passed on base: tests.test_security_sarif::test_suppression_is_applied_before_deduplication
  passed on base: tests.test_security_sarif::test_a_document_that_is_not_sarif_is_rejected[not an object-document0]
  passed on base: tests.test_security_sarif::test_the_report_command_renders_correlated_findings
  passed on base: tests.test_security_sarif::test_the_report_command_records_why_scanners_did_not_run
  passed on base: tests.test_security_sarif::test_finding_fingerprints_are_pinned_to_literal_values
  passed on base: tests.test_security_sarif::test_malformed_locations_never_raise[no physical location-locations3]
  passed on base: tests.test_security_sarif::test_the_same_finding_reported_twice_is_collapsed
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[moderate-MEDIUM]
  passed on base: tests.test_security_sarif::test_a_scanner_that_did_not_run_gets_no_run_only_a_notification
  passed on base: tests.test_security_sarif::test_a_report_counts_every_severity
  passed on base: tests.test_security_sarif::test_a_scanner_finding_is_normalized_into_structure
  passed on base: tests.test_security_sarif::test_malformed_locations_never_raise[artifact location not an object-locations4]
  passed on base: tests.test_security_sarif::test_an_emitted_document_declares_the_supported_schema_and_version
  failed on base: tests.test_security_sarif::test_the_run_of_a_tool_holds_each_record_of_that_tool_in_its_property_bag (pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolRun)
  passed on base: tests.test_security_sarif::test_a_fingerprint_distinguishes_the_same_rule_in_different_files
  passed on base: tests.test_security_sarif::test_paths_are_normalized_without_mangling_leading_dots[-]
  passed on base: tests.test_security_sarif::test_a_title_without_a_rule_prefix_gets_a_derived_identifier
  passed on base: tests.test_security_sarif::test_a_rule_glob_suppresses_matching_findings
  passed on base: tests.test_security_sarif::test_a_policy_that_is_not_a_mapping_is_rejected
  passed on base: tests.test_security_sarif::test_the_summary_reports_severities_with_no_findings
  passed on base: tests.test_security_sarif::test_filtering_by_severity_keeps_the_threshold_itself
  passed on base: tests.test_security_sarif::test_scanner_location_strings_are_split_into_structure[registry.example.com/img:efficiency-expected4]
  passed on base: tests.test_security_sarif::test_scanner_severity_vocabularies_map_onto_one_scale[note-LOW]
  passed on base: tests.test_security_sarif::test_a_finding_with_no_path_emits_no_location
  passed on base: tests.test_security_sarif::test_findings_are_ranked_most_severe_first
  passed on base: tests.test_k8s::test_deploy_stack_dry_run_lists_the_kustomizations_its_stacks_apply[all-kustomizations1]
  passed on base: tests.test_k8s::test_k8s_bootstrap_openwebui
  passed on base: tests.test_k8s::test_recover_stuck_helm_release_deployed_does_nothing
  passed on base: tests.test_k8s::test_loki_deletes_logs_once_they_are_thirty_days_old
  passed on base: tests.test_k8s::test_pyroscope_helm_release_and_grafana_datasource
  passed on base: tests.test_k8s::test_deploy_stack_dry_run_lists_the_kustomizations_its_stacks_apply[infra-kustomizations0]
  passed on base: tests.test_k8s::test_deploy_stack_dry_run_refuses_like_the_deploy_without_service_repositories
  passed on base: tests.test_k8s::test_pyroscope_port_forward_and_proxy_targets
  passed on base: tests.test_k8s::test_require_helm_version
  passed on base: tests.test_k8s::test_k8s_status_dry_run
  passed on base: tests.test_k8s::test_k8s_teardown_stack_when_argo_not_managed_allows_teardown
  passed on base: tests.test_k8s::test_deploy_stack_without_service_repositories_writes_nothing_and_names_the_setting
  passed on base: tests.test_k8s::test_an_alert_fires_before_the_log_or_metric_volume_fills
  passed on base: tests.test_k8s::test_k8s_deploy_stack_fails_when_cluster_unreachable
  passed on base: tests.test_k8s::test_helm_version_older_than_minimum_fails
  passed on base: tests.test_k8s::test_deploy_stack_with_process_fake_pending_upgrade_rolls_back
  passed on base: tests.test_k8s::test_deploy_stack_leaves_the_service_digest_image_updater_set_on_application_devops
  passed on base: tests.test_k8s::test_teardown_stack_keeps_the_prometheus_operator_crds
  passed on base: tests.test_k8s::test_native_teardown_stack_llm_deletes_the_gateway_kustomization
  passed on base: tests.test_k8s::test_no_manifest_runs_an_in_cluster_image_registry
  passed on base: tests.test_k8s::test_deploy_stack_on_argo_cd_pushes_secrets_after_deriving_the_hosts_and_before_writing
  passed on base: tests.test_k8s::test_k8s_lint_exit_codes
  passed on base: tests.test_k8s::test_infra_teardown_deletes_the_template_before_the_uninstalls_and_the_namespace_after
  passed on base: tests.test_k8s::test_recover_stuck_helm_release_uninstalls_pending_install
  passed on base: tests.test_k8s::test_k8s_port_forward_llm_dry_run
  passed on base: tests.test_k8s::test_k8s_stack_deploy_ssa_and_manifest_contracts
  passed on base: tests.test_k8s::test_k8s_apply_logs_and_urls
  passed on base: tests.test_k8s::test_k8s_helpers_and_error_branches
  passed on base: tests.test_k8s::test_k8s_deploy_stack_llm_dry_run
  passed on base: tests.test_k8s::test_infra_stack_applies_the_perimeter_before_and_the_template_after_every_chart
  passed on base: tests.test_k8s::test_k8s_contexts_and_switch
  passed on base: tests.test_k8s::test_k8s_service_url_helpers
  passed on base: tests.test_k8s::test_k8s_contexts_dry_run
  passed on base: tests.test_k8s::test_k8s_teardown_stack_refuses_on_argo_check_error
  passed on base: tests.test_k8s::test_k8s_teardown_stack_when_argo_cd_managed
  passed on base: tests.test_k8s::test_k8s_status
  passed on base: tests.test_k8s::test_infra_dry_runs_list_the_argo_workflows_release_perimeter_and_template
  passed on base: tests.test_k8s::test_deploy_stack_dry_run_lists_the_kustomizations_its_stacks_apply[llm-kustomizations2]
  passed on base: tests.test_k8s::test_deploy_stack_refuses_a_revision_with_no_placeholder_host_rather_than_clear_staged_hosts
  passed on base: tests.test_k8s::test_is_cluster_argo_managed
  passed on base: tests.test_k8s::test_teardown_stack_skips_post_helm_delete_when_crd_not_installed
  passed on base: tests.test_k8s::test_deploy_stack_without_a_domain_writes_nothing_and_names_the_setting
  passed on base: tests.test_k8s::test_teardown_stack_removes_the_monitoring_perimeter_with_its_namespace[all-removal0]
  passed on base: tests.test_k8s::test_deploy_stack_fails_when_argo_cd_refuses_the_hosts
  passed on base: tests.test_k8s::test_deploy_stack_writes_nothing_when_an_application_does_not_build_at_its_revision
  passed on base: tests.test_k8s::test_k8s_deploy_stack_no_wait
  passed on base: tests.test_k8s::test_bootstrap_openwebui_dry_run_masks_email
  passed on base: tests.test_k8s::test_k8s_deploy_stack_all_dry_run
  passed on base: tests.test_k8s::test_deploy_stack_on_argo_cd_applies_the_config_map_and_sets_hosts_from_each_applications_revision
  passed on base: tests.test_k8s::test_deploy_stack_with_process_fake_pending_install_uninstalls
  passed on base: tests.test_k8s::test_llm_stack_applies_the_gateway_policy_before_the_gateway_and_deletes_it
  passed on base: tests.test_k8s::test_k8s_security_tools_and_scans
  passed on base: tests.test_k8s::test_k8s_teardown_stack_llm_dry_run
  passed on base: tests.test_k8s::test_k8s_deploy_and_teardown_dry_run_makes_no_cluster_calls
  passed on base: tests.test_k8s::test_native_deploy_stack_infra_applies_the_monitoring_kustomization
  passed on base: tests.test_k8s::test_deploy_stack_llm_on_argo_cd_changes_nothing_itself
  passed on base: tests.test_k8s::test_native_deploy_stack_llm_applies_the_gateway_kustomization_after_the_secret_push
  passed on base: tests.test_k8s::test_build_helm_upgrade_cmd_carries_take_ownership
  passed on base: tests.test_k8s::test_deploy_stack_stages_the_hosts_of_a_revision_before_it_merges
  passed on base: tests.test_k8s::test_deploy_stack_reports_post_helm_apply_failure_when_crd_not_installed
  passed on base: tests.test_k8s::test_is_helm_v4_or_newer_capability_detection
  passed on base: tests.test_k8s::test_k8s_extended_subcommands
  passed on base: tests.test_k8s::test_extract_service_url_ingress_and_nodeport
  passed on base: tests.test_k8s::test_k8s_deploy_stack_dry_run
  passed on base: tests.test_k8s::test_deploy_stack_dry_run_says_an_argo_cd_cluster_needs_a_domain_and_runs_nothing
  passed on base: tests.test_k8s::test_k8s_bootstrap_and_stacks
  passed on base: tests.test_k8s::test_k8s_configure_urls_llm_dry_run
  passed on base: tests.test_k8s::test_both_volumes_hold_thirty_days_and_no_size_cap_cuts_them_short
  passed on base: tests.test_k8s::test_k8s_workload_resource_limits_and_probes
  passed on base: tests.test_k8s::test_recover_stuck_helm_release_rolls_back_pending_rollback
  passed on base: tests.test_k8s::test_deploy_stack_on_a_native_cluster_applies_the_rendered_config_map_and_no_file_of_it
  passed on base: tests.test_k8s::test_llm_stack_applies_gateway_servicemonitor_after_helm_and_deletes_before_uninstall
  passed on base: tests.test_k8s::test_k8s_helm_upgrade_command_includes_pinned_version
  passed on base: tests.test_k8s::test_k8s_apply_and_logs
  passed on base: tests.test_k8s::test_k8s_tls_secret_and_audit
  passed on base: tests.test_k8s::test_mask_email_display_variants
  passed on base: tests.test_k8s::test_k8s_configure_urls_dry_run
  passed on base: tests.test_k8s::test_k8s_deploy_stack_invalid_stack
  passed on base: tests.test_k8s::test_teardown_stack_removes_the_monitoring_perimeter_with_its_namespace[infra-removal1]
  passed on base: tests.test_k8s::test_k8s_teardown_stack_dry_run
  passed on base: tests.test_k8s::test_k8s_configure_urls_success
  passed on base: tests.test_k8s::test_teardown_stack_devops_deletes_the_config_map_deploy_stack_rendered
  passed on base: tests.test_k8s::test_k8s_bootstrap_dry_run
  passed on base: tests.test_k8s::test_deploy_stack_dry_run_reports_the_config_map_and_host_overrides_and_runs_nothing
  passed on base: tests.test_k8s::test_deploy_stack_dry_run_makes_no_request
  passed on base: tests.test_k8s::test_deploy_stack_warns_on_kubectl_version_skew
  passed on base: tests.test_k8s::test_deploy_stack_fails_when_the_cluster_refuses_the_config_map
  passed on base: tests.test_k8s::test_prometheus_operator_crds_install_before_every_service_monitor
  passed on base: tests.test_k8s::test_deploy_stack_dry_run_lists_the_secrets_and_key_names_and_runs_nothing
  passed on base: tests.test_k8s::test_resolve_accessible_url_fallback
  passed on base: tests.test_k8s::test_k8s_bootstrap_fails_when_minikube_stopped_and_no_auto_start
  passed on base: tests.test_k8s::test_deploy_stack_infra_on_argo_cd_sets_only_the_ingress_hosts
  passed on base: tests.test_k8s::test_recover_stuck_helm_release_rolls_back_pending_upgrade
6 failed on base (6 failed and 267 passed in tests/commands/test_k8s_audit.py, tests/security/test_kube_api_network_profile.py, tests/test_builtin_tools.py, tests/test_k8s.py, tests/test_secops.py, tests/test_security_sarif.py; 4 errored).
Elapsed: 42s

@dan-petty
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
dan-petty force-pushed the feat/2132-popeye-kube-api-sandbox branch from a07d875 to c0d204c Compare October 28, 2026 17:31
@dan-petty
dan-petty merged commit e02c3fb into main Oct 28, 2026
17 checks passed
@dan-petty
dan-petty deleted the feat/2132-popeye-kube-api-sandbox branch October 28, 2026 17:52
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/k8s Kubernetes commands, Helm charts, pods, services, and policies scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(security): popeye runs in the tool sandbox with one named profile that opens only the kubernetes api

1 participant