Bug 1484034

Summary: glibc: Stricter IPv6 address parser
Product: Red Hat Enterprise Linux 7 Reporter: Florian Weimer <fweimer>
Component: glibcAssignee: Florian Weimer <fweimer>
Status: CLOSED ERRATA QA Contact: Sergey Kolosov <skolosov>
Severity: unspecified Docs Contact: Vladimír Slávik <vslavik>
Priority: unspecified    
Version: 7.5CC: ashankar, codonell, fweimer, mnewsome, pfrankli, skolosov, vslavik
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.17-202.el7 Doc Type: Bug Fix
Doc Text:
Invalid IPv6 scope IDs no longer incorrectly accepted by `getaddrinfo()` Previously, the GNU C Library ( *glibc* ) function `getaddrinfo()` erroneously accepted invalid IPv6 scope IDs. As a consequence, strings such as `::%-1` or `2001:db8::1%037777777777` were incorrectly parsed as valid IPv6 addresses. The `getaddrinfo()` implementation has been changed to reject such invalid IPv6 scope IDs and return a name resolution failure instead. As a result, such invalid IPv6 address strings are no longer accepted by applications using the `getaddrinfo()` function.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 14:00:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 677316    

Description Florian Weimer 2017-08-22 13:34:11 UTC
Currently, glibc accepts invalid IPv6 addresses, such as:

::%
::%-1
2001:db8::1%037777777777
2001:db8::00001

This is because invalid scope IDs and leading zeros in the address are not rejected.

This has been fixed upstream as part of bug 20611 and 16637.

Comment 1 Florian Weimer 2017-09-27 09:55:22 UTC
I think the change in parsing scope IDs carries very little risk and we should implement it.

I'm still undecided about the leading zeros change.  Many implementations reject such officially invalid IPv6 addresses: NSPR, various Perl, JQuery and Apache Commons validators, and the ip4r extension for PostgreSQL.

However, OpenJDK accepts them because their Java implementation is derived from the same inet_pton6 function originally found in BIND 4.9.4 (so it has the same bug).

ip6tables uses the glibc parser as well, so the change could cause ip6tables to reject invalid IPv6 addresses with an error message which would have previously been accepted.

Comment 2 Carlos O'Donell 2017-09-27 20:31:58 UTC
(In reply to Florian Weimer from comment #1)
> I think the change in parsing scope IDs carries very little risk and we
> should implement it.
> 
> I'm still undecided about the leading zeros change.  Many implementations
> reject such officially invalid IPv6 addresses: NSPR, various Perl, JQuery
> and Apache Commons validators, and the ip4r extension for PostgreSQL.
> 
> However, OpenJDK accepts them because their Java implementation is derived
> from the same inet_pton6 function originally found in BIND 4.9.4 (so it has
> the same bug).
> 
> ip6tables uses the glibc parser as well, so the change could cause ip6tables
> to reject invalid IPv6 addresses with an error message which would have
> previously been accepted.

Without enough data I think we should lean towards being liberal in what we accept.

Eventually the upstream parser, as it is, will enter the next major release of RHEL, where expectations can be set more clearly about the strictness of the parser.

Comment 3 Florian Weimer 2017-09-29 16:16:37 UTC
(In reply to Carlos O'Donell from comment #2)
> Without enough data I think we should lean towards being liberal in what we
> accept.

Agreed.  With the version I intend to commit, 2001:db8::00001 is accepted, but 2001:db8::1%037777777777 is rejected.  I think this is a reasonable compromise.

Comment 18 errata-xmlrpc 2018-04-10 14:00:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0805