CVE-2015-8771 (published 2017-02-13T18:59Z)

The generate_smb_nt_hash function in include/functions.inc in GOsa allows remote attackers to execute arbitrary commands via a crafted password.

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/gosa-project/gosa-core
commit_details: repo_url: https://github.com/gosa-project/gosa-core
author: bzapiec
author_date: 2015-10-30 10:07:20+00:00
msg: (See #1221)
udpate samba hash generation due to a possible code injection

command line parameter will be passed base64 encoded to avoid 
complex escaping sequences that may alter the initial passphrase



git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@21280 594d385d-05f5-0310-b6e9-bd551577e9d8
repository: repo_url: https://github.com/gosa-project/gosa-core
repo_name: gosa-project/gosa-core
description: GOsa core
repo_language: PHP
owner: gosa-project
file_changes: filename: class_core.inc
change_type: ModificationType.MODIFY
diff: @@ -582,7 +582,7 @@ DEBUG_SI      = 256"),
                         array(
                                 "name"          => "sambaHashHook",
                                 "type"          => "command",
-                                "default"       => "perl -MCrypt::SmbHash -e \"print join(q[:], ntlmgen %password), $/;\"",
+                                "default"       => "perl -MCrypt::SmbHash -e \"use MIME::Base64; print join(q[:], ntlmgen decode_base64('%password')), $/;\"",
                                 "description"   => _("Command to create Samba NT/LM hashes. Required for password synchronization if you don't use supplementary services."),
                                 "check"         => "gosaProperty::isCommand",
                                 "migrate"       => "",

programming_language: PHP
filename: functions.inc
change_type: ModificationType.MODIFY
diff: @@ -3101,8 +3101,8 @@ function generate_smb_nt_hash($password)
       $password = addcslashes($password, '$'); 
       $password = addcslashes($password, '$'); // <- And again once, to be able to use it as parameter for the perl script.
 	  $tmp = $config->get_cfg_value("core",'sambaHashHook');
-      $tmp = preg_replace("/%userPassword/", escapeshellarg($password), $tmp);
-      $tmp = preg_replace("/%password/", escapeshellarg($password), $tmp);
+      $tmp = preg_replace("/%userPassword/", base64_encode($password), $tmp);
+      $tmp = preg_replace("/%password/", base64_encode($password), $tmp);
 	  @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $tmp, "Execute");
 
  	  exec($tmp, $ar);

programming_language: PHP