php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #77221 Request IP address filter flag to exclude non-global IP addresses
Submitted: 2018-11-29 19:38 UTC Modified: 2021-08-10 11:54 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: dan dot franklin at fen dot com Assigned:
Status: Open Package: Filter related
PHP Version: Next Minor Version OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dan dot franklin at fen dot com
New email:
PHP Version: OS:

 

 [2018-11-29 19:38 UTC] dan dot franklin at fen dot com
Description:
------------
Currently, filter_var is able to filter out private IP addresses and those reserved by protocol with the FILTER_FLAG_NO_PRIV_RANGE and FILTER_FLAG_NO_RES_RANGE flags respectively.

There is a need for further filtering, to determine whether an IP address is Global, as described in RFC 6890.

Only global addresses are useful in identifying the country of origin; this new filter would enable PHP code to search through the list of addresses in an X-Forwarded-For header to find the first global address and send only that address to a country locator such as GeoIP.

Global addresses would also be useful for forensic purposes.

This request is for a new flag, perhaps called FILTER_FLAG_ONLY_GLOBAL_RANGE, that would filter out all IP address ranges listed as “Global: false” in RFC 6890.



Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-29 22:47 UTC] cmb@php.net
-Package: Network related +Package: filter
 [2018-11-29 22:47 UTC] cmb@php.net
Changing package to PECL/filter (“Filter related” is for stream filters).
 [2019-03-24 07:05 UTC] yutafuji2008 at gmail dot com
Hi, I read https://bugs.php.net/bug.php?id=77217 and came to this page.
I totally agree with what dan dot franklin says and want this flag, too!
Is someone working on this now, or can I make a PR on https://github.com/php/php-src ?
 [2021-08-10 11:54 UTC] cmb@php.net
-Package: filter +Package: Filter related
 [2021-08-10 11:54 UTC] cmb@php.net
Changing to "Filter related", since in practice that category
is used for ext/filter.

> Is someone working on this now, or can I make a PR on
> https://github.com/php/php-src ?

You're welcome to submit a pull request!
 [2022-01-06 10:23 UTC] vnsavage at gmail dot com
The following pull request has been associated:

Patch Name: Implement a filter that filters for Global IPs as per RFC 6890
On GitHub:  https://github.com/php/php-src/pull/7893
Patch:      https://github.com/php/php-src/pull/7893.patch
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 08:01:29 2024 UTC