Repository navigation
fix(redact): mask kubectl secret reads and shell-expanded flags (RIG-11965) - #223
Merged
rigel-nemo[bot] merged 13 commits intoNov 23, 2026
Merged
rigel-nemo[bot] merged 13 commits into
rigel-nemo[bot] merged 13 commits into
Conversation
…11965) Add a Kubernetes pass to redact_sensitive_text. It masks Secret data and stringData values (YAML and JSON, including truncated JSON), env value entries under a secret-named name (YAML, JSON either order, kubectl describe Environment blocks). Keys, ConfigMap data, valueFrom and non-secret env stay. All scans are linear; a 1 MB test runs under 1 s. Refs RIG-11725 Co-authored-by: Matt Wilkinson <matt@rigel.build>
Move the Kubernetes pass to agent/redact_kubernetes.py, a span-based module. JSON is read in one token pass with an object stack. Each object is decided when it closes or when the text ends, so kubectl key order (data before kind), cut-off output, Lists, SecretList and the last-applied-configuration annotation are masked. YAML is read in one line pass. Helm flow env, Go-map env and describe lines are covered. Secret names add PASS, PWD and AUTH; _TTL, _PATH and _FILE names stay visible. Every review probe row is a test; 1 MB perf rows run under 1 s. Refs RIG-11725 Co-authored-by: Matt Wilkinson <matt@rigel.build>
Run the PEM block pass before the Kubernetes pass, and mask every continuation line of a describe env value. A list item with no kind is decided by its list (SecretList, or unknown at end of text). A kind cut off mid-word counts as unknown. JSON env after a one-word jsonpath prefix is checked again. Setting names (MAX_, _TOKENS, _ENABLED, _MODE, _LENGTH, _DAYS and similar) stay visible through a name allowlist; the _ID exemption is gone. file_read masks with the non-reusable sentinel. JSON nesting is capped at 512. Refs RIG-11725 Co-authored-by: Matt Wilkinson <matt@rigel.build>
…v names Refs RIG-11725 Co-authored-by: Matt Wilkinson <matt@rigel.build>
…Go-map tails, deep JSON - Secret reads through go-template or jsonpath mask the whole output. - kubectl set env --list masks NAME=value values. - Go-map values run to the segment end, fail closed past ] and word:. - JSON nesting past the depth cap masks the rest of the text.
- Secret reads with go-template, template, custom-columns or jsonpath output mask the whole output. - kubectl is found at any token (kubectl.exe, sudo, sh -c); secrets.v1 and -f secret.yaml count as Secret reads. - kubectl set env --list=... masks NAME=value values. - Go-map segments end only at the next map[name:/map[value: key.
A glob in an unquoted token (*, ?, [, ], ~) expands in bash after shlex reads it as one token, so [-]ojsonpath can become a flag. Treat the glob characters like the other shell metacharacters: mask the whole output, and the command still runs. Red first: 2 glob rows failed at the brace commit.
…slashes (RIG-11965) The shell joins kube''ctl, "kube"ctl and kube\ctl into kubectl, but the gate read the raw first word, so these reads passed unmasked. The gate now masks any command whose first raw word holds a quote or backslash, and the mention check strips them first. Mask-only: the command still runs. Red first: 4 split rows failed with plain values.
The shell can build the kubectl name from quotes, backslashes, $, backticks,
parens, braces or a line continuation. The gate now masks any read whose first
raw word has a character outside [A-Za-z0-9._/+-], and the mention check
strips those characters (and ${...} expansions) before the name match. Mask-only:
the command still runs. Red first: 5 built-name rows and 4 split rows failed
with plain values; a keep row for a plain kubectl name stays unmasked.
…965)
Removing shell-building characters could join kubectl to the word before it
(echo x<newline>kubectl, ${IFS}, echo)kubectl), and the mention check then missed
it. The mention check now runs two copies: removed (joins split names) and
spaced (separates glued names). A hit in either counts. Red first: 7 glued-name
rows failed with plain values; the keep row for a plain kubectl name stays
unmasked.
…IG-11965) Nemo's condition for #223: describe on deployments still masks container env values, and logs output still goes through the value redactor. Adds one row each. No code change.
Contributor
Author
|
All-clear at 494a268 |
|
Checks read:
|
rigel-nemo
Bot
deleted the
harness/rig-11965-mask-kubectl-secret-reads-and-shell
branch
November 23, 2026 00:53
Contributor
Author
|
Correction to this merged PR's Risks section (RIG-12026 ruling): the |
This branch had an error being deployed
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.
What does this do
Masks the whole output of any kubectl/oc/k read that the gate cannot fully parse. Masking is the control; no command is blocked.
Supersedes #214 (RIG-11725). This PR includes #214's commits, so closing #214 alone does not remove them.
Why do we need it
The per-line Secret pass cannot see reads whose shell or flag shape hides the output format, and per-case fixes kept missing shapes (RIG-11965 ruling, option A).
Summary
-Ao), brace and glob expansion mask.exec,attach,debug,run,cp,get --raw,create token,config view --raw.Verification
pytest tests/agent/test_redact*.py tests/agent/test_compaction_redaction_boundaries.pyon mattpc-wsl at the PR head: 988 passed.get pods,get pods -o wide,logs,describe configmap,config viewwithout flags.Risks
-o jsonpath, pipes to filters,-n run).describe(RIG-12026): workload describe printsArgsand CRDSpec:values unmasked. Pod describe still masksEnvironment:values. The RIG-11887 bans on these forms stay until RIG-12026 closes.oc extract,oc whoami -t,oc rsh,oc sa get-tokenare not yet covered; tracked in RIG-11984.Spec impact
None to a public contract. Internal redaction behavior only. The RIG-11887 live masking check must include the reads listed in its comment.
Checks skipped:
nebula has no pre-push hook config; GitHub Actions ci.yaml runs its checksRefs RIG-11965
Co-authored-by: Matt Wilkinson matt@rigel.build