CVE-2015-5243 (published 2018-08-20T21:29Z)

phpWhois allows remote attackers to execute arbitrary code via a crafted whois record.

Severity: HIGH
CVSS v2 base score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 9.8, CRITICAL (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-94
cwe_name: Improper Control of Generation of Code ('Code Injection')
description: The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
extended_description: 
            When a product allows a user's input to contain code syntax, it might be possible for an attacker to craft the code in such a way that it will alter the intended control flow of the product. Such an alteration could lead to arbitrary code execution.
            Injection problems encompass a wide variety of issues -- all mitigated in very different ways. For this reason, the most effective way to discuss these weaknesses is to note the distinct features which classify them as injection weaknesses. The most important issue to note is that all injection problems share one thing in common -- i.e., they allow for the injection of control plane data into the user-controlled data plane. This means that the execution of the process may be altered by sending code in through legitimate data channels, using no other mechanism. While buffer overflows, and many other flaws, involve the use of some further issue to gain execution, injection problems need only for the data to be parsed. The most classic instantiations of this category of weakness are SQL injection and format string vulnerabilities.
         
         

Fix information:
repo_url: https://github.com/Gemorroj/phpwhois
commit_details: repo_url: https://github.com/Gemorroj/phpwhois
author: Gemorroj
author_date: 2018-02-10 20:40:14+03:00
msg: remove eval-s
repository: repo_url: https://github.com/Gemorroj/phpwhois
repo_name: Gemorroj/phpwhois
description: Mirror of http://sourceforge.net/projects/phpwhois/
repo_language: PHP
owner: Gemorroj
file_changes: filename: whois.parser.php
change_type: ModificationType.MODIFY
diff: @@ -102,10 +102,12 @@ function generic_parser_a_blocks($rawdata, $translate, &$disclaimer)
             $k = $translate[$k];
             if ($k == '') continue;
             if (strstr($k, '.')) {
-                eval("\$block" . getvarname($k) . "=\$v;");
+                ${'block' . getvarname($k)} = $v;
                 continue;
             }
-        } else $k = strtolower($k);
+        } else {
+            $k = strtolower($k);
+        }
 
         if ($k == 'handle') {
             $v = strtok($v, ' ');
@@ -345,15 +347,16 @@ function generic_parser_b($rawdata, $items = false, $dateformat = 'mdy', $hasreg
 
                 if ($pos !== false) {
                     if ($field != '') {
-                        $var = '$r' . getvarname($field);
                         $itm = trim(substr($val, $pos + strlen($match)));
 
-                        if ($itm != '')
-                            eval($var . '="' . str_replace('"', '\"', $itm) . '";');
+                        if ($itm != '') {
+                            ${'r' . getvarname($field)} = '="' . str_replace('"', '\"', $itm) . '";';
+                        }
                     }
 
-                    if (!$scanall)
+                    if (!$scanall) {
                         break;
+                    }
                 }
             }
         }
@@ -418,7 +421,8 @@ function get_blocks($rawdata, $items, $partial_match = false, $def_block = false
                 } else {
                     $var = getvarname(strtok($field, '#'));
                     $itm = trim(substr($val, $pos + strlen($match)));
-                    eval('$r' . $var . '=$itm;');
+
+                    ${'r' . $var} = $itm;
                 }
 
                 break;
@@ -480,7 +484,9 @@ function get_blocks($rawdata, $items, $partial_match = false, $def_block = false
 
             if ($pos !== false) {
                 $var = getvarname(strtok($field, '#'));
-                if ($var != '[]') eval('$r' . $var . '=$block;');
+                if ($var != '[]') {
+                    ${'r' . $var} = $block;
+                }
             }
         }
     }
@@ -586,7 +592,7 @@ function get_contact($array, $extra_items = '', $has_org = false)
                 $itm = trim(substr($val, $pos + strlen($match)));
 
                 if ($field != '' && $itm != '') {
-                    eval('$r' . getvarname($field) . '=$itm;');
+                    ${'r' . getvarname($field)} = $itm;
                 }
 
                 $val = trim(substr($val, 0, $pos));

programming_language: PHP