Skip to content

fix: mask WORKOS_API_KEY in debug env output - #277

Open
willporter-workos wants to merge 1 commit into
mainfrom
devin/1795032402-mask-debug-env-secrets
Open

willporter-workos wants to merge 1 commit into
mainfrom
devin/1795032402-mask-debug-env-secrets

Conversation

@willporter-workos

@willporter-workos willporter-workos commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

workos debug env printed WORKOS_API_KEY in full in both human and --json output, so pasting its output into a support ticket, issue, or CI log leaked a live management key. debug state already masks secrets by default behind --show-secrets; debug env now does the same.

  • ENV_VAR_CATALOG entries take an optional secret: true (set on WORKOS_API_KEY); runDebugEnv({ showSecrets }) passes those values through the existing maskSecret() unless --show-secrets is set.
  • JSON shape is unchanged; only the value is masked (sk_t****mnop).

From a bug bounty report (Plain T-26250), triaged as Low (the user has to share the output themselves). The report's other claim, that an existing credentials file with loose permissions is never tightened, doesn't hold up: every CLI version has written that file with 0o600.

Tests: added specs for human and JSON masking and for --show-secrets. lint, format, typecheck, and build pass. In the full bun run test run, ai-analysis.spec.ts failed once; it passes when run alone, both on main and on this branch.


Bug Bounty Triage opened this PR for Will
Implemented in session Triage CLI debug env API key leak report
Review with Devin · Open in Devin Desktop


Mask the key in human and JSON output by default, matching debug state,
and add --show-secrets to print it unredacted.

Co-Authored-By: Will Porter <will.porter@workos.com>
@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The change is limited to values printed by the debug environment report.

The PR appears safe to merge, with a non-blocking issue in how empty values are reported.

Findings

  1. P2 Empty keys appear unset ▶
Fix with agent prompt
### Issue 1
src/commands/debug.ts:419
**Empty keys appear unset.** With `WORKOS_API_KEY=''`, `maskSecret()` returns `undefined`. The default output then lists the variable as unset and returns `null` in JSON, while `--show-secrets` correctly reports it as set with an empty value. Preserve the original value's presence when building the `set` and `unset` lists, and add an empty-value test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

workos debug env now masks WORKOS_API_KEY by default and lets users reveal it with --show-secrets.

  • Debug environment output masks the API key unless you ask to show it.

Reviews (1) · Last reviewed commit: "fix: mask WORKOS_API_KEY in debug env ou..." · Reviewed by Greptile

Comment thread src/commands/debug.ts
const vars: EnvVarInfo[] = ENV_VAR_CATALOG.map(({ name, effect, secret }) => ({
name,
value: process.env[name],
value: secret && !showSecrets ? maskSecret(process.env[name]) : process.env[name],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Empty keys appear unset. With WORKOS_API_KEY='', maskSecret() returns undefined. The default output then lists the variable as unset and returns null in JSON, while --show-secrets correctly reports it as set with an empty value. Preserve the original value's presence when building the set and unset lists, and add an empty-value test.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/commands/debug.ts
Line: 419

Comment:
**Empty keys appear unset.** With `WORKOS_API_KEY=''`, `maskSecret()` returns `undefined`. The default output then lists the variable as unset and returns `null` in JSON, while `--show-secrets` correctly reports it as set with an empty value. Preserve the original value's presence when building the `set` and `unset` lists, and add an empty-value test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Prompt hidden (unlisted session)

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant