matomo-org / component-network Goto Github PK
View Code? Open in Web Editor NEWNetwork component: manipulate IP addresses (ipv4, ipv6) in PHP used in the Matomo project
License: GNU Lesser General Public License v3.0
Network component: manipulate IP addresses (ipv4, ipv6) in PHP used in the Matomo project
License: GNU Lesser General Public License v3.0
This was reported by email by a security researcher:
As described by another security researcher here, http://zoczus.blogspot.sg/2014/05/how-reverse-dns-can-help-us-with-xss.html, an attacker will need to be in control of an IP address where he can set the RDNS hostname to return JS script tags. After that, the attacker tunnels his traffic through that IP address and visits the target site. The getHostname() function will then resolve the IP address and obtain the JS code. Since it is not sanitized, any function which directly stores or displays the hostname will be susceptible to XSS.
The idea is to prevent the function from returning a special string which would trigger an XSS attack, for example <script>alert("1");</script>
According to RFC1123, valid hostnames can consist of only letters, digits and hyphens. Hence, valid RDNS names should only consist of letter, digits, hyphens and dots. It should thus be possible to sanitize the input to remove all other invalid characters without breaking RDNS resolution for legitimate hosts.
Our solution should also accept international / unicode domains in case the hostname would contain non english characters?
This package could contain IP classes as well as the Url classes from Piwik.
See bug report in matomo-org/matomo#10373
There is nowwhere a function mb_orig_strlen
/**
* Returns true if this is an IPv4, IPv4-compat, or IPv4-mapped address, false otherwise.
*
* @param string $binaryIp
* @return bool
*/
private static function isIPv4($binaryIp)
{
// in case mbstring overloads strlen function
$strlen = function_exists('mb_orig_strlen') ? 'mb_orig_strlen' : 'strlen';
return $strlen($binaryIp) == 4;
}
Our file headers eg. https://github.com/piwik/component-network/blob/master/src/IPUtils.php can mention LGPL license since we changed from GPL when this component was still in Piwik.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.