Skip to content

feat: strip authentication secrets from private index/download URL #646

Closed

Description

@fkleon

Version 4.0.0 includes additional metadata in the SBOM, one of which is the package url.

When using cyclonedx-py with the --index-url parameter, the index URL ends up in the component metadata section of the SBOM (this happen with version v4.0.0-rc.4)

This can be an issue if a private PyPI registry URL is used that contains authentication credentials, e.g. the GitLab PyPi repository, where the URL looks like:

https://<personal_access_token_name>:<personal_access_token>@gitlab.example.com/api/v4/projects/<project_id>/packages/pypi/simple

The URL should probably be sanitised first to strip the authentication part; or at least a warning printed for the user?

Activity

  1. jkowalleck commented on Jan 9, 2024

    @jkowalleck
    Member

    caused by #605

  2. added this to the 4.0.0 milestone on Jan 9, 2024
  3. jkowalleck commented on Jan 9, 2024

    @jkowalleck
    Member

    Thanks for testing the v4.0.0-rc.4.

    A possible solution could be, to replace the password with *****? Would this be sufficient, @fkleon ?


    the mentioned issue affects the following:

    • all (extra) index urls for
      • pipenv
      • requirements
      • poetry
    • all direct download urls for
      • pyproject.toml
      • environment
      • pipenv
      • requirements
      • poetry
    • all external refererences for
      • pyproject.toml
      • environment
      • pipenv
      • requirements
      • poetry
  4. added
    enhancement
    on Jan 9, 2024
  5. changed the title [-]Component metadata: implicit dist url may contain private index URL with authentication secrets[/-] [+]feat: url may contain private index URL with authentication secrets[/+] on Jan 9, 2024
  6. fkleon commented on Jan 9, 2024

    @fkleon
    Author

    HI @jkowalleck! Masking the password is sufficient to avoid accidentally leaking the credentials.

    However I'm not sure what the primary purpose of the url field is. If those URLs should be comparable across SBOM versions it's probably best to fully strip the credentials (e.g. when running in CI the username/password might be different every time).

    So that a given URL: https://gitlab-ci:[email protected]/api/v4/projects/some-project/packages/pypi/simple
    Would be normalised to: https://gitlab.example.com/api/v4/projects/some-project/packages/pypi/simple

  7. self-assigned this
    on Jan 9, 2024
  8. jkowalleck commented on Jan 9, 2024

    @jkowalleck
    Member

    So that a given URL: https://gitlab-ci:[email protected]/api/v4/projects/some-project/packages/pypi/simple
    Would be normalised to: https://gitlab.example.com/api/v4/projects/some-project/packages/pypi/simple

    will go with this solution , in accordance with PEP 610. implementation in progress #647

  9. changed the title [-]feat: url may contain private index URL with authentication secrets[/-] [+]feat: strip authentication secrets from private index/download URL[/+] on Jan 10, 2024
  10. jkowalleck commented on Jan 10, 2024

    @jkowalleck
    Member

    a fix was published in version 4.0.0rc5.

    Could you test it, @fkleon ?

  11. fkleon commented on Jan 10, 2024

    @fkleon
    Author

    Thanks for the quick turnaround. Seems to be working nicely now with rc5.

    Just wanting to say that the rest of 4.0.0 also looks really good, it's great having the additional metadata (e.g. licenses) and the dependency tree included in the SBOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions