Skip to content

fix(security): secret masking leaves code-like credential values unmasked #662

Closed

Description

@dan-petty

Summary

Found in the release/v0.2.23 review (line numbers at 7fdaa9d).

The new "code value" exemption in mask_secrets leaves some credentials unmasked. Running the pattern table directly, each of these passes through verbatim, and main masked all of them:

  • password: hunter2(x)y
  • password=Xk9{mP2[qL7z
  • password: correct.horse.battery
  • token=Ab3dEf[gh]Ij9kLmN
  • --password=Pa(ss)word1!

mask_secrets scrubs several kinds of text:

  • review diffs before they are sent to the LLM provider (src/devops_cli/ai/review/sanitization.py:27);
  • sandbox output;
  • agent memory;
  • span error samples.

Root Cause

_CODE_VALUE (src/devops_cli/security/sanitizer.py:52) treats any value containing (, [ or {, or any dotted-word value, as code. _mask_literal (:55-63, applied at :73-79 and :96-100) then leaves such unquoted password/token assignments unmasked. The regression test (tests/test_review_finding_losses.py:281-296) covers only real code expressions.

Remediation Plan

  1. Narrow the exemption to values shaped like code: a dotted identifier path followed by a call or index expression, where the bracket group closes at the end of the value or is cut off at a quote (e.g. hashlib.md5(pw).hexdigest(), os.environ[). A leaked secret is worse than a hidden code smell, so plain dotted paths stay masked.
  2. Add the five values above as regression tests, keeping the existing code-expression tests green.

Activity

  1. added this to the v0.2.23 milestone on Sep 28, 2026
  2. added
    type/security
    scope/security
    priority/p1-high
    on Sep 28, 2026
  3. dan-petty commented on Sep 28, 2026

    @dan-petty
    OwnerAuthor

    Closed by #676, merged into release/v0.2.23.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

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

    priority/p1-highscope/securitytype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions