Skip to content

fix(release): redact the token in the GitHub and GitLab release error output - #36852

Open
AgentEnder wants to merge 10 commits into
masterfrom
ss-bearer-token-log-e9d15dac
Open

fix(release): redact the token in the GitHub and GitLab release error output#36852
AgentEnder wants to merge 10 commits into
masterfrom
ss-bearer-token-log-e9d15dac

Conversation

@AgentEnder

@AgentEnder AgentEnder commented Aug 30, 2026

Copy link
Copy Markdown
Member

Current Behavior

When creating a GitHub or GitLab release fails, the error output includes Token Header Data: [object Object]. It doesn't leak the token today, but it reads like a formatting bug, and the obvious fix (JSON.stringify, like the Body: line next to it) would print the bearer token in CI logs.

Expected Behavior

The line names the header the token was sent under, with the value redacted: Token Header: Authorization: Bearer <redacted>, or Token Header: none when no token was configured. Specs assert the token itself never appears.

The unknown-error fallback right below had the same problem: it dumped the raw axios error, which carries the token in config.headers. It now prints the error with the token value replaced by <redacted>.

Related Issue(s)

Fixes #

NXC-4910, raised by https://socket.dev/npm/package/nx/alerts/23.1.2?alert_name=gptSecurity


View Polygraph session ↗

… output

- The API-error output printed `Token Header Data: [object Object]`. It never
  leaked a token, but it read as a formatting bug and the obvious fix
  (`JSON.stringify`, as the adjacent `Body:` line does) would have written the
  bearer token to CI logs.
- Print the header name with the value redacted instead, or `none` when no
  token was configured, so a failing release still shows which credential
  source was used.
- Add specs for both clients asserting the token never appears in the output.

Flagged by the Socket gptSecurity analysis of nx 23.1.2.
@netlify

netlify Bot commented Aug 30, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 32ad586
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a9b36d77825d00008376d04
😎 Deploy Preview https://deploy-preview-36852--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 30, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 32ad586
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a9b36d78d68e00007fd3d62
😎 Deploy Preview https://deploy-preview-36852--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 71cb8aa

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ✅ Succeeded 11m 41s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 55s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 18s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-04 21:39:27 UTC

@polygraph-app
polygraph-app Bot marked this pull request as ready for review August 30, 2026 03:34
@polygraph-app
polygraph-app Bot requested a review from a team as a code owner August 30, 2026 03:34
@polygraph-app
polygraph-app Bot requested a review from JamesHenry August 30, 2026 03:34
nx-cloud[bot]

This comment was marked as outdated.

AgentEnder and others added 3 commits August 31, 2026 16:26
The fallback branch of handleError logged the raw error object, and an axios
error carries the real token in `config.headers` and `request._header`. Dump
it through util.inspect with the token value replaced by `<redacted>` instead.
… value

The dump is searched for the raw env value, but the rendered text can differ:
axios trims header values before sending, and inspect() escapes them. A token
with trailing whitespace therefore matched nothing and was printed in full,
while auth still succeeded, so the misconfiguration gave no signal.

Trim the token before searching and also redact its inspected rendering. The
trim doubles as the empty-token guard: the previous check tested tokenData,
not the token, so a blank value made split('') interleave the marker between
every character of the dump.
nx-cloud[bot]

This comment was marked as outdated.

FrozenPandaz and others added 3 commits September 1, 2026 18:18
The two needles coincide whenever the token has nothing for inspect() to
escape, which is the normal case. The second pass then scans the whole dump
again for no gain, and rewrites the marker the first pass inserted.
Node strips CR/LF from outgoing header values, so a token that picked one up
(a wrapped paste into a CI variable) authenticates on the stripped form while
the dump held it unredacted. Same shape as the trimming case: the sent value
differs from the configured one.
nx-cloud[bot]

This comment was marked as outdated.

@AgentEnder

Copy link
Copy Markdown
Member Author

Assigned. One thing to carry into review: this is a credential-redaction change, so what needs checking is whether every path that can surface the token is covered, not just the two error messages in the diff.

Triage notes (automated triage, reviewed before posting)

CI rollup is SUCCESS on the head commit.

No GitHub closing reference, and none is needed. This is tracked in Linear as NXC-4910.

FrozenPandaz and others added 2 commits September 4, 2026 16:25
inspect() renders a long value carrying a line break as concatenated per-line
chunks, so no whole-token needle spans it and a wrapped paste of a
github_pat_ token (~93 chars) leaked. Redact each line as well, skipping
fragments short enough to collide with ordinary dump text.

Also covers the gaps the fix left untested: the JOB-TOKEN header, a blank
token leaving the dump untouched, and the missing string-type guard on the
trailing-whitespace specs.

@nx-cloud nx-cloud Bot 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.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants