CVE-2022-24707: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: Anuko Time Tracker is an open source, web-based time tracking application written in PHP. UNION SQL injection and time-based blind injection vulnerabilities existed in Time Tracker Puncher plugin in versions of anuko timetracker prior to 1.20.0.5642. This was happening because the Puncher plugin was reusing code from other places and was relying on an unsanitized date parameter in POST requests. Because the parameter was not checked, it was possible to craft POST requests with malicious SQL for Time Tracker database. This issue has been resolved in in version 1.20.0.5642. Users unable to upgrade are advised to add their own checks to input.
CWE 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.
CVSS v3 base score: 8.8
Published: 2022-02-24T16:15Z
Repository: https://github.com/anuko/timetracker
Language: PHP
Files changed: initialize.php, puncher.php
Commit date: 2022-02-21 14:56:57 +0000
Commit message: Addressed an sql injection vulnerability in puncher.php.

Diff: diff --git a/initialize.php b/initialize.php
index 295d77ca0..039438f08 100644
--- a/initialize.php
+++ b/initialize.php
@@ -10,11 +10,11 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); // & ~E_DEPRECATED);
 // E_ALL tends to change as PHP evolves, therefore we use & here instead of exclusive OR (^).
 
 // Disable displaying errors on screen.
 ini_set('display_errors', 'Off');
 
-define("APP_VERSION", "1.20.0.5641");
+define("APP_VERSION", "1.20.0.5642");
 define("APP_DIR", dirname(__FILE__));
 define("LIBRARY_DIR", APP_DIR."/WEB-INF/lib");
 define("TEMPLATE_DIR", APP_DIR."/WEB-INF/templates");
 // Date format for database and URI parameters.
 define('DB_DATEFORMAT', '%Y-%m-%d');
diff --git a/puncher.php b/puncher.php
index 787c6f34b..0cfd37f20 100644
--- a/puncher.php
+++ b/puncher.php
@@ -17,10 +17,17 @@ if (!ttAccessAllowed('track_own_time')) {
 }
 if (!$user->isPluginEnabled('pu')) {
   header('Location: feature_disabled.php');
   exit();
 }
+// If we are passed in a date, make sure it is in correct format.
+// TODO: redo this temporary sql injection fix as we are not supposed to pass a date.
+$date = $request->getParameter('date');
+if ($date && !ttValidDbDateFormatDate($date)) {
+  header('Location: access_denied.php');
+  exit();
+}
 if ($request->isPost()) {
   // Validate that browser_today parameter is in correct format.
   $browser_today = $request->getParameter('browser_today');
   if ($browser_today && !ttValidDbDateFormatDate($browser_today)) {
     header('Location: access_denied.php');

Vulnerable code: define("APP_VERSION", "1.20.0.5641");
Fixed code: define("APP_VERSION", "1.20.0.5642");
// If we are passed in a date, make sure it is in correct format.
// TODO: redo this temporary sql injection fix as we are not supposed to pass a date.
$date = $request->getParameter('date');
if ($date && !ttValidDbDateFormatDate($date)) {
  header('Location: access_denied.php');
  exit();
}