Skip to content

fix(security): keep prose after a token colon unmasked - #3639

Merged
dan-petty merged 5 commits into
mainfrom
fix/2613-prose-after-a-token-colon
Nov 5, 2026
Merged

dan-petty merged 5 commits into
mainfrom
fix/2613-prose-after-a-token-colon

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The output masking rewrote a plain word after token: or password:. buildx writes "failed to fetch oauth token: unexpected status ...", and the printed error lost the word "unexpected". After a colon, _mask_literal now leaves an unquoted value as written when it reads as a plain word. A credential, a quoted value and a value after = or := stay masked, as on main. The check reuses _looks_like_a_credential, so no new heuristic exists.

Closes #2613

Change: openspec/changes/archive/2026-11-05-2613-prose-after-a-token-colon/

The token and password rules masked any value of 8 or more characters after a colon, so the buildx error 'failed to fetch oauth token: unexpected status ...' printed as 'token=<masked-token> status ...'. After a colon, an unquoted value that reads as a word is now left as written. An equals sign and a quote mark still mask the value.
Plans the change folder of issue 2613: the proposal with its feasibility check, the design, the secret-masking spec delta and the tasks.
A value that starts with an equals sign, as in token:=word or token: =word, is an assignment. The colon rule left it as written. The check now masks it, as on main.
Add the assignment requirement and modify the syntax-aware requirement. Correct the pattern-set claim, group kind and sentence length.
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault labels Nov 5, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results

Fail-to-pass (uv run devops ci fail-to-pass --base origin/main): 10 failed on base (10 failed and 224 passed in tests/security/test_secret_redaction.py; 0 errored). The 10 cases are the prose cases of test_a_prose_word_after_a_credential_keyword_and_a_colon_is_left_alone: five texts, each in data and code syntax. The masked cases pass on the base and on the branch. This is the intended result: they prove that the change does not lower the masking.

Narrow tests: uv run devops ci test tests/security/test_secret_redaction.py tests/security/test_redaction_properties.py tests/review/test_review_syntax_masking.py tests/ai/test_review_finding_losses.py gives 297 passed.

Full gate (uv run devops ci, one run on the final code): every gate passes (ruff, mypy, bandit, deptry, openspec validation, docs, test tree and the others). Coverage is 94.52%, and 85% is required. The gate pytest & coverage reports 10 failed, 18777 passed, 1 error. None of the failures comes from this change:

  • Four tests and one contract case read the state of this host. They fail in the same way on a clean origin/main worktree (4 failed, 183 passed, 1 error). Open issue fix(ci): host state fails four tests and one case #3585 holds them (test_get_ssh_key_prefix_resolution, test_find_project_config_path_skips_directory, test_mark_only_commands_under_global_dry_run and the [direct] case of test_tool_executor_contract).
  • Six cases of tests/ai/rag/test_rag_qdrant_span.py fail only in a checkout whose branch name holds token. The tracer adds the branch name to the span attributes, and the test reads the name as a leak. They pass on a detached head, which is what a pull request check uses. The cause is a test defect, filed as a separate issue.

Review findings

  1. := unmasked the value (major). Confirmed and fixed. password:=correcthorse gave password=<masked-password> on origin/main and password:=correcthorse on the first commit. The fix in the review (the group (?P<sep>:=|[:=])) is not enough. I ran it. token:=abcdefg (a 7-character value) and token: =correcthorse (a space) still come back unmasked, because the regex backtracks and gives the colon to sep. So _mask_literal now leaves a value that starts with = masked. All forms match origin/main. Tests for password:=correcthorse, token:=abcdefghijkl, token:=abcdefg and token: =correcthorse are in the masked cases.
  2. The delta only ADDED a requirement (minor). Confirmed and fixed. The delta now modifies "Syntax-aware secret masking": the scenario "Default masking syntax" no longer says "unconditionally masked", and the requirement names the colon exception. The Risks bullet of design.md is corrected. The assignment rule is its own requirement, because the validator limits one requirement to 500 characters.
  3. "The last rule of the pattern set" is false (minor). Confirmed and fixed in proposal.md and design.md: it now says "the rule of the space-separated form".
  4. Group 1 has no kind (minor). Confirmed and fixed. parse_task_groups now gives is_behavior=True for group 1 (Kind: behavior. and a first verification that ends with fails on the base). The tuicr bullet is under ## Workflow follow-up.
  5. Sentences longer than 25 words (minor). Confirmed and fixed in the proposal, the design, the tasks, the spec and the docstring of _mask_literal. A script that counts the words of each sentence finds none above 25.

@dan-petty

Copy link
Copy Markdown
Owner Author

Filed as #3638: six cases of test_rag_qdrant_span.py fail on a branch name that holds token.

@dan-petty
dan-petty marked this pull request as ready for review November 5, 2026 15:46
@dan-petty
dan-petty merged commit 73eff22 into main Nov 5, 2026
35 of 38 checks passed
@dan-petty
dan-petty deleted the fix/2613-prose-after-a-token-colon branch November 5, 2026 15:49
dan-petty pushed a commit that referenced this pull request Nov 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.62.5](v0.62.4...v0.62.5)
(2026-11-05)


### Bug Fixes

* **security:** keep prose after a token colon unmasked
([#3639](#3639))
([73eff22](73eff22))


### Performance Improvements

* **roadmap:** read the default tree once per run
([#3636](#3636))
([2db71f2](2db71f2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): output masking reads the prose 'token: <word>' as a secret and rewrites error text

1 participant