Skip to content

fix(security): redact_text leaves the user name of a URL with no password, so a token used as the user name shows in text #2662

Closed

Description

@dan-petty

Problem Description

redact_text and mask_uri_credentials in src/devops_cli/security/sanitizer.py mask the userinfo of a URL only when it holds a password. _mask_url_candidate tests parts.password is not None. A URL whose userinfo is a user name alone is left as it is.

Some services take a token as the user name, with an empty password. httpx2 sends such a URL as Basic authentication, and a token can be in ai.ollama_urls. Then an error text that quotes the URL shows the token. A masked text with a password shows <masked-user>:<masked-password>, so the two cases differ.

The same line cannot tell a token from a harmless user name such as git in an SSH clone URL. A person must choose the rule. #2481 does not depend on the choice, because the benchmarks and the embedding engine now name a URL without its userinfo.

Reproduction Steps

  1. Run redact_text in Python on a text that quotes http://example.com:11434/api/embed with a fake token before the host, as a user name only.
  2. Run it again on the same text with a fake user name and a fake password before the host.
  3. Compare the two results.

Expected vs Actual Behavior

Expected: a person decides whether a user name alone is masked. The decision is written in the docs of the sanitizer and in its tests.

Actual: the text with a password shows <masked-user>:<masked-password>, and the text with a user name alone shows the user name.

Environment Diagnostics

  • DevOps CLI Version: 0.16.1 (origin/main 9f6ace18)
  • Python Version: 3.14.10
  • OS & Architecture: Linux x86_64 (WSL2)
  • Execution Environment: DevContainer

Logs, Traces, or Terminal Output

user name only:        the text comes back unchanged
user name and password: the userinfo shows as <masked-user>:<masked-password>

The redaction of intake refuses a literal URL with userinfo, so this report describes the two texts.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #2481

Proposed design

Problem statement

redact_text and mask_uri_credentials mask URL userinfo only when a password is present. A URL whose userinfo is a user name alone is left unchanged. Some services send a token as the user name with an empty password, so the token appears in masked text. The rule for masking a user name without a password is not stated in the docs or the tests.

Acceptance criteria

Requirement: Mask user-name-only userinfo in redact_text

redact_text SHALL mask the user name of a URL that has a user name but no password.

Scenario: URL with user name only

  • WHEN redact_text processes a text that contains a URL with a user name and no password
  • THEN the user name is replaced with a masked placeholder and the host and path are unchanged

Requirement: Mask user-name-only userinfo in mask_uri_credentials

mask_uri_credentials SHALL mask the user name of a URL that has a user name but no password.

Scenario: URI with user name only

  • WHEN mask_uri_credentials processes a URI with a user name and no password
  • THEN the user name is replaced with a masked placeholder and the scheme, host and path are unchanged

Requirement: Document the masking rule

The sanitizer module documentation SHALL state the rule for masking a user name without a password.

Scenario: Documentation states the rule

  • WHEN a reader consults the docstring or module doc of the sanitizer
  • THEN the rule for user-name-only masking is stated

Requirement: Test the user-name-only case

The test suite SHALL include a test that asserts a user name without a password is masked.

Scenario: Test covers user-name-only URL

  • WHEN the sanitizer test suite runs
  • THEN a test asserts that a URL with a user name and no password has its user name masked

Existing Tool Considered

No check has run. The project already maintains its own sanitizer in src/devops_cli/security/sanitizer.py. The fix changes one condition in _mask_url_candidate and one in mask_uri_credentials, and adds tests and a doc line. No open, maintained library provides this masking as a drop-in. The written cost is a few lines of condition change, a few test lines, and one doc sentence.

Key questions

  • Should a user name alone (no password) in a URL be masked?: Yes. Mask the user name. RFC 7235 treats the user-id as part of the credentials. The principle of least exposure says: when you cannot tell a token from a harmless name, mask it. The existing code already masks userinfo when a password is present, which shows the project treats userinfo as sensitive. The body states that a person must choose this rule. (a person decides) [sources: src/devops_cli/security/sanitizer.py:54]

Open questions

  • Should a user name alone (no password) in a URL be masked? (a person decides)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-04: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/security
    status/new
    value/medium
    effort/low
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

  3. added
    priority/p2-medium
    on Oct 29, 2026
  4. added
    type/bug
    scope/security
    and removed
    type/security
    on Oct 30, 2026
  5. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 46fd02d until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Should a user name alone (no password) in a URL be masked? (a person decides)
  6. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Tool: none found

    Lacks:

    • No maintained library scans arbitrary text for URLs and masks a user-name-only userinfo with a placeholder while leaving scheme, host and path unchanged; the rule and the _mask_url_candidate condition stay in the project's own sanitizer.
    • General redaction libraries mask by user-supplied regex or dictionary key (loggingredactor) or by PII patterns over data structures (sanitary), so they do not supply the URL userinfo policy or the `` placeholder format.
    • PII tooling such as Presidio does not detect API keys or bearer tokens, so a token used as a URL user name is not covered.
    • Library URL redaction such as urlps applies only to URLs inside its own client callback layer, not to redact_text / mask_uri_credentials over free text.
    • The documented rule and the sanitizer test for the user-name-only case are project-specific and have no library equivalent.

    Searches run:

    • python library redact credentials from URLs in text log messages
    • pypi package sanitize url userinfo username password masking
    • python package mask url credentials in strings "userinfo" redact username
    • pypi "redact" library mask credentials URLs in arbitrary text python scrub
    • sanitize-url python pypi strip authentication userinfo
    • python library find URLs in text and redact username password placeholder masked-user
    • scrubadub presidio URL credential redaction userinfo not supported
    • urlps python package redacted URL userinfo bare token masked query values
    • python library redact secrets tokens from arbitrary text strings maintained package

    Sources:

    Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 5, 2026
  8. removed
    status/in-review
    on Nov 5, 2026
  9. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor
  10. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-05 19:48 UTC

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

    effort/lowpriority/p2-mediumscope/securitysource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions