Commit 86b9250
committed
bug symfony#59055 [HttpFoundation] Fixed
This PR was squashed before being merged into the 6.4 branch.
Discussion
----------
[HttpFoundation] Fixed `IpUtils::anonymize` exception when using IPv6 link-local addresses with RFC4007 scoping
| 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](https://datatracker.ietf.org/doc/html/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.
Commits
-------
1696353 [HttpFoundation] Fixed `IpUtils::anonymize` exception when using IPv6 link-local addresses with RFC4007 scopingIpUtils::anonymize exception when using IPv6 link-local addresses with RFC4007 scoping (jbtronics)File tree
2 files changed
+11
-0
lines changed- src/Symfony/Component/HttpFoundation
- Tests
2 files changed
+11
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
185 | 195 | | |
186 | 196 | | |
187 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
0 commit comments