CVE-2010-10009: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: A vulnerability was found in frioux ptome. It has been rated as critical. This issue affects some unknown processing. The manipulation leads to sql injection. The patch is named 26829bba67858ca0bd4ce49ad50e7ce653914276. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218519.
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: 9.8
Published: 2023-01-18T21:15Z
Repository: https://github.com/frioux/ptome
Language: PHP
Files changed: OpenSiteAdmin/scripts/classes/Field.php, OpenSiteAdmin/scripts/classes/LoginManager.php
Commit date: 2010-01-11 06:15:24 +0000
Commit message: Security update to thwart SQL injection (previously, magic_quotes_gpc was saving us)
Diff: diff --git a/OpenSiteAdmin/scripts/classes/Field.php b/OpenSiteAdmin/scripts/classes/Field.php
index 04951f0..d14b848 100755
--- a/OpenSiteAdmin/scripts/classes/Field.php
+++ b/OpenSiteAdmin/scripts/classes/Field.php
@@ -201,11 +201,11 @@
 		 * Gets the current value of this form field.
          *
 		 * @return MIXED Current field value.
 		 */
 		function getValue() {
-			$ret = $this->value;
+            $ret = SecurityManager::formPrep($this->value);
             if(empty($ret)) {
 				return $this->default;
 			}
 			return $ret;
         }
@@ -269,10 +269,11 @@
          *
          * @param MIXED $value Value to store.
          * @return BOOLEAN False if any error were encountered.
          */
         protected function postProcess($value) {
+            $value = SecurityManager::SQLPrep($value);
             $this->setValue($value);
             return true;
         }
 
         /**
diff --git a/OpenSiteAdmin/scripts/classes/LoginManager.php b/OpenSiteAdmin/scripts/classes/LoginManager.php
index 7fa8415..05ba0a2 100755
--- a/OpenSiteAdmin/scripts/classes/LoginManager.php
+++ b/OpenSiteAdmin/scripts/classes/LoginManager.php
@@ -66,10 +66,12 @@
 		 * @param STRING $remember If set to "yes", the user's login information will be saved in cookies if it validates sucessfully.
 		 * @param BOOLEAN $isCookie True if the provided data is coming from cookie data (cookie passwords are already encrypted).
 		 * @return INTEGER One of the error code constants defined in this class.
 		 */
 		function login($user, $pass, $remember="no", $isCookie=false) {
+            $user = htmlspecialchars(addslashes($user));
+            $pass = htmlspecialchars(addslashes($pass));
 			$sql = "select `users`.*, `libraries`.`interTOME` from `users` JOIN `libraries` ON `users`.`libraryID` = `libraries`.`ID` where `username` LIKE '$user'";
 			$result = DatabaseManager::checkError($sql);
 			if(DatabaseManager::getNumResults($result) === 0) {
 				return LoginManager::INVALID;
 			}

Vulnerable code: 			$ret = $this->value;
Fixed code:             $ret = SecurityManager::formPrep($this->value);
            $value = SecurityManager::SQLPrep($value);
            $user = htmlspecialchars(addslashes($user));
            $pass = htmlspecialchars(addslashes($pass));