CVE-2015-10122 (PHP, published 2023-07-18T05:15Z)
Description: value: A vulnerability was found in wp-donate Plugin up to 1.4 on WordPress. It has been classified as critical. This affects an unknown part of the file includes/donate-display.php. The manipulation leads to sql injection. It is possible to initiate the attack remotely. Upgrading to version 1.5 is able to address this issue. The identifier of the patch is 019114cb788d954c5d1b36d6c62418619e93a757. It is recommended to upgrade the affected component. The identifier VDB-234249 was assigned to this vulnerability.
Severity: nan (CVSS v3 base score: 9.8)
Weakness: CWE-89 \u2014 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
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.
Repository: https://github.com/wp-plugins/wp-donate
Files changed:
includes/donate-display.php
Commit message: made changes in sql query to fix sql injection vulnerabilities by using proper WP query

git-svn-id: https://plugins.svn.wordpress.org/wp-donate/trunk@1118609 b8457f37-d9ea-0310-8a92-e5e31aec5664


Vulnerable code:
		$first_name = $_REQUEST['first_name'];
		$last_name = $_REQUEST['last_name'];
		$organization = $_REQUEST['organization'];
		$address = $_REQUEST['address'];
		$city = $_REQUEST['city'];
		$country = $_REQUEST['country'];
		$state = $_REQUEST['state'];
		$zip = $_REQUEST['zip'];
		$phone = $_REQUEST['phone'];
		$email = $_REQUEST['email'];		
		$donation_type = $_REQUEST['donation_type'];
		$r_frequency = $_REQUEST['r_frequency'];
		$r_times = $_REQUEST['r_times'];
		$amount = $_REQUEST['amount'];
		$card_type = $_REQUEST['card_type'];
		$x_card_num = $_REQUEST['x_card_num'];
		$exp_month = $_REQUEST['exp_month'];
		$exp_year = $_REQUEST['exp_year'];
		$x_card_code = $_REQUEST['x_card_code'];
		$comment = $_REQUEST['comment'];
			$sql = "INSERT INTO `".$wpdb->prefix."donate` (`first_name`, `last_name`, `organization`, `address`, `city`, `country`, `state`, `zip`, `phone`, `email`, `donation_type`, `amount`, `comment`, `status`,`date`) 
			VALUES ('".$first_name."', '".$last_name."','".$organization."','".$address."','".$city."','".$country."','".$state."','".$zip."','".$phone."','".$email."','".$donation_type."','".$amount."','".$comment."', '1',now());";
			$wpdb->query($sql);

Fixed code:
		$first_name = mysql_real_escape_string($_REQUEST['first_name']);
		$last_name = mysql_real_escape_string($_REQUEST['last_name']);
		$organization = mysql_real_escape_string($_REQUEST['organization']);
		$address = mysql_real_escape_string($_REQUEST['address']);
		$city = mysql_real_escape_string($_REQUEST['city']);
		$country = mysql_real_escape_string($_REQUEST['country']);
		$state = mysql_real_escape_string($_REQUEST['state']);
		$zip = mysql_real_escape_string($_REQUEST['zip']);
		$phone = mysql_real_escape_string($_REQUEST['phone']);
		$email = mysql_real_escape_string($_REQUEST['email']);		
		$donation_type = mysql_real_escape_string($_REQUEST['donation_type']);
		$r_frequency = mysql_real_escape_string($_REQUEST['r_frequency']);
		$r_times = mysql_real_escape_string($_REQUEST['r_times']);
		$amount = mysql_real_escape_string($_REQUEST['amount']);
		$card_type = mysql_real_escape_string($_REQUEST['card_type']);
		$x_card_num = mysql_real_escape_string($_REQUEST['x_card_num']);
		$exp_month = mysql_real_escape_string($_REQUEST['exp_month']);
		$exp_year = mysql_real_escape_string($_REQUEST['exp_year']);
		$x_card_code = mysql_real_escape_string($_REQUEST['x_card_code']);
		$comment = mysql_real_escape_string($_REQUEST['comment']);
			
                        
				$q_status = "1";
				$wpdb->query(
						$wpdb->prepare("
							INSERT INTO `".$wpdb->prefix."donate`
							(`first_name`, `last_name`, `organization`, `address`, `city`, `country`, `state`, `zip`, `phone`, `email`, `donation_type`, `amount`, `comment`, `status`,`date`) 
							VALUES ( %s, %s, %s, %s,%s, %s, %s, %s,%s, %s, %s, %s, %s,%s,%s  )
						", 
						$first_name, 
						$last_name, 
						$organization,
						$address,
						$city,
						$country,
						$state,
						$zip,
						$phone,
						$email,
						$donation_type,
						$amount,
						$comment,
						$q_status,
						date('Y-m-d H:i:s')
					)
				);