v2.0.4: backport v3.0.1/v3.1.0 security hardening to 2.x - #12
Merged
Conversation
Backports for v2.0.4: - Host::tld(): replace dynamic-regex suffix removal (only '.' was escaped) with str_ends_with/substr string operations. - HostParser: detect schemes with an anchored RFC 3986 pattern instead of strpos substring matching; URLs carrying http:// in path/query are no longer mis-classified, and non-http/https schemes now throw InvalidArgumentException instead of mis-parsing (ftp://a.com used to yield the host 'ftp'). - Validator: implement Public Suffix List wildcard (*) and exception (!) rule handling; the prevailing rule is the exception rule if any, otherwise the longest match. - Validator::checkIfIsPrivate(): replace substring matching (which could mark unrelated hosts as private) with label-wise suffix matching, including wildcard and exception rules. - Tests: port SecurityTest and WildcardExceptionTest regression coverage from 3.x. - SECURITY.md: document affected versions.
adrorocker
force-pushed
the
security/2.x-backport
branch
from
August 14, 2026 17:11
eedcedb to
1acadb9
Compare
php-actions/composer@v6 runs composer inside its own container (PHP 8.5), ignoring the version selected by shivammathur/setup-php. The Pest 2 dependency stack cannot resolve on PHP 8.5, so every matrix job failed during install. Run composer directly on the runner instead, where the matrix PHP is active. Also bumps actions/checkout to v4.
var-dumper ^7.0 requires PHP >=8.2, contradicting this branch's ^8.1.0 support. The old CI never caught it because the composer action resolved dependencies with its container's newer PHP.
… resolution Composer's advisory blocking refuses every phpunit <=10.5.61, while every Pest 2.x release hard-caps phpunit inside that range via its conflict rules — making the Pest 2 dev stack unresolvable on any PHP version, and PHP 8.1 in particular. The advisory affects the test runner only (dev dependency, never shipped); ignoring this single ID lets the solver pick pest 2.36.0 + phpunit 10.5.36 + paratest 7.3.1 on PHP 8.1 and newer sets elsewhere.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of the v3.0.1 and v3.1.0 (#11) security fixes to the 2.x maintenance branch, ported to its flat-list structure —
Validator's constructor signature andPublicSuffixListParser::parse()output are unchanged, so 2.x BC is intact.Fixes
Host::tld(): dynamic-regex suffix removal (only.escaped → PCRE metacharacter injection, compile errors, small ReDoS surface) replaced withstr_ends_with/substr.HostParser:strpossubstring scheme detection replaced with an anchored RFC 3986 pattern — URLs carryinghttp://in path/query no longer mis-parse, and non-http/https schemes throwInvalidArgumentExceptioninstead of yielding a bogus host (ftp://a.com→ hostftp).*) and exception (!) rules now handled per the PSL algorithm (exception prevails, otherwise longest match).checkIfIsPrivate()(2.x-only defect):strpossubstring matching could mark unrelated hosts as private; replaced with label-wise suffix matching, wildcard- and exception-aware.Tests
SecurityTestandWildcardExceptionTestported from 3.x. 33 → 56 tests; pest, phpstan and phpcs all green.SECURITY.md marks v2.0.0–v2.0.3 as insecure and points to v2.0.4.