Skip to content

Scrub leaked tokens from test-quarantine Part 1 output - #67322

Merged
wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/quarantine-scrub-tokens
Jun 19, 2026
Merged

wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/quarantine-scrub-tokens

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Jun 19, 2026

Copy link
Copy Markdown
Member

The daily test-quarantine workflow gathers flaky-test failure data into part1_data and injects it into the agent prompt via job outputs. Some aspnetcore E2E tests run as Helix work items, and on failure the Helix result-upload step logs a live Azure DevOps bearer JWT into the console log. Part 1 captures Helix [FAIL] blocks and test stack traces verbatim, so the JWT ends up in the output.

GitHub's GITHUB_OUTPUT secret detector then skips the entire part1_data value (Skip output 'part1_data' since it may contain secret), leaving the agent with empty data and producing a false noop on every run.

Fix

Redact token-shaped strings from the captured error/stack/[FAIL]-block text before the length caps, plus a final pass over the serialized payload as a safety net (GitHub's skip is all-or-nothing, so any field can trip it). Patterns cover JWTs, GitHub tokens, Bearer headers, Azure SAS signatures, basic-auth URLs, connection-string secrets, and long base64 runs.

This removes the detector trigger and also avoids surfacing live tokens in the agent prompt and uploaded artifacts.

Validated by replaying a real ~190 KB Part 1 payload end-to-end: the leaked JWT and other token-shaped runs are removed, git SHAs are preserved, and the JSON stays valid.

The .lock.yml is regenerated with gh aw compile.

The daily test-quarantine workflow gathers flaky-test failure data into
part1_data and injects it into the agent prompt via job outputs. Some
aspnetcore E2E tests run as Helix work items, and on failure the Helix
result-upload step logs a live Azure DevOps bearer JWT into the console
log. Part 1 captures Helix [FAIL] blocks and test stack traces verbatim,
so the JWT lands in the output. GitHub's GITHUB_OUTPUT secret detector
then skips the entire part1_data value ("may contain secret"), leaving
the agent with empty data and producing a false noop every run.

Redact token-shaped strings (JWTs, GitHub tokens, Bearer headers, SAS
signatures, basic-auth URLs, connection-string secrets, long base64
runs) from the captured error/stack/[FAIL]-block text before emitting,
plus a final pass over the serialized payload as a safety net. This
removes the detector trigger and avoids surfacing live tokens in the
prompt and uploaded artifacts.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 19, 2026 16:17
@wtgodbe
wtgodbe requested a review from a team as a code owner June 19, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents the daily test-quarantine workflow from leaking token-shaped secrets (notably an Azure DevOps bearer JWT that can appear in Helix failure logs) into the part1_data job output, which can cause GitHub’s GITHUB_OUTPUT secret detector to skip the entire output and leave the agent with empty Part 1 data.

Changes:

  • Add regex-based secret scrubbing for captured failure text (errorMessage, stackTrace, and extracted Helix [FAIL] blocks) before applying existing length caps.
  • Add a final “safety net” scrub over the fully serialized part1_data JSON payload before writing to GITHUB_OUTPUT.
  • Regenerate the gh-aw compiled workflow lock file.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/test-quarantine.md Adds scrub_secrets() and applies it to captured failure text + final serialized payload before emitting part1_data.
.github/workflows/test-quarantine.lock.yml Regenerated compiled workflow reflecting the .md updates (and updated pinned action SHAs/versions).

Comment thread .github/workflows/test-quarantine.md Outdated
re.compile(r'(?i)\bhttps?://[^/\s:@"]+:[^@\s/"]{6,}@'), # basic-auth credentials in URL
re.compile(r'(?i)[?&]sig=[A-Za-z0-9%/+_=-]{20,}'), # Azure SAS signature
re.compile(r'(?i)\b(?:AccountKey|SharedAccessKey|AccessKey|Password|Pwd)=[^;\s"\']{12,}'), # connection-string secret
re.compile(r'[A-Za-z0-9+/=_-]{52,}'), # long high-entropy run (AzDO PAT, base64)
Comment on lines 34 to 36
# Custom actions used:
# - actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# - actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
# - actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Require the generic token pattern to start with an alphanumeric so it no
longer redacts long ===/---/___ separator lines in stack traces and
[FAIL] blocks, while still catching base64/PAT-like tokens.

Co-authored-by: Copilot <[email protected]>
@wtgodbe
wtgodbe merged commit 3d18de5 into dotnet:main Jun 19, 2026
10 checks passed
wtgodbe added a commit that referenced this pull request Jun 21, 2026
#67338)

The daily test-quarantine workflow's activation job was failing with
"An error occurred trying to start process '/usr/bin/bash' ... Argument
list too long" (E2BIG). The pre_activation step computes ~225 KB of CI
failure data (part1_data) and gh-aw passes it to the prompt-building
steps as a single environment variable. Linux caps one env-var string at
MAX_ARG_STRLEN (32 * 4 KiB page = 131072 bytes) during execve, so merely
declaring that variable on a step makes the step die before it runs.

This was latent until #67322 fixed token scrubbing: previously GitHub's
secret detector skipped the whole output, so the env var resolved empty
and never hit the limit; with scrubbing fixed the data now flows at full
size and trips MAX_ARG_STRLEN.

Split part1_data into 16 fixed, byte-bounded chunks (<=80000 bytes each,
well under the limit), one per job output (part1_data_0..15), and
concatenate the placeholders adjacently in the prompt so gh-aw's
exact-string substitution reconstructs the JSON verbatim. Empty slots
cost nothing, so total environment size is unchanged. Chunks split on
UTF-8 character boundaries; a loud FATAL guards the (unreachable in
practice, since json.dumps emits ASCII) case of overflow rather than
silently truncating.

Recompiled the lockfile with gh aw v0.79.8.

Co-authored-by: Copilot <[email protected]>
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants