Skip to content

[HttpFoundation] Fixed IpUtils::anonymize exception when using IPv6 link-local addresses with RFC4007 scoping #59055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

jbtronics
Copy link
Contributor

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues See below
License MIT

When accessing a web server via an IPv6 link-local address, it is possible to get a REMOTE_ADDR like fe80::1fc4:15d8:78db:2319%enp4s0, which is then subsequently also returned by Request::getClientIp().
This % suffix is IPv6 scoping according to RFC4007, as the link-local addresses are network interface dependent, and are important to uniquely identify a device in the network.

PHP and Symfony Request consider this format valid (or at least do not touch it). However, IPUtils::anonymize break when getting such a (valid) IP and throws an exception as the inet_ntop function cannot handle that format and returns false.

This PR fixes that by just stripping away the scoping suffix, before passing the IP to that function. I think the interface information is not important on the anonymized IP (as we want to lose the uniqueness anyway) and it might contain the interface name, which one could consider as somewhat sensitive information, that should not be leaked to end users.

@carsonbot carsonbot added this to the 6.4 milestone Dec 1, 2024
@carsonbot carsonbot changed the title Fixed IPUtils::anonymize exception when using IPv6 link-local addresses with RFC4007 scoping [HttpFoundation] Fixed IPUtils::anonymize exception when using IPv6 link-local addresses with RFC4007 scoping Dec 2, 2024
@OskarStark OskarStark changed the title [HttpFoundation] Fixed IPUtils::anonymize exception when using IPv6 link-local addresses with RFC4007 scoping [HttpFoundation] Fixed IpUtils::anonymize exception when using IPv6 link-local addresses with RFC4007 scoping Dec 2, 2024
@jbtronics jbtronics force-pushed the rfc4007_ip_anonymize_fix branch from 64d99aa to 558b4f8 Compare December 2, 2024 13:16
@nicolas-grekas
Copy link
Member

Thank you @jbtronics.

@nicolas-grekas nicolas-grekas force-pushed the rfc4007_ip_anonymize_fix branch from 558b4f8 to 1696353 Compare January 7, 2025 16:56
@nicolas-grekas nicolas-grekas merged commit 86b9250 into symfony:6.4 Jan 7, 2025
1 check passed
This was referenced Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants