Skip to content

elixir_security_importer_v2 strips '~>' in patched_versions into '!=', marking patched Hex releases as affected #2529

Backlog

Description

@trackoor

When importing Elixir advisories whose patched_versions use the ~> pessimistic version operator (4 of the 10 imported advisories: plug/2017-02-28, plug/2017-02-28_2, plug/2017-04-17, and phoenix/2017-03-14), elixir_security_importer_v2 converts each ~> X.Y.Z entry into !=X.Y.Z, causing unfurl_version_range_v2 to mark subsequent patched Hex releases on those minor branches as affected.

Reproduction

From a migrated vulnerablecode checkout:

python manage.py import elixir_security_importer_v2
python manage.py improve unfurl_version_range_v2
python manage.py shell -c '
from vulnerabilities.models import AdvisoryV2
imp = AdvisoryV2.objects.get(advisory_id="plug/2017-02-28").impacted_packages.get()
print("affecting_vers:", imp.affecting_vers)
print("fixed_by:", sorted(p.version for p in imp.fixed_by_packages.all()))
print("affected 1.2.x:", sorted(p.version for p in imp.affecting_packages.all() if p.version.startswith("1.2.")))
'

Actual vs Expected

Actual output:

affecting_vers: vers:hex/!=1.0.4|!=1.1.7|!=1.2.3|<1.3.2
fixed_by: ['1.0.4', '1.1.7', '1.2.3']
affected 1.2.x: ['1.2.0', '1.2.0-rc.0', '1.2.1', '1.2.2', '1.2.4', '1.2.5', '1.2.6']

Expected: plug/2017-02-28 (CVE-2017-1000052) declares patched_versions: ['>= 1.3.2', '~> 1.2.3', '~> 1.1.7', '~> 1.0.4']. Under Elixir Version requirement rules, ~> 1.2.3 matches >= 1.2.3 and < 1.3.0 (and similarly [1.1.7, 1.2.0) and [1.0.4, 1.1.0)), so affecting_vers should be vers:hex/<1.0.4|>=1.1.0|<1.1.7|>=1.2.0|<1.2.3|>=1.3.0|<1.3.2, and patched plug releases 1.2.4, 1.2.5, and 1.2.6 (along with 1.0.5, 1.0.6, 1.1.8, and 1.1.9) should not be marked as affected.

Versions

  • vulnerablecode: v40.2.0 (910df628cf485e8d58c61b0a7c8c1a64b0964a14) and main (9a9c9b3e8ff7d173bf8d2d04b4587c445a6d96b3)
  • univers: 32.0.1
  • Python: 3.12.16

Root Cause

In vulnerabilities/pipelines/v2_importers/elixir_security_importer.py (lines 115-119), ElixirSecurityImporterPipeline.process_file strips "~>" with version = version[2:] before calling VersionConstraint.from_string(...).invert(), turning "~> 1.2.3" into "!=1.2.3" instead of inverting the pessimistic range >= 1.2.3, < 1.3.0.

Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.

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

Activity

  1. Gowri213 commented on Nov 25, 2026

    @Gowri213

    Hi! I'd like to work on fixing this in elixir_security_importer.py and adding regression tests for pessimistic (~>) version requirements.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions