Skip to content

[BUG] Single-token URL credentials without a colon are not stripped from SBOM URLs #1150

Done

Description

@trackoor

Describe the bug

When generating an SBOM from requirements, poetry, or pipenv inputs, cyclonedx-py strips user:password@ credentials from index, VCS, and download URLs (added in #646 / #647), but leaves single-token userinfo (https://<token>@..., with no :) unredacted in externalReferences, purl qualifiers, and description. Single-part token URLs without a password or colon are documented in pip's authentication guide (https://[email protected]/simple) and are also standard for HTTPS Git PAT URLs (git+https://<token>@github.com/org/repo.git).

By contrast, pip strips single-token userinfo when recording PEP 610 direct_url.json, so cyclonedx-py environment omits the token while cyclonedx-py requirements (and poetry / pipenv) retains it.

To Reproduce

  1. Create requirements.txt:
--index-url https://[email protected]/simple/
requests==2.32.3
six @ git+https://[email protected]/benjaminp/[email protected]
  1. Run:
cyclonedx-py requirements requirements.txt --output-reproducible

Expected behavior

Single-token HTTP/HTTPS credentials are stripped from emitted URLs, PURLs, and descriptions just like user:password@ credentials:

  • https://pypi.company.com/simple/requests/
  • requirements line 3: six @ git+https://github.com/benjaminp/[email protected]
  • git+https://github.com/benjaminp/[email protected]
  • pkg:pypi/six?vcs_url=git%2Bhttps://github.com/benjaminp/six.git%401.16.0

Screenshots or output-paste

Actual output (components section):

  "components": [
    {
      "bom-ref": "requirements-L2",
      "description": "requirements line 2: requests==2.32.3",
      "externalReferences": [
        {
          "comment": "implicit dist url",
          "type": "distribution",
          "url": "https://[email protected]/simple/requests/"
        }
      ],
      "name": "requests",
      "purl": "pkg:pypi/[email protected]",
      "type": "library",
      "version": "2.32.3"
    },
    {
      "bom-ref": "requirements-L3",
      "description": "requirements line 3: six @ git+https://[email protected]/benjaminp/[email protected]",
      "externalReferences": [
        {
          "comment": "explicit dist url",
          "type": "vcs",
          "url": "git+https://[email protected]/benjaminp/[email protected]"
        }
      ],
      "name": "six",
      "purl": "pkg:pypi/six?vcs_url=git%2Bhttps://ghp_0123456789abcdef%40github.com/benjaminp/six.git%401.16.0",
      "type": "library"
    }
  ],

Environment

  • cyclonedx-py version: 9.0.0 (PyPI cyclonedx-bom==9.0.0) and main (087a93338905b6c3b4169cb8c35721b442c23ae4)
  • Python version: Python 3.11.2
  • OS: Debian GNU/Linux 12 (bookworm), x86_64

Additional context

In cyclonedx_py/_internal/utils/secret.py, _URL_AUTH_MATCHER = re_compile(r'(?<=://)[^/@:]+:[^/@]+@') requires a : in the userinfo segment, so token@host never matches (note that PEP 610 exempts ${ENV_VAR} placeholders and git@ in SSH VCS URLs such as ssh://[email protected]/...).

Contribution

  • I am willing to provide a fix
  • I will wait until somebody else fixes it

Credit: https://ucsbplse.github.io/

Activity

  1. added
    bug
    help wanted
    on Nov 25, 2026
  2. jkowalleck commented on Nov 25, 2026

    @jkowalleck
    Member

    thanks for the report.

    Ticket seams pretty clear and properly scoped - ready to be picked up by anybody interested in contributing.

  3. jkowalleck commented on Nov 30, 2026

    @jkowalleck
    Member
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

    buggood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions