Repository navigation
fix(api): Redact container command lines from the served debug info - #396
Draft
yuechao-qin wants to merge 1 commit into
Draft
yuechao-qin wants to merge 1 commit into
yuechao-qin wants to merge 1 commit into
Conversation
A container that consumes a secret as an input value receives it on its command line, so the launched object a launcher stores in `ContainerExecution.launcher_data` can hold that value in plaintext, and `get_container_execution_state` serves that dict to any authenticated user as `debug_info`. Launchers can blank it on the way in, but a row written before they did, or by a launcher that does not, still holds it. At serving time the stored dict is all there is and nothing records which parts came from a secret, so the filter is deliberately non-selective: every element of every command line list, at any depth, is replaced with `<REDACTED_ON_READ>`. Depth and spelling both matter - a Pod keeps containers at `spec.containers`, a Job at `spec.template.spec.containers` plus a copy per Pod, and the Docker launcher stores a raw `docker inspect` dict spelling the same fields `Args`, `Config.Cmd` and `Config.Entrypoint`. The helper returns a copy, so a read request cannot mark the JSON column dirty.
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 component input whose value comes from the secret store is passed to the container on its
command line, so the launched object a launcher stores in
ContainerExecution.launcher_datacanhold that value in plaintext.
get_container_execution_stateserves that dict straight back asdebug_info, so any authenticated user reading an execution's container state can read it.#395 stops the Kubernetes launchers writing it. This is the other half: a filter on the way out,
for the rows that fix cannot reach.
Before / after
GET /api/executions/{execution_node_id}/container_stateKubernetes shape —
.debug_info.kubernetes_job.debug_job.spec.template.spec.containers[0],and the same again for every
.debug_info.kubernetes_job.debug_pods[*].spec.containers[0]:Docker shape —
.debug_info.docker.debug_container:Everything that is not a command line list is served unchanged —
image,Path,Config.Image,job_name— and the stored row is not touched, so the plaintext is still inthe database until a backfill runs.
(shapes and values from the tests in this PR, not a live capture)
Fix
At serving time the stored dict is all there is, and nothing in it records which parts came from
a secret — so every element of every command line list goes, at any depth.
Depth and spelling both matter:
debug_pod.spec.containers[*].command/.argsdebug_job.spec.template.spec.containers[*], plus a copy per Pod underdebug_podsdocker inspectdict:Args,Config.Cmd,Config.EntrypointHence a recursive walk and a case-insensitive match on
command,args,cmd,entrypoint.Notes
<REDACTED_ON_READ>, deliberately different from a launcher-side marker: itsays the serving layer hid this, and therefore that the row may still hold the value. It
claims nothing about the element having been a secret, because at this point that is unknown.
instance's JSON column dirty. Asserted by a test.
written, which needs a separate one-off pass.
pass values on the command line, and the launcher that does deliver secrets by environment
persists no spec at all. Easy to extend if that changes.
Tests
tests/test_execution_nodes_api_service.py, inTestGetContainerExecutionStatedebug_podsare bothblanked, while
imageandjob_nameare served unchangeddocker inspectshape:Args,Config.Cmd,Config.Entrypointblanked;Path(astring) and
Config.Imageuntouchedsession.dirtyisempty
Each fails on the code without this change. Full suite: 537 passed.
blackclean.