Skip to content

fix(redact): mask raw kubectl and oc secret reads (RIG-11984) - #226

Open
rigel-mintaka wants to merge 4 commits into
mainfrom
harness/rig-11984-mask-raw-kubectl-and-oc-secret-reads
Open

rigel-mintaka wants to merge 4 commits into
mainfrom
harness/rig-11984-mask-raw-kubectl-and-oc-secret-reads

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What does this do

Masks the whole output of raw kubectl and oc reads that the per-line Secret pass cannot see, and masks kubectl plugin output.

  • oc rsh, oc extract, oc whoami -t / --show-token, oc sa get-token now mask whole.
  • The oc forms of exec, debug, cp, create token, get --raw and config view --raw mask whole.
  • A kubectl-<name> plugin binary, or a plugin verb after kubectl, oc or k, masks whole. A read unmasks only when its first verb after the global flags is a built-in read verb.
  • Keep rows still show content: get, describe, logs, version, config view with no flags, oc whoami with no token flag.

Why do we need it

Raw reads print Secret content that the per-line pass cannot see (RIG-11984). Stacked on nebula#223 (RIG-11965).

Summary

Adds the oc-only and plugin shapes to the kubectl structured-read gate in forks/hermes-agent/agent/redact.py. Mask-only; no change to the per-line pass.

Verification

  • Red first: 15 oc and plugin rows failed on the stacked base; all pass after the fix.
  • Suite on mattpc-wsl: pytest tests/agent/test_redact*.py tests/agent/test_compaction_redaction_boundaries.py: 1050 passed. ruff check on the touched files: clean.

Risks

Over-masks by design: a token match on exec, debug, run, cp and attach masks clean output that happens to share those words.

Spec impact

None.

Checks skipped: nebula has no pre-push hook config; GitHub Actions ci.yaml runs its checks

Refs RIG-11984

Co-authored-by: Matt Wilkinson matt@rigel.build

@linear-code

linear-code Bot commented Nov 22, 2026

Copy link
Copy Markdown

RIG-11984

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

All-clear at 5d9f51d
Base: harness/rig-11965-mask-kubectl-secret-reads-and-shell

@rigel-mintaka
rigel-mintaka marked this pull request as ready for review November 22, 2026 06:08
Base automatically changed from harness/rig-11965-mask-kubectl-secret-reads-and-shell to main November 23, 2026 00:53
@rigel-mintaka
rigel-mintaka force-pushed the harness/rig-11984-mask-raw-kubectl-and-oc-secret-reads branch from 5d9f51d to a6aaf28 Compare November 23, 2026 01:18
@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

All-clear at a6aaf28
Base: main

rigel-mintaka and others added 4 commits November 22, 2026 23:19
Co-authored-by: Matt Wilkinson <matt@rigel.build>
…IG-11984)

kubectl exec, attach, debug, run and cp print container or file content
with no -o flag, and get --raw and create token return raw API objects
or bearer tokens. The per-line Secret pass cannot see these, so the
masker now masks the whole output of each. Token match over-masks by
design (for example -n run); that is accepted under option A.

Red first: 7 leak rows failed at 8fd0ee02; all green after the fix.
Pin three bypasses from the PR 226 review as strict xfail rows: oc whoami
-t=VALUE, verbose klog Secret bodies at -v 8+, and kuberc default output
(--kuberc=, KUBECTL_KUBERC=). Each row is a real leak today; strict xfail
turns red when a later fix makes it pass.

Not patched here: one patch round, per the review stop rule. Tracked on
RIG-11984.
@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

All-clear at 0ecf7e6
Base: main

This branch had an error being deployed

1 failed deployment
ci — 0ecf7e6d Deployed Nov 23, 2026 by rigel-mintaka via CI (aarch64-linux) #1167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-before-ready PR touches secrets or auth paths; review on the draft head before ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant