CVE-2018-7466 (published 2018-02-25T07:29Z)

install/installNewDB.php in TestLink through 1.9.16 allows remote attackers to conduct injection attacks by leveraging control over DB LOGIN NAMES data during installation to provide a long, crafted value.

Severity: MEDIUM
CVSS v2 base score: 6.0 (AV:N/AC:M/Au:S/C:P/I:P/A:P)
CVSS v3 base score: 7.5, HIGH (CVSS:3.0/AV:N/AC:H/PR:L/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/TestLinkOpenSourceTRMS/testlink-code
commit_details: repo_url: https://github.com/TestLinkOpenSourceTRMS/testlink-code
author: Francisco Mancardi
author_date: 2018-02-24 17:21:33+01:00
msg: Limit DB LOGIN NAMES length to avoid some kind of injection
repository: repo_url: https://github.com/TestLinkOpenSourceTRMS/testlink-code
repo_name: TestLinkOpenSourceTRMS/testlink-code
description: TestLink Open Source Test & Requirement Management System
repo_language: PHP
owner: TestLinkOpenSourceTRMS
file_changes: filename: installNewDB.php
change_type: ModificationType.MODIFY
diff: @@ -63,22 +63,25 @@ $db_table_prefix = preg_replace($san,'',$db_table_prefix);
 $db_server = trim($_SESSION['databasehost']);
 $db_server = preg_replace($san,'',$db_server);
 
-$db_admin_name = trim($_SESSION['databaseloginname']);
-$db_admin_name = preg_replace($san,'',$db_admin_name);
-
 $db_admin_pass = trim($_SESSION['databaseloginpassword']);
 $db_admin_pass = preg_replace($san,'',$db_admin_pass);
 
 $db_type = trim($_SESSION['databasetype']);
 $db_type = preg_replace($san,'',$db_type);
 
-$tl_db_login = trim($_SESSION['tl_loginname']);
-$tl_db_login = preg_replace($san,'',$tl_db_login);
-
 $tl_db_passwd = trim($_SESSION['tl_loginpassword']);
 $tl_db_passwd = preg_replace($san,'',$tl_db_passwd);
 
 
+// will limit length to avoi some kind of injection
+// Choice: 32 
+$tl_db_login = trim($_SESSION['tl_loginname']);
+$tl_db_login = substr(preg_replace($san,'',$tl_db_login),0,32);
+
+$db_admin_name = trim($_SESSION['databaseloginname']);
+$db_admin_name = substr(preg_replace($san,'',$db_admin_name),0,32);
+
+
 
 $sql_create_schema = array();
 $sql_create_schema[] = "sql/{$db_type}/testlink_create_tables.sql";

programming_language: PHP