CVE-2017-20173: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: A vulnerability was found in AlexRed contentmap. It has been rated as critical. Affected by this issue is the function Load of the file contentmap.php. The manipulation of the argument contentid leads to sql injection. The name of the patch is dd265d23ff4abac97422835002c6a47f45ae2a66. It is recommended to apply a patch to fix this issue. The identifier of this vulnerability is VDB-218492.
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-18T16:15Z
Repository: https://github.com/AlexRed/contentmap
Language: PHP
Files changed: extras/lib_contentmap/json/articlesmarkers.php, site/views/smartloader/view.html.php
Commit date: 2017-03-08 08:35:38 +0000
Commit message: Corretta vulnerabilità SQL Injection

Diff: diff --git a/contentmap.php b/contentmap.php
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/json/articlesmarkers.php b/extras/lib_contentmap/json/articlesmarkers.php
index 4a0ff67..2d57702 100644
--- a/extras/lib_contentmap/json/articlesmarkers.php
+++ b/extras/lib_contentmap/json/articlesmarkers.php
@@ -353,11 +353,11 @@ class articleGoogleMapMarkers extends GoogleMapMarkers
 		$query = $db->getQuery(true);
 		$query->select("id, title, alias, introtext, catid, created, created_by_alias, images, metadata, metadesc, language");
 		$query->from("#__content");
 
 		// Condition: content id passed py plugin
-		$query->where("id = '" . JRequest::getVar("contentid", 0, "GET") . "'");
+		$query->where("id = '" . intval(JRequest::getVar("contentid", 0, "GET")) . "'");
 
 		// Condition: metadata field contains "xreference":"coordinates"
 		// {\"xreference\":\"} the string "xreference":"
 		// {[+-]?} One character. It can be + or - sign. It is optional.
 		// {([0-9]+)} At least one number. They are mandatory.
diff --git a/extras/lib_contentmap/language/cs-CZ/cs-CZ.contentmap.ini b/extras/lib_contentmap/language/cs-CZ/cs-CZ.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/en-GB/en-GB.contentmap.ini b/extras/lib_contentmap/language/en-GB/en-GB.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/es-ES/es-ES.contentmap.ini b/extras/lib_contentmap/language/es-ES/es-ES.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/fr-FR/fr-FR.contentmap.ini b/extras/lib_contentmap/language/fr-FR/fr-FR.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/it-IT/it-IT.contentmap.ini b/extras/lib_contentmap/language/it-IT/it-IT.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/nb-NO/nb-NO.contentmap.ini b/extras/lib_contentmap/language/nb-NO/nb-NO.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/nl-NL/nl-NL.contentmap.ini b/extras/lib_contentmap/language/nl-NL/nl-NL.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/pt-BR/pt-BR.contentmap.ini b/extras/lib_contentmap/language/pt-BR/pt-BR.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/ru-RU/ru-RU.contentmap.ini b/extras/lib_contentmap/language/ru-RU/ru-RU.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/language/sv-SE/sv-SE.contentmap.ini b/extras/lib_contentmap/language/sv-SE/sv-SE.contentmap.ini
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/media/js/markerclusterer.js b/extras/lib_contentmap/media/js/markerclusterer.js
old mode 100755
new mode 100644
diff --git a/extras/lib_contentmap/media/js/markerclusterer_compiled.js b/extras/lib_contentmap/media/js/markerclusterer_compiled.js
old mode 100755
new mode 100644
diff --git a/extras/mod_contentmap/mod_contentmap.xml b/extras/mod_contentmap/mod_contentmap.xml
old mode 100755
new mode 100644
diff --git a/extras/plg_contentmap/contentmap.xml b/extras/plg_contentmap/contentmap.xml
old mode 100755
new mode 100644
diff --git a/site/views/smartloader/view.html.php b/site/views/smartloader/view.html.php
index 5812c56..fd8c1ab 100644
--- a/site/views/smartloader/view.html.php
+++ b/site/views/smartloader/view.html.php
@@ -9,10 +9,14 @@ class ContentMapViewSmartLoader extends JViewLegacy
 		//		parent::display($tpl);
 
 		// Load module || component || plugin parameters. Defaults to plugin
 		$owner = JRequest::getVar("owner", "", "GET") or $owner = "plugin"; // getVar() default value doesn't work with ?owner=""
 
+		if (!in_array($owner,array('module','plugin','component','article'))){
+			die();
+		}
+		
 		$db = JFactory::getDbo();
 		jimport("joomla.database.databasequery");
 		$query = $db->getQuery(true);
 		$this->$owner($query);
 		$db->setQuery($query);

Vulnerable code: 		$query->where("id = '" . JRequest::getVar("contentid", 0, "GET") . "'");
Fixed code: 		$query->where("id = '" . intval(JRequest::getVar("contentid", 0, "GET")) . "'");
		if (!in_array($owner,array('module','plugin','component','article'))){
			die();
		}