CVE-2015-10050 (published 2023-01-15T18:15Z)

A vulnerability was found in brandonfire miRNA_Database_by_PHP_MySql. It has been declared as critical. This vulnerability affects the function __construct/select_single_rna/count_rna of the file inc/model.php. The manipulation leads to sql injection. The patch is identified as 307c5d510841e6142ddcbbdbb93d0e8a0dc3fd6a. It is recommended to apply a patch to fix this issue. VDB-218374 is the identifier assigned to this vulnerability.

CVSS v3 base score: 9.8, CRITICAL (CVSS:3.1/AV:N/AC:L/PR:N/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/brandonfire/miRNA_Database_by_PHP_MySql
commit_details: repo_url: https://github.com/brandonfire/miRNA_Database_by_PHP_MySql
author: brandonfire
author_date: 2015-01-23 11:33:56-05:00
msg: prevent sql injection
repository: repo_url: https://github.com/brandonfire/miRNA_Database_by_PHP_MySql
repo_name: brandonfire/miRNA_Database_by_PHP_MySql
repo_language: CSS
owner: brandonfire
file_changes: filename: model.php
change_type: ModificationType.MODIFY
diff: @@ -14,8 +14,9 @@ class rna_database{
 	function select_single_rna($new){
 
 	try {
-		$results = $this->db->query("SELECT * FROM `mirna` WHERE Name = '$new'");
-	
+		$results = $this->db->prepare("SELECT * FROM `mirna` WHERE Name = ?");
+		$results->bindParam(1,$new);
+		$results->execute();
 		} catch(Exception $e)
 		{
 			echo"Could not query the database.";
@@ -25,14 +26,19 @@ class rna_database{
 	return $mirnas;
 	}
 
-	function count_rna($name,$tissue){
+	function count_rna($name,$tissue,$onc=''){
 		try {
 		  if($tissue == "all"){
-		  	$total = $this->db->query("SELECT count(*) FROM mirna WHERE Name LIKE '%$name%'");
-		  
+		  	$total = $this->db->prepare("SELECT count(*) FROM mirna WHERE Name LIKE ? AND Cancer_Effect LIKE ?");
+		  	$total->bindValue(1,"%" . $name . "%");
+		  	$total->bindValue(2,"%" . $onc . "%");
+		  	$total->execute();
 			} else {
-				$total = $this->db->query("SELECT count(*) FROM mirna WHERE Name LIKE '%$name%' AND tissue = '$tissue'");
-		  
+				$total = $this->db->prepare("SELECT count(*) FROM mirna WHERE Name LIKE ? AND tissue = ? AND Cancer_Effect LIKE ?");
+		  		$total->bindValue(1,"%" . $name . "%");
+		  		$total->bindParam(2,$tissue);
+		  		$total->bindValue(3,"%" . $onc . "%");
+		  		$total->execute();
 		  }
 		} catch(Exception $e){
 			echo"Could not query the database.";
@@ -42,14 +48,23 @@ class rna_database{
 		$total_n = intval($arr[0]["count(*)"]);
 		return $total_n;
 	}
-	function select_rnas($name,$tissue,$records_perpage=100,$c_p=0){
+	function select_rnas($name,$tissue,$records_perpage=100,$c_p=0,$onc=''){
 		try {
 		  if($tissue == "all"){
-			$results = $this->db->query("SELECT * FROM mirna WHERE Name LIKE '%$name%' ORDER BY databaseid ASC LIMIT $records_perpage OFFSET $c_p");
-		  
+			$results = $this->db->prepare("SELECT * FROM mirna WHERE Name LIKE ? AND Cancer_Effect LIKE ? ORDER BY databaseid ASC LIMIT ? OFFSET ?");
+		  	$results->bindValue(1,"%" . $name . "%");
+		  	$results->bindValue(2,"%" . $onc . "%");
+		  	$results->bindParam(3,$records_perpage,PDO::PARAM_INT);
+		  	$results->bindParam(4,$c_p,PDO::PARAM_INT);
+		  	$results->execute();
 			} else {
-		  		$results = $this->db->query("SELECT * FROM mirna WHERE Name LIKE '%$name%' AND tissue = '$tissue' ORDER BY databaseid ASC LIMIT $records_perpage OFFSET $c_p");
-		  
+		  		$results = $this->db->prepare("SELECT * FROM mirna WHERE Name LIKE ? AND tissue = ? AND Cancer_Effect LIKE ? ORDER BY databaseid ASC LIMIT ? OFFSET ?");
+		  		$results->bindValue(1,"%" . $name . "%");
+		  		$total->bindParam(2,$tissue);
+		  		$results->bindValue(3,"%" . $onc . "%");
+		  		$results->bindParam(4,$records_perpage,PDO::PARAM_INT);
+		  		$results->bindParam(5,$c_p,PDO::PARAM_INT);
+		  		$results->execute();
 		  }
 		} catch(Exception $e){
 			echo"Could not query the database.";

programming_language: PHP