Repository navigation
fix(kubernetes): Do not store container command lines in the serialized launcher data - #415
Open
yuechao-qin wants to merge 2 commits into
Open
yuechao-qin wants to merge 2 commits into
yuechao-qin wants to merge 2 commits into
Conversation
Ark-kun
reviewed
Nov 3, 2026
| _remove_keys_with_none_values(obj_dict) | ||
| # A container that consumes a secret as a value receives that value on its command line, | ||
| # so a stored command line can hold a secret in plaintext. | ||
| _remove_command_lines(obj_dict) |
Contributor
There was a problem hiding this comment.
Nice idea to have the fix in a single place. But this makes the behavior of the function called _serialize_kubernetes_object_to_compact_dict surprising.
Let's move the _remove_command_lines call to the places where _serialize_kubernetes_object_to_compact_dict is called.
Alternatively, we can add another function like _serialize_kubernetes_object_to_compact_dict_and_censor_it that calls _serialize_kubernetes_object_to_compact_dict then _remove_command_lines.
Ark-kun
approved these changes
Nov 3, 2026
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.
Problem
A container that consumes a secret as a value receives that value on its command line. The Kubernetes launchers store the launched object verbatim in
ContainerExecution.launcher_data— at launch and again on every poll — so the secret lands in the database in plaintext and is served back to any authenticated caller in the execution API'sdebug_info. Deleting or rotating the secret does not scrub the stored copy.Before / after
ContainerExecution.launcher_data(database)commandandargsin plaintextdebug_infoinGET /api/execution_nodes/{id}/container_execution_stateFix
Remove
commandandargsfrom the serialized dict._serialize_kubernetes_object_to_compact_dictis the single seam every stored copy passes through, so one call covers all of them:debug_podLaunchedKubernetesPod.to_dictdebug_job.spec.templateLaunchedKubernetesJob.to_dictdebug_pods.<name>, one per Podto_dict, once per Pod15 added lines, nothing removed: one call plus a recursive key removal next to the existing
_remove_keys_with_none_values.Notes
exec.command. Selectivity is what made fix(kubernetes): Do not store secret values in the serialized launcher data #395 large (an annotation carrying redacted positions, written at launch and read back during serialization); this is the alternative suggested in review there, and supersedes it.debug_infono longer shows what a container ran, for every execution rather than only those consuming a secret. That is the cost of the patch being 15 lines.launcher_datais still owed, and is independent of this PR.docker inspectdict with the same exposure and is unaffected here.Tests
tests/launchers/kubernetes/test_kubernetes_command_line_removal.py— six tests, no cluster needed; they build aV1Pod/V1Joband go through both the serializer and the two launched-containerto_dictmethods.test_serialized_pod_has_no_command_linespec.containers[0],imagekept, secret absent from the whole dicttest_serialized_job_has_no_command_line_on_its_pod_templatespec.template.spec.containers[0]test_serialized_pod_has_no_command_line_anywherereadinessProbe.exec.commandare all strippedtest_launched_container_to_dict_has_no_command_linekubernetes.debug_podtest_launched_job_to_dict_has_no_command_line_in_any_copykubernetes_job.debug_job.spec.templateand every entry ofdebug_podstest_launched_pod_keeps_its_command_lineMutation-checked rather than asserted: disabling the call, removing either recursion branch, or narrowing the walk to
spec.containerseach turns two or three of these red; restoring the code returns all four to green. Full suite: 577 passed.