Skip to content

Bound SemVer input length - #24100

Merged
andrew merged 1 commit into
mainfrom
semver-input-limit
Sep 26, 2026
Merged

andrew merged 1 commit into
mainfrom
semver-input-limit

Conversation

@andrew

@andrew andrew commented Sep 26, 2026

Copy link
Copy Markdown
Member

Vulns::Semver parses version strings from remote advisory data without a size limit. Large strings reach regex matching, integer conversion and prerelease splitting.

Reject inputs over 256 bytes before normalisation or parsing. Oversized versions return nil, as invalid versions already do, so the advisory matcher retains the OSV match without reporting a local fix. Cover the limit boundary, oversized numeric components, build metadata and whitespace, plus advisory matching.

From the repository root, run:

./bin/brew ruby -- -e 'require "vulns/semver"; p Homebrew::Vulns::Semver.compare("1.0.0-" + "a" * 5000, "1.0.0")'

This prints -1 before the change and nil after it. The limit also applies to release_version.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

OpenAI Codex (GPT-6) assisted with the implementation and tests.


Copilot AI lite review requested due to automatic review settings September 26, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 26, 2026
@andrew
andrew added this pull request to the merge queue Sep 26, 2026
Merged via the queue into main with commit e5d5d7d Sep 26, 2026
51 checks passed
@andrew
andrew deleted the semver-input-limit branch September 26, 2026 14:51
@doktorszarlatan

doktorszarlatan commented Sep 26, 2026 via email

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants