CVE-2015-10100 (PHP, published 2023-04-10T18:15Z)
Description: value: A vulnerability, which was classified as critical, has been found in Dynamic Widgets Plugin up to 1.5.10 on WordPress. This issue affects some unknown processing of the file classes/dynwid_class.php. The manipulation leads to sql injection. The attack may be initiated remotely. Upgrading to version 1.5.11 is able to address this issue. The identifier of the patch is d0a19c6efcdc86d7093b369bc9e29a0629e57795. It is recommended to upgrade the affected component. The identifier VDB-225353 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/dynamic-widgets
Files changed:
classes/dynwid_class.php
Commit message: Change DB query methods to prevent SQL injection

git-svn-id: https://plugins.svn.wordpress.org/dynamic-widgets/trunk@1220789 b8457f37-d9ea-0310-8a92-e5e31aec5664


Vulnerable code:
				$query = "SELECT COUNT(1) AS total FROM " . $this->dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = '" . $maintype . "' AND name = 'default'";
			$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = '" . $maintype ."'";
				$query .= " AND name = '" . $name . "'";
                     WHERE  maintype LIKE '" . $whereami . "%'";
                 WHERE widget_id LIKE '" . $widget_id . "'
                   AND maintype LIKE '" . $maintype . "%'
                  WHERE widget_id LIKE '" . $widget_id . "'
                    AND maintype LIKE '" . $maintype . "%'
                  WHERE widget_id LIKE '" . $widget_id . "'
                    AND (maintype LIKE '" . $maintype . "%'";
						$q[ ] = "'" . $omt . "'";
                  WHERE widget_id = '" . $widget_id . "' AND
                        maintype != 'individual'";
			$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = '" . $widget_id . "'";

Fixed code:
			$fields = array(
				'widget_id'		=> $widget_id,
				'maintype'		=> 'date',
				'name'			=> 'default',
				'value'			=> '0'
			);
			$this->wpdb->insert($this->dbtable, $fields);

			/*
			*/
				$fields = array(
					'widget_id'		=> $widget_id,
					'maintype'		=> 'date',
					'name'			=> $name,
					'value'			=> $date
				);
				$this->wpdb->insert($this->dbtable, $fields);

				/*
				*/

				$fields = array(
					'widget_id'		=> $widget_id,
					'maintype'		=> 'ip',
					'name'			=> 'default',
					'value'			=> '0'
				);
				$this->wpdb->insert($this->dbtable, $fields);

				/*
				*/
			$fields = array(
				'widget_id'		=> $widget_id,
				'maintype'		=> 'ip',
				'name'			=> 'ip',
				'value'			=> $value
			);
			$this->wpdb->insert($this->dbtable, $fields);

			/*
			*/
				$fields = array(
					'widget_id'		=> $widget_id,
					'maintype'		=> 'shortcode',
					'name'			=> 'default',
					'value'			=> '0'
				);
				$this->wpdb->insert($this->dbtable, $fields);

				/*
				*/
			$fields = array(
				'widget_id'		=> $widget_id,
				'maintype'		=> 'shortcode',
				'name'			=> 'shortcode',
				'value'			=> $value
			);
			$this->wpdb->insert($this->dbtable, $fields);

			/*
			*/
				$fields = array(
					'widget_id'		=> $widget_id,
					'maintype'		=> 'url',
					'name'			=> 'default',
					'value'			=> '0'
				);
				$this->wpdb->insert($this->dbtable, $fields);

				/*
				*/
			$fields = array(
				'widget_id'		=> $widget_id,
				'maintype'		=> 'url',
				'name'			=> 'url',
				'value'			=> $value
			);
			$this->wpdb->insert($this->dbtable, $fields);

			/*
			*/
				$query = "SELECT COUNT(1) AS total FROM " . $this->dbtable . " WHERE widget_id = %s AND maintype = %s AND name = %s";
				$query = $this->wpdb->prepare($query, $widget_id, $maintype, 'default');
				$fields = array(
					'widget_id'		=> $widget_id,
					'maintype'		=> $maintype,
					'name'			=> 'default',
					'value'			=> $opt_default
				);
				$this->wpdb->insert($this->dbtable, $fields);

				/*
				*/
				$fields = array(
					'widget_id'		=> $widget_id,
					'maintype'		=> $maintype,
					'name'			=> $option,
					'value'			=> $opt_act
				);
				$this->wpdb->insert($this->dbtable, $fields);

				/*
				*/
			$fields = array(
				'widget_id'		=> $widget_id,
				'maintype'		=> $maintype,
				'value'			=> $value
			);
			$this->wpdb->insert($this->dbtable, $fields);

			/*
			*/
			$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = %s AND maintype = %s";
				$query .= " AND name = %s";
				$query = $this->wpdb->prepare($query, $widget_id, $maintype, $name);
			} else {
				$query = $this->wpdb->prepare($query, $widget_id, $maintype);

                     WHERE  maintype LIKE '" . esc_sql($whereami) . "%'";
                 WHERE widget_id LIKE '" . esc_sql($widget_id) . "'
                   AND maintype LIKE '" . esc_sql($maintype) . "%'
                  WHERE widget_id LIKE '" . esc_sql($widget_id) . "'
                    AND maintype LIKE '" . esc_sql($maintype) . "%'
                  WHERE widget_id LIKE '" . esc_sql($widget_id) . "'
                    AND (maintype LIKE '" . esc_sql($maintype) . "%'";
						$q[ ] = "'" . esc_sql($omt) . "'";
                  WHERE widget_id = %s AND
                        maintype != %s";
			$query = $this->wpdb->prepare($query, $widget_id, 'individual');
			$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = %s";
			$query = $this->wpdb->prepare($query, $widget_id);