Numeric ipv4 resolver bypass - #12827
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12827 +/- ##
==========================================
+ Coverage 98.94% 99.14% +0.20%
==========================================
Files 131 128 -3
Lines 47099 46539 -560
Branches 2435 2449 +14
==========================================
- Hits 46600 46142 -458
+ Misses 376 274 -102
Partials 123 123
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
|
Merging this PR will not alter performance
Comparing Footnotes
|
PR Review — Numeric ipv4 resolver bypassSolid, focused security fix. Merge-ready.
Checklist
Automated review by Kōan (Claude) |
Backport to 3.14: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply ccf218a on top of patchback/backports/3.14/ccf218ab8c319faf166aff4d4c04f969fed7e341/pr-12827 Backporting merged PR #12827 into master
🤖 @patchback |
Backport to 3.15: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply ccf218a on top of patchback/backports/3.15/ccf218ab8c319faf166aff4d4c04f969fed7e341/pr-12827 Backporting merged PR #12827 into master
🤖 @patchback |
What do these changes do?
is_ip_address()treats any digit-and-dot host as an IP literal, soTCPConnector._resolve_host()treated legacy numeric forms like2130706433,017700000001and127.1as IP literals and handed the raw string straight to the socket layer instead of the configured resolver.This adds
is_canonical_ipv4_address(), which accepts only a standard dotted-quad with four decimal octets in range and no leading zeros, cross-checked againstipaddress.IPv4Addressover a broad corpus._resolve_host()now treats only canonical IPv4 literals (and IPv6) as IP addresses; any other numeric form is rejected withInvalidUrlClientError, and every non-literal host goes through the configured resolver as before.Are there changes in behavior for the user?
A request to a non-canonical numeric IPv4 host now raises
InvalidUrlClientErrorinstead of being treated as an IP literal. Canonical dotted-quad addresses, IPv6 literals, and ordinary hostnames are unchanged.Is it a substantial burden for the maintainers to support this?
No.
Related issue number
N/A
Checklist
CONTRIBUTORS.txtN/A, already listedCHANGES/folder