CVE-2021-43851 (published 2021-12-22T00:15Z)

Anuko Time Tracker is an open source, web-based time tracking application written in PHP. SQL injection vulnerability exist in multiple files in Time Tracker version 1.19.33.5606 and prior due to not properly checking of the "group" and "status" parameters in POST requests. Group parameter is posted along when navigating between organizational subgroups (groups.php file). Status parameter is used in multiple files to change a status of an entity such as making a project, task, or user inactive. This issue has been patched in version 1.19.33.5607. An upgrade is highly recommended. If an upgrade is not practical, introduce ttValidStatus function as in the latest version and start using it user input check blocks wherever status field is used. For groups.php fix, introduce ttValidInteger function as in the latest version and use it in the access check block in the file.

Severity: MEDIUM
CVSS v2 base score: 6.5 (AV:N/AC:L/Au:S/C:P/I:P/A:P)
CVSS v3 base score: 8.8, HIGH (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-89
cwe_name: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
description: The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
extended_description: 
            
            
         
         

Fix information:
repo_url: https://github.com/anuko/timetracker
commit_details: repo_url: https://github.com/anuko/timetracker
author: Nik Okuntseff
author_date: 2021-10-21 12:29:00+00:00
msg: Added additional protection against an sql injection fixed in previous commit.
repository: repo_url: https://github.com/anuko/timetracker
repo_name: anuko/timetracker
description: Simple, easy to use, open source time tracking system.
repo_language: PHP
owner: anuko
file_changes: filename: ttGroupHelper.class.php
change_type: ModificationType.MODIFY
diff: @@ -27,9 +27,13 @@ class ttGroupHelper {
   static function getParentGroup($group_id) {
     global $user;
 
+    // Checking parameters for sanity is normally done in access check blocks on pages.
+    // This cast below is just in case we forgot to check $group_id to be an integer.
+    $groupId = (int) $group_id; // Protection against sql injection.
+
     $mdb2 = getConnection();
 
-    $sql = "select parent_id from tt_groups where id = $group_id and org_id = $user->org_id and status = 1";
+    $sql = "select parent_id from tt_groups where id = $groupId and org_id = $user->org_id and status = 1";
     $res = $mdb2->query($sql);
 
     if (!is_a($res, 'PEAR_Error')) {

programming_language: PHP
filename: initialize.php
change_type: ModificationType.MODIFY
diff: @@ -12,7 +12,7 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); // & ~E_DEPRECATED);
 // Disable displaying errors on screen.
 ini_set('display_errors', 'Off');
 
-define("APP_VERSION", "1.19.31.5602");
+define("APP_VERSION", "1.19.31.5603");
 define("APP_DIR", dirname(__FILE__));
 define("LIBRARY_DIR", APP_DIR."/WEB-INF/lib");
 define("TEMPLATE_DIR", APP_DIR."/WEB-INF/templates");

programming_language: PHP
repo_url: https://github.com/anuko/timetracker
commit_details: repo_url: https://github.com/anuko/timetracker
author: Nik Okuntseff
author_date: 2021-10-20 20:51:47+00:00
msg: Fixed an sql injection vulnerability in groups.php.
repository: repo_url: https://github.com/anuko/timetracker
repo_name: anuko/timetracker
description: Simple, easy to use, open source time tracking system.
repo_language: PHP
owner: anuko
file_changes: filename: groups.php
change_type: ModificationType.MODIFY
diff: @@ -11,9 +11,16 @@ if (!ttAccessAllowed('manage_subgroups')) {
   header('Location: access_denied.php');
   exit();
 }
-if ($request->isPost() && !$user->isGroupValid($request->getParameter('group'))) {
-  header('Location: access_denied.php'); // Wrong group id in post.
-  exit();
+if ($request->isPost()) {
+  $group_id = $request->getParameter('group');
+  if (!ttValidInteger($group_id)) {
+    header('Location: access_denied.php'); // Protection against sql injection.
+    exit();
+  }
+  if (!$user->isGroupValid($group_id)) {
+    header('Location: access_denied.php'); // Wrong group id in post.
+    exit();
+  }
 }
 // End of access checks.
 

programming_language: PHP
filename: initialize.php
change_type: ModificationType.MODIFY
diff: @@ -12,7 +12,7 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); // & ~E_DEPRECATED);
 // Disable displaying errors on screen.
 ini_set('display_errors', 'Off');
 
-define("APP_VERSION", "1.19.30.5601");
+define("APP_VERSION", "1.19.31.5602");
 define("APP_DIR", dirname(__FILE__));
 define("LIBRARY_DIR", APP_DIR."/WEB-INF/lib");
 define("TEMPLATE_DIR", APP_DIR."/WEB-INF/templates");

programming_language: PHP