CVE-2014-125081: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: A vulnerability, which was classified as critical, has been found in risheesh debutsav. This issue affects some unknown processing. The manipulation leads to sql injection. The patch is named 7a8430df79277c613449262201cc792db894fc76. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218459.
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-17T23:15Z
Repository: https://github.com/risheesh/debutsav
Language: PHP
Files changed: assets/php/delegateRegistration.php, assets/php/speakerRegistration.php
Commit date: 2014-10-05 21:50:51 +0530
Commit message: Fixed sqli in sqlite3

Diff: diff --git a/assets/php/delegateRegistration.php b/assets/php/delegateRegistration.php
index 5746aec..25a8410 100755
--- a/assets/php/delegateRegistration.php
+++ b/assets/php/delegateRegistration.php
@@ -49,52 +49,52 @@ if ( $_SERVER["REQUEST_METHOD"] == "POST" ) {
 	} else {
 		// Your code here to handle a successful verification
 		$myDateTime = new DateTime( Date( '' ), new DateTimeZone( 'GMT' ) );
 		$myDateTime->setTimezone( new DateTimeZone( 'Asia/Kolkata' ) );
 		$date = $myDateTime->format( 'Y-m-d H:i:s' );
-		$name = $_POST['del-name'];
+		$name = SQLite3::escapeString($_POST['del-name']);
 		if ( empty( $_POST['del-email'] ) )
 		{
 			$emailerror = "Required Field";
 		}
 		else
 		{
-			$email = $_POST['del-email'];
+			$email = SQLite3::escapeString($_POST['del-email']);
 			if ( !preg_match( "/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email ) )
 			{
 				$emailerror = "Invalid Format";
 			}
 		}
-		$org = $_POST['del-org'];
-		$city = $_POST['del-city'];
+		$org = SQLite3::escapeString($_POST['del-org']);
+		$city = SQLite3::escapeString($_POST['del-city']);
 		if ( !preg_match( '/$^|^[a-zA-Z]+[0-9]*[\. ,]*[a-zA-Z0-9]*$/', $city ) )
 		{
 			$cityerror = "City name must start with a letter and can contain only alphanumerics, spaces, periods and commas";
 		}
 
 		if ( empty( $_POST['del-arrival'] ) ) {
 
 			$arrivalerror = "No arriving date given";
 		} else {
 
-			$arrival = $_POST['del-arrival'];
+			$arrival = SQLite3::escapeString($_POST['del-arrival']);
 		}
 		if ( empty( $_POST['del-depart'] ) ) {
 			$departureerror = "No departure date given";
 		} else {
-			$departure = $_POST['del-depart'];
+			$departure = SQLite3::escapeString($_POST['del-depart']);
 		}
 		$lap = 1;
 		if ( empty( $_POST['del-accom'] ) ) {
 			$accom = "0";
 		} else {
-			$accom = $_POST['del-accom'];
+			$accom = SQLite3::escapeString($_POST['del-accom']);
 		}
 		if ( empty( $_POST['del-tshirt'] ) ) {
 			$tshirt = "0";
 		} else {
-			$tshirt = $_POST['del-tshirt'];
+			$tshirt = SQLite3::escapeString($_POST['del-tshirt']);
 		}
 
 		if ( $nameerror == "" && $emailerror == "" && $arrivalerror == "" && $departureerror == "" && $orgerror == "" && $cityerror == "" )
 		{
 
diff --git a/assets/php/speakerRegistration.php b/assets/php/speakerRegistration.php
index 752b022..429d6ac 100755
--- a/assets/php/speakerRegistration.php
+++ b/assets/php/speakerRegistration.php
@@ -1,8 +1,7 @@
 <?php
-error_reporting( E_ALL );
-ini_set( 'display_errors', '1' );
+error_reporting(0);
 # Database Connection
 class database extends SQLite3
 {
 	function __construct()
 	{
@@ -52,66 +51,66 @@ if ( $_SERVER["REQUEST_METHOD"] == "POST" ) {
 		"(reCAPTCHA said: " . $resp->error . ")" );
 	} else {
 		$myDateTime = new DateTime( Date( '' ), new DateTimeZone( 'GMT' ) );
 		$myDateTime->setTimezone( new DateTimeZone( 'Asia/Kolkata' ) );
 		$date = $myDateTime->format( 'Y-m-d H:i:s' );
-		$name = $_POST['sp-name'];
+		$name = SQLite3::escapeString( $_POST['sp-name'] );
 		if ( empty( $_POST['sp-email'] ) )
 		{
 			$emailerror = "Required Field";
 		}
 		else
 		{
-			$email = $_POST['sp-email'];
+			$email = SQLite3::escapeString( $_POST['sp-email'] );
 			if ( !preg_match( "/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email ) )
 			{
 				$emailerror = "Invalid Format";
 			}
 		}
-		$org = $_POST['sp-org'];
-		$city = $_POST['sp-city'];
+		$org = SQLite3::escapeString( $_POST['sp-org'] );
+		$city = SQLite3::escapeString( $_POST['sp-city'] );
 		if ( !preg_match( '/$^|^[a-zA-Z]+[0-9]*[\. ,]*[a-zA-Z0-9]*$/', $city ) )
 		{
 			$cityerror = "City name must start with a letter and can contain only alphanumerics, spaces, periods and commas";
 		}
 		if ( empty( $_POST['sp-profile'] ) ) {
 			$profilerror = "No profile";
 		} else {
-			$profile = $_POST['sp-profile'];
+			$profile = SQLite3::escapeString( $_POST['sp-profile'] );
 		}
 
 		if ( empty( $_POST['sp-tshirt'] ) ) {
 			$tshirt = "0";
 		} else {
-			$tshirt = $_POST['sp-tshirt'];
+			$tshirt = SQLite3::escapeString( $_POST['sp-tshirt'] );
 		}
 
 		if ( empty( $_POST['sp-arrival'] ) ) {
 			$arrivalerror = "No arriving date given";
 		} else {
-			$arrival = $_POST['sp-arrival'];
+			$arrival = SQLite3::escapeString( $_POST['sp-arrival'] );
 		}
 		if ( empty( $_POST['sp-depart'] ) ) {
 			$departureerror = "No departure date given";
 		} else {
-			$departure = $_POST['sp-depart'];
+			$departure = SQLite3::escapeString( $_POST['sp-depart'] );
 		}
 		$lap = 1;
 		if ( empty( $_POST['sp-accom'] ) ) {
 			$accom = "0";
 		} else {
-			$accom = $_POST['sp-accom'];
+			$accom = SQLite3::escapeString( $_POST['sp-accom'] );
 		}
-		$pretitle = $_POST['sp-title'];
+		$pretitle = SQLite3::escapeString( $_POST['sp-title'] );
 		if ( empty( $pretitle ) )
 		{
 			$titleerror = "Required Field";
 		}
 		else
 		{
-			$title = $_POST['sp-title'];
-			$desc = $_POST['sp-desc'];
+			$title = SQLite3::escapeString( $_POST['sp-title'] );
+			$desc = SQLite3::escapeString( $_POST['sp-desc'] );
 
 		}
 		if ( $nameerror == "" && $emailerror == "" && $arrivalerror == "" && $departureerror == "" && $orgerror == "" && $cityerror == "" && $titleerror == "" && $profilerror == "" )
 		{
 			$sql = "INSERT INTO `registration_speaker` VALUES ('$name','$email','$org','$city','$lap','$accom','$tshirt','$arrival','$departure','$title','$desc','$date', '$profile')";
@@ -121,14 +120,14 @@ if ( $_SERVER["REQUEST_METHOD"] == "POST" ) {
 			{
 				$db->close();
 				header( 'location:../../registration_success.html' );
 			} else {
 				echo "fail";
-//				header( 'location:../../registration_fail.html' );
+				header( 'location:../../registration_fail.html' );
 			}
 		} else {
 			echo "fail";
-//			header( 'location:../../registration_fail.html' );
+			header( 'location:../../registration_fail.html' );
 		}
 	}
 }
 ?>

Vulnerable code: 		$name = $_POST['del-name'];
			$email = $_POST['del-email'];
		$org = $_POST['del-org'];
		$city = $_POST['del-city'];
			$arrival = $_POST['del-arrival'];
			$departure = $_POST['del-depart'];
			$accom = $_POST['del-accom'];
			$tshirt = $_POST['del-tshirt'];
error_reporting( E_ALL );
ini_set( 'display_errors', '1' );
		$name = $_POST['sp-name'];
			$email = $_POST['sp-email'];
		$org = $_POST['sp-org'];
		$city = $_POST['sp-city'];
			$profile = $_POST['sp-profile'];
			$tshirt = $_POST['sp-tshirt'];
			$arrival = $_POST['sp-arrival'];
			$departure = $_POST['sp-depart'];
			$accom = $_POST['sp-accom'];
		$pretitle = $_POST['sp-title'];
			$title = $_POST['sp-title'];
			$desc = $_POST['sp-desc'];
//				header( 'location:../../registration_fail.html' );
//			header( 'location:../../registration_fail.html' );
Fixed code: 		$name = SQLite3::escapeString($_POST['del-name']);
			$email = SQLite3::escapeString($_POST['del-email']);
		$org = SQLite3::escapeString($_POST['del-org']);
		$city = SQLite3::escapeString($_POST['del-city']);
			$arrival = SQLite3::escapeString($_POST['del-arrival']);
			$departure = SQLite3::escapeString($_POST['del-depart']);
			$accom = SQLite3::escapeString($_POST['del-accom']);
			$tshirt = SQLite3::escapeString($_POST['del-tshirt']);
error_reporting(0);
		$name = SQLite3::escapeString( $_POST['sp-name'] );
			$email = SQLite3::escapeString( $_POST['sp-email'] );
		$org = SQLite3::escapeString( $_POST['sp-org'] );
		$city = SQLite3::escapeString( $_POST['sp-city'] );
			$profile = SQLite3::escapeString( $_POST['sp-profile'] );
			$tshirt = SQLite3::escapeString( $_POST['sp-tshirt'] );
			$arrival = SQLite3::escapeString( $_POST['sp-arrival'] );
			$departure = SQLite3::escapeString( $_POST['sp-depart'] );
			$accom = SQLite3::escapeString( $_POST['sp-accom'] );
		$pretitle = SQLite3::escapeString( $_POST['sp-title'] );
			$title = SQLite3::escapeString( $_POST['sp-title'] );
			$desc = SQLite3::escapeString( $_POST['sp-desc'] );
				header( 'location:../../registration_fail.html' );
			header( 'location:../../registration_fail.html' );