Skip to content

IPMatcher: Strip IPv6 zone - #358

Open
hansott wants to merge 1 commit into
ip-matcherfrom
ipv6-zones
Open

IPMatcher: Strip IPv6 zone#358
hansott wants to merge 1 commit into
ip-matcherfrom
ipv6-zones

Conversation

@hansott

@hansott hansott commented Sep 9, 2026

Copy link
Copy Markdown
Member

No description provided.

@hansott
hansott added this pull request to stack #359 September 9, 2026 20:48
Comment on lines 801 to 813
if (start == end) {
return false;
}
int zoneSeparator = indexOf(value, '%', start, end);
if (zoneSeparator >= 0) {
if (zoneSeparator == end - 1) {
return false;
}
end = zoneSeparator;
}
if (end - start == 2 && value.charAt(start) == ':' && value.charAt(start + 1) == ':') {
return true;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low - IPv6 zone stripping accepts malformed addresses with no address before %

The new zone handling truncates end after checking start == end, so an input such as %eth0:: or [%eth0::] leaves an empty address portion and then parseIPv6 returns success through the no-compression path, producing the all-zero address. IPMatcher.matches consequently treats this malformed string as ::, so an IP allowlist or other IP list containing ::/128 (or a broader IPv6 range) can accept a non-IP value; the private-IP detector instead fails closed by classifying it as private. The same first-percent truncation also silently accepts additional zone separators and malformed text after an incomplete address.

Show fix
Suggested change
if (start == end) {
return false;
}
int zoneSeparator = indexOf(value, '%', start, end);
if (zoneSeparator >= 0) {
if (zoneSeparator == end - 1) {
return false;
}
end = zoneSeparator;
}
if (end - start == 2 && value.charAt(start) == ':' && value.charAt(start + 1) == ':') {
return true;
}
int zoneSeparator = indexOf(value, '%', start, end);
if (zoneSeparator >= 0) {
if (zoneSeparator == start || zoneSeparator == end - 1) {
return false;
}
if (indexOf(value, '%', zoneSeparator + 1, end) >= 0) {
return false;
}
end = zoneSeparator;
}
if (start == end) {
return false;
}
if (end - start == 2 && value.charAt(start) == ':' && value.charAt(start + 1) == ':') {

More info - Reply on this comment to give feedback or ignore the issue.

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant