Repository navigation
fix: mask WORKOS_API_KEY in debug env output - #277
willporter-workos wants to merge 1 commit into
Conversation
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>
[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
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
Reviews (1) · Last reviewed commit: "fix: mask WORKOS_API_KEY in debug env ou..." · Reviewed by Greptile |
| 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], |
There was a problem hiding this 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.
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.|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
Prompt hidden (unlisted session) |
Summary
workos debug envprintedWORKOS_API_KEYin full in both human and--jsonoutput, so pasting its output into a support ticket, issue, or CI log leaked a live management key.debug statealready masks secrets by default behind--show-secrets;debug envnow does the same.ENV_VAR_CATALOGentries take an optionalsecret: true(set onWORKOS_API_KEY);runDebugEnv({ showSecrets })passes those values through the existingmaskSecret()unless--show-secretsis set.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 fullbun run testrun,ai-analysis.spec.tsfailed once; it passes when run alone, both on main and on this branch.Implemented in session Triage CLI debug env API key leak report
Review with Devin · Open in Devin Desktop