Repository navigation
Description
Problem Description
The output masking of devops-cli rewrites prose that has the word token followed by a colon and a word of 8 or more characters. It reads the prose as a secret assignment and replaces the word with token=<masked-token>, which changes the message and hides its cause.
The rule is the token|auth_token pattern of src/devops_cli/security/sanitizer.py (\b(?:token|auth_token)\s*[:=]\s*["']?(?P<value>[^\s"',;]{8,})). It matches the error text of a registry client: buildx writes failed to fetch oauth token, then a colon, then unexpected status from GET request to https://ghcr.io/...: 403 Forbidden. The pattern takes unexpected as the value.
Reproduction Steps
- Run a devops command whose output holds that buildx error, for example
devops k8s image-pins(test(k8s): every image pin under k8s/ resolves in its registry before the merge #1994) with a stored Docker credential that GHCR refuses. - Read the printed error.
Expected vs Actual Behavior
- Expected: the error prints as the tool wrote it, with the colon and the word
unexpected. The text holds no secret. - Actual: the colon and the word
unexpectedare replaced with an equals sign and the masked-token marker, and the printed message no longer says what failed.
Environment Diagnostics
origin/main a95992aa (2026-10-29).
Logs, Traces, or Terminal Output
The ✗ line of devops k8s image-pins in the #1994 measurement, for 5 GHCR images. The same detection also refused the first draft of this issue in devops roadmap intake ("The candidate's body holds what looks like a secret"), because the draft quoted the buildx error.
Existing Tool Considered
The masking already falls back to a literal match. A secret scanner's rule set (detect-secrets or gitleaks keyword rules with entropy) tells a prose word from a token by entropy; the fix may require entropy or a value shape for this one pattern, as the rules for keys already do.
Proposed design
Problem statement
The output masking in devops-cli rewrites prose that contains the word "token" followed by a colon and a common English word of 8 or more characters. The token|auth_token regex in src/devops_cli/security/sanitizer.py matches this prose as a secret assignment and replaces the word with a masked-token marker. This corrupts error messages and hides their cause. The same defect exists in the password|passwd|pwd pattern, which shares the same replacement function.
Acceptance criteria
Requirement: Prose word after token colon is not masked
The token|auth_token pattern SHALL not rewrite a value that does not look like a credential.
Scenario: prose word after token colon
- WHEN the input text contains "token: unexpected"
- THEN the output preserves "token: unexpected" unchanged
Requirement: Credential after token colon is still masked
The token|auth_token pattern SHALL rewrite a value that looks like a credential.
Scenario: credential after token colon
- WHEN the input text contains "token: abc123def456ghi789jkl012"
- THEN the output replaces the value with "token="
Requirement: Prose word after password colon is not masked
The password|passwd|pwd pattern SHALL not rewrite a value that does not look like a credential.
Scenario: prose word after password colon
- WHEN the input text contains "password: unexpected"
- THEN the output preserves "password: unexpected" unchanged
Requirement: Other secret patterns are unaffected
The fix SHALL not change the masking behavior of other secret patterns.
Scenario: GitHub token is still masked
- WHEN the input text contains "ghp_abc123def456ghi789jkl012"
- THEN the output replaces it with ""
Existing Tool Considered
No check has run. The fix is a bug fix in the project's own sanitizer. The project already has the _looks_like_a_credential heuristic in src/devops_cli/security/sanitizer.py. The fix applies that heuristic to the token|auth_token and password|passwd|pwd patterns. The written cost is changing two replacement lambdas and adding test cases.
Key questions
- How should the
token|auth_tokenpattern distinguish a prose word from a credential?: Apply the existing_looks_like_a_credentialcheck to the pattern's replacement. A value is a credential if it is 24 or more characters, contains a digit or a separator, or has an internal capital. A prose word like "unexpected" matches none of these and is left unchanged. (best practice) [sources: src/devops_cli/security/sanitizer.py]- Chosen: Apply
_looks_like_a_credentialto the pattern. The heuristic already exists in the codebase and is used by the last pattern in the list. It correctly distinguishes prose words from tokens. - Rejected: Add entropy calculation to the pattern. More complex than needed. The existing heuristic already handles the reported case and is simpler to test.
- Rejected: Increase the minimum value length in the regex. Would miss short but valid tokens that contain digits or separators. The heuristic is more precise.
- Chosen: Apply
- Should the
password|passwd|pwdpattern also be fixed?: Yes. It uses the same_mask_literalfunction and has the same false positive. The fix applies the same_looks_like_a_credentialcheck to both patterns. (best practice) [sources: src/devops_cli/security/sanitizer.py]- Chosen: Fix both patterns. They share the same replacement function and the same false positive. Fixing one without the other leaves the same bug.
- Rejected: Fix only the token pattern. The issue names the token pattern, but the password pattern has the same defect. Leaving it unfixed would require a second issue.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-04: none.
Tool: none found.
Activity
dan-petty commentedon Oct 29, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
A defect in existing security masking code that corrupts legitimate error text.It hides the cause of a failure in printed errors, which slows debugging, but does not expose secrets or break the tool.Users lose the real error message, which reduces their ability to diagnose buildx or registry failures.The fix is a constraint on one regex pattern, possibly adding an entropy or shape check already used by other rules.Both are false-positive bugs in the token keyword pattern in sanitizer.py, but #2450 is about a line-break in \s+ and the candidate is about the [:=] separator matching a colon in prose.devops-cli-service commentedon Oct 30, 2026
Status set to Ready at 07fb4c2 (see proposed design in issue body).
devops-cli-service commentedon Nov 4, 2026
Alternatives check: none
Tool: none found
Lacks:
Searches run:
Sources:
Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 5, 2026
Released in v0.62.5: https://github.com/dan-petty/devops-cli/releases/tag/v0.62.5
devops-cli-service commentedon Nov 5, 2026
Live since 2026-11-05 16:42 UTC