Skip to content

fix(requester): normalize hex-form IPv4-compatible IPv6 in isAddressRestricted - #1558

Open
tilak-patel-postman wants to merge 3 commits into
developfrom
security/ssrf-test-coverage
Open

fix(requester): normalize hex-form IPv4-compatible IPv6 in isAddressRestricted#1558
tilak-patel-postman wants to merge 3 commits into
developfrom
security/ssrf-test-coverage

Conversation

@tilak-patel-postman

Copy link
Copy Markdown
Contributor

What

isAddressRestricted() recognised IPv4-compatible IPv6 addresses only in their dotted form (::a.b.c.d). The equivalent hex form (e.g. ::7f00:1) is reported by ipaddr.js as a generic unicast address, so it was not reduced to its embedded IPv4 and therefore did not match a configured IPv4 restrictedAddresses entry the way the dotted form does — an inconsistency in address normalization.

Change

  • Normalize the hex form: when the first six hextet groups are zero and the seventh is non-zero, match on the embedded IPv4 (the last four bytes). ::1 (parts[6] === 0) and ordinary IPv6 addresses (parts[0] !== 0) are unaffected; the existing rfc6052/rfc6145/6to4 handling is unchanged. Teredo (2001::/32) is intentionally left as-is because it carries the relay server's address rather than the destination.
  • Broadens restrictedAddresses test coverage: additional special-use IPv4 ranges, alternate IPv4 literal encodings, more IPv6 ranges, and DNS/redirect resolution cases (multiple A records, AAAA, wildcard DNS, 0.0.0.0, redirect chains), plus a scoped integration runner for the restricted-addresses suite.

Tests

  • Unit (test/unit/requester-core.test.js): 122 passing
  • Integration (restricted-addresses): 32 passing

…estricted

isAddressRestricted() only recognised IPv4-compatible IPv6 addresses in their
dotted form (::a.b.c.d). The equivalent hex form (e.g. ::7f00:1) is reported by
ipaddr.js as a generic 'unicast' address, so it was not reduced to its embedded
IPv4 and therefore did not match a configured IPv4 restrictedAddresses entry the
way the dotted form does. Normalize it consistently: when the first six hextet
groups are zero and the seventh is non-zero, match on the embedded IPv4 (the last
four bytes). The parts[6] !== 0 guard leaves ::1 to the existing loopback/exact
handling and does not affect ordinary IPv6 addresses. The existing rfc6052/
rfc6145/6to4 handling is unchanged. Teredo (2001::/32) is left as-is because it
carries the relay server's address rather than the destination.

Also broadens restrictedAddresses test coverage: more special-use IPv4 ranges,
alternate IPv4 literal encodings, additional IPv6 ranges, and DNS/redirect
resolution cases (multiple A records, AAAA, wildcard DNS, 0.0.0.0, redirect
chains), plus a scoped integration runner for the restricted-addresses suite.
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.63%. Comparing base (681f020) to head (c0fb6dc).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1558      +/-   ##
===========================================
+ Coverage    77.54%   77.63%   +0.08%     
===========================================
  Files           51       51              
  Lines         4338     4350      +12     
  Branches      1223     1228       +5     
===========================================
+ Hits          3364     3377      +13     
  Misses         731      731              
+ Partials       243      242       -1     
Flag Coverage Δ
integration 68.78% <71.42%> (+0.06%) ⬆️
legacy 34.22% <0.00%> (-0.10%) ⬇️
unit 47.01% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants