Skip to content

fix(security): mask_secrets masks every GitHub token prefix, ghu_, ghs_ and ghr_ included #1398

Closed

Description

@dan-petty

Problem

mask_secrets (src/devops_cli/security/sanitizer.py:151) masks GitHub tokens with the prefixes ghp_, gho_ and github_pat_, and credentials inside URLs. It does not mask the other prefixes GitHub documents: ghu_ (user-to-server), ghs_ (server-to-server, such as a GitHub App installation token) and ghr_ (refresh). Found during #1124's review on 2026-10-08: a ghs_ token in a pre-receive hook's message would be printed unmasked in the release command's error output.

Acceptance criteria

  • mask_secrets masks every GitHub token prefix GitHub documents (ghp_, gho_, ghu_, ghs_, ghr_, github_pat_), each with its documented minimum length, in one pattern.
  • A parametrized test masks a sample of each prefix inside surrounding text and leaves a near-miss (a shorter body, or the prefix inside a longer word) unmasked.
  • Each test call phase stays under 1 s and uv run devops ci passes; changelog.d/<n>.md records the change under ### Security.

Strategic alignment


Found on 2026-10-08 while delivering #1124. Filed directly with no priority; the roadmap service's intake sets Priority, Value and Effort.

Activity

  1. added
    type/security
    scope/security
    source/agent
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P1-High. A real token (e.g. a ghs_ GitHub App installation token) can be printed unmasked in error output, which is a direct credential-exposure risk.
    • Value: High. Prevents live GitHub tokens from leaking into logs, error messages, or LLM-bound text, protecting users' credentials.
    • Effort: Low. The fix is adding three prefixes to an existing regex pattern plus a parametrized test; the acceptance criteria are fully specified.
  3. added this to the v0.2.30 milestone on Oct 8, 2026
  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.30 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: P1 secret and sandbox-boundary fixes, the review tools lock, kube-linter finding identity and a faster gate. Position 1 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  5. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1464, merged into release/v0.2.30 as a3bb370.

    Summary

    mask_secrets now masks every GitHub token prefix in one pattern: ghp_, gho_, ghu_, ghs_, ghr_ and github_pat_. That includes the new ghs_APPID_JWT installation tokens, which run to about 520 characters, contain dots, and include Actions' GITHUB_TOKEN. #1124's review found that a ghs_ token in a pre-receive hook's message would have reached the release command's error output unmasked.

    8 file(s) changed.

    How it was verified

    Check runs at 6c79be1:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1398-mask-every-github-token-prefix.md:

    • mask_secrets masks every prefix GitHub documents (ghp_, gho_, ghu_, ghs_, ghr_, github_pat_) in one pattern, each with the minimum length above. test_every_github_token_prefix_is_masked_whole masks a sample of each prefix, plus a ghs_APPID_JWT installation token, inside remote: ... rejected. It compares the whole line, which proves no part of a token is printed.
    • A parametrized test masks each sample inside surrounding text (test_every_github_token_prefix_is_masked_whole). test_a_near_miss_github_token_is_left_alone leaves seven near-misses unchanged: a short body for ghu_, ghs_ and github_pat_, a prefix after a letter (xghr_...), and three snake_case names with _ghu_, _ghr_ and _ghs_ whose tails pass each minimum. The samples are built in code, so the test source holds no literal token. The ghs_APPID_JWT sample is built once, in tests/github_token_samples.py, which both test files import.
    • sanitize_diff_output masks a whole ghs_APPID_JWT token (test_sanitize_diff_output_masks_a_whole_installation_token), and test_sanitize_diff_output_secrets still passes.
    • Each new test's call phase stays under 1 s, and uv run devops ci passes. changelog.d/1398.md records the change under ### Security, and CHANGELOG.md and docs/ROADMAP.md are untouched.
  6. added a commit that references this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope/securitysource/agenttype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions