Skip to content

fix(redaction): keep machine-readable output out of the redaction path - #1307

Closed
skevetter wants to merge 4 commits into
mainfrom
fix/redaction-machine-readable-output
Closed

skevetter wants to merge 4 commits into
mainfrom
fix/redaction-machine-readable-output

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Summary

Redaction replaces a secret value as a literal substring wherever it appears, with no minimum length. A one-character value under a credential-bearing key therefore masked that character everywhere in captured subprocess output.

On a machine with such a variable set, this produced two concrete failures:

  • the detected agent version v1.2.3 became v***.2.3
  • a docker volume mountpoint became a path that does not exist, so writing the agent binary into the volume failed with ENOENT

The capture path was also conflating two different things: subprocess.Result.Stdout is redacted for display, but several callers parse it as data.

Changes

pkg/secrets — NewRedactor skips values below minRedactableValueLength (8) and reports them through SkippedValueCount, so a genuinely short secret is surfaced rather than silently left unmasked. The Redactor already computed this length for its replacer but never used it.

pkg/subprocess — adds Result.RawStdout and Options.UnredactedStdout, so callers that parse command output can use it verbatim while Stdout, Stderr and DiagnosticOutput stay redacted for display. RawStdout is empty unless requested, so the default path is unchanged. This mirrors the UnredactedStdout option pkg/git already used for git credential fill.

Callers routed through raw capture — the volume mountpoint, managed volume listing, detected agent version and seed label parsing in pkg/agent/delivery, and the rendered environment template in pkg/devcontainer/crane.

Verification

  • The eight failures above are reproduced on main and pass here, same environment.
  • Reverting the capture split alone makes the new delivery tests fail again, which is what shows the split rather than the guard is the causal fix. The guard is separately covered: neutralising the threshold fails the pkg/secrets tests while leaving delivery green.
  • The new delivery tests inject the offending variable explicitly, so they fail on unfixed code with the original symptom and pass with the fix, in any environment rather than only where that variable happens to be set.

Note for review

NewRedactor now leaves values under 8 characters unmasked, and SkippedValueCount exists to report them. Whether 8 is the right threshold, and whether callers should surface that count, is a security tradeoff worth a second opinion.

skevetter and others added 4 commits September 27, 2026 23:23
Redaction replaces a secret value as a literal substring wherever it
appears, with no minimum length. A one-character value under a
credential-bearing key therefore masked that character everywhere in
captured subprocess output: "v1.2.3" became "v***.2.3" and a docker
volume mountpoint became a path that does not exist, so writing the
agent binary into the volume failed with ENOENT.

Skip values below minRedactableValueLength and report them through
SkippedValueCount, so a genuinely short secret is surfaced rather than
silently left unmasked. The Redactor already computed this length for
its replacer but never used it.

Two existing tests used sub-threshold fixtures ("hunter2", "sec"); they
now use realistic values that still exercise the behavior they cover.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Result.Stdout is redacted, but several callers parse it as data rather
than display it. A redactor that masked any character of a value then
corrupted the value itself: the docker volume mountpoint became a path
that does not exist, and the agent version and seed labels parsed wrong.

Add Result.RawStdout plus Options.UnredactedStdout so those callers can
use the output verbatim while Stdout, Stderr and DiagnosticOutput stay
redacted for display. RawStdout is empty unless requested, so the
default path is unchanged. This mirrors the UnredactedStdout option pkg/git
already used for `git credential fill`.

Route the volume mountpoint, managed volume listing, detected agent
version and seed label parsing in pkg/agent/delivery through raw capture,
along with the rendered environment template in pkg/devcontainer/crane,
which reaches subprocess through the options-based entry point.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The eight failures that surfaced this bug only reproduce when the ambient
environment happens to hold a credential-bearing variable with a
low-entropy value. On a clean CI runner they pass, so the regression
would not have been caught by the new unit-test job.

Inject the offending variable explicitly through the delivery
Environment field and assert that both consumers of machine-readable
docker output survive it: the volume mountpoint, which is used as a
filesystem path, and the detected agent version, which is compared
verbatim.

Both fail against the unfixed code with the original symptom
("v1.2.3" reported as "v***.2.3", and a mountpoint path rewritten to
"00***"), and pass once the capture path is separated from redaction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comments restated what the code already says. Cut them back to the part
that is not derivable: why a value must be long enough to mask, and why
the docker output is captured unredacted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit beba14a
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6ab9fa8f80c17b00089c56a1

@netlify

netlify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit beba14a
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6ab9fa8f5aec060008d1198c

@skevetter skevetter closed this Oct 6, 2026
@skevetter
skevetter deleted the fix/redaction-machine-readable-output branch November 7, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant