CVE-2013-10014: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: A vulnerability classified as critical has been found in oktora24 2moons. Affected is an unknown function. The manipulation leads to sql injection. The patch is identified as 1b09cf7672eb85b5b0c8a4de321f7a4ad87b09a7. It is recommended to apply a patch to fix this issue. VDB-218898 is the identifier assigned to this vulnerability.
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-19T10:15Z
Repository: https://github.com/oktora24/2moons
Language: PHP
Files changed: includes/pages/game/class.ShowFleetStep1Page.php, includes/pages/game/class.ShowFleetTablePage.php, includes/pages/game/class.ShowGalaxyPage.php, includes/pages/game/class.ShowInformationPage.php
Commit date: 2013-01-18 11:31:33 +0000
Commit message: fix possible sql injections.
Diff: diff --git a/includes/pages/game/class.ShowFleetStep1Page.php b/includes/pages/game/class.ShowFleetStep1Page.php
index 0ac765b..a75e10c 100644
--- a/includes/pages/game/class.ShowFleetStep1Page.php
+++ b/includes/pages/game/class.ShowFleetStep1Page.php
@@ -39,14 +39,14 @@ class ShowFleetStep1Page extends AbstractPage
 	
 	public function show()
 	{
 		global $USER, $PLANET, $resource, $pricelist, $reslist, $LNG;
 		
-		$targetGalaxy 			= HTTP::_GP('galaxy', $PLANET['galaxy']);
-		$targetSystem 			= HTTP::_GP('system', $PLANET['system']);
-		$targetPlanet			= HTTP::_GP('planet', $PLANET['planet']);
-		$targetType 			= HTTP::_GP('type', $PLANET['planet_type']);
+		$targetGalaxy 			= HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
+		$targetSystem 			= HTTP::_GP('system', (int) $PLANET['system']);
+		$targetPlanet			= HTTP::_GP('planet', (int) $PLANET['planet']);
+		$targetType 			= HTTP::_GP('type', (int) $PLANET['planet_type']);
 		
 		$mission				= HTTP::_GP('target_mission', 0);
 				
 		$Fleet		= array();
 		$FleetRoom	= 0;
diff --git a/includes/pages/game/class.ShowFleetTablePage.php b/includes/pages/game/class.ShowFleetTablePage.php
index 10600ee..512cb2c 100644
--- a/includes/pages/game/class.ShowFleetTablePage.php
+++ b/includes/pages/game/class.ShowFleetTablePage.php
@@ -190,14 +190,14 @@ class ShowFleetTablePage extends AbstractPage
 			$maxExpedition 		= 0;
 		}
 
 		$maxFleetSlots	= FleetFunctions::GetMaxFleetSlots($USER);
 
-		$targetGalaxy	= HTTP::_GP('galaxy', $PLANET['galaxy']);
-		$targetSystem	= HTTP::_GP('system', $PLANET['system']);
-		$targetPlanet	= HTTP::_GP('planet', $PLANET['planet']);
-		$targetType		= HTTP::_GP('planettype', $PLANET['planet_type']);
+		$targetGalaxy	= HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
+		$targetSystem	= HTTP::_GP('system', (int) $PLANET['system']);
+		$targetPlanet	= HTTP::_GP('planet', (int) $PLANET['planet']);
+		$targetType		= HTTP::_GP('planettype', (int) $PLANET['planet_type']);
 		$targetMission	= HTTP::_GP('target_mission', 0);
 		
 		$fleetResult 		= $GLOBALS['DATABASE']->query("SELECT * FROM ".FLEETS." WHERE fleet_owner = ".$USER['id']." AND fleet_mission <> 10 ORDER BY fleet_end_time ASC;");
 		$activeFleetSlots	= $GLOBALS['DATABASE']->numRows($fleetResult);
 
diff --git a/includes/pages/game/class.ShowGalaxyPage.php b/includes/pages/game/class.ShowGalaxyPage.php
index 2b0ae84..67b39dd 100644
--- a/includes/pages/game/class.ShowGalaxyPage.php
+++ b/includes/pages/game/class.ShowGalaxyPage.php
@@ -45,16 +45,16 @@ class ShowGalaxyPage extends AbstractPage
 		$action 		= HTTP::_GP('action', '');
 		$galaxyLeft		= HTTP::_GP('galaxyLeft', '');
 		$galaxyRight	= HTTP::_GP('galaxyRight', '');
 		$systemLeft		= HTTP::_GP('systemLeft', '');
 		$systemRight	= HTTP::_GP('systemRight', '');
-		$galaxy			= min(max(HTTP::_GP('galaxy', $PLANET['galaxy']), 1), Config::get('max_galaxy'));
-		$system			= min(max(HTTP::_GP('system', $PLANET['system']), 1), Config::get('max_system'));
-		$planet			= min(max(HTTP::_GP('planet', $PLANET['planet']), 1), Config::get('max_planets'));
+		$galaxy			= min(max(HTTP::_GP('galaxy', (int) $PLANET['galaxy']), 1), Config::get('max_galaxy'));
+		$system			= min(max(HTTP::_GP('system', (int) $PLANET['system']), 1), Config::get('max_system'));
+		$planet			= min(max(HTTP::_GP('planet', (int) $PLANET['planet']), 1), Config::get('max_planets'));
 		$type			= HTTP::_GP('type', 1);
 		$current		= HTTP::_GP('current', 0);
-			
+		
         if (!empty($galaxyLeft))
             $galaxy	= max($galaxy - 1, 1);
         elseif (!empty($galaxyRight))
             $galaxy	= min($galaxy + 1, Config::get('max_galaxy'));
 
diff --git a/includes/pages/game/class.ShowInformationPage.php b/includes/pages/game/class.ShowInformationPage.php
index 2d00b52..dce450c 100644
--- a/includes/pages/game/class.ShowInformationPage.php
+++ b/includes/pages/game/class.ShowInformationPage.php
@@ -53,11 +53,11 @@ class ShowInformationPage extends AbstractPage
 		
 		if (TIMESTAMP < $NextJumpTime) {
 			$this->sendJSON(array('message' => $LNG['in_jump_gate_already_used'].' '.pretty_time($NextJumpTime - TIMESTAMP), 'error' => true));
 		}
 		
-		$TargetPlanet = HTTP::_GP('jmpto', $PLANET['id']);
+		$TargetPlanet = HTTP::_GP('jmpto', (int) $PLANET['id']);
 		$TargetGate   = $GLOBALS['DATABASE']->getFirstRow("SELECT id, last_jump_time FROM ".PLANETS." WHERE id = ".$TargetPlanet." AND id_owner = ".$USER['id']." AND sprungtor > 0;");
 
 		if (!isset($TargetGate) || $TargetPlanet == $PLANET['id']) {
 			$this->sendJSON(array('message' => $LNG['in_jump_gate_doesnt_have_one'], 'error' => true));
 		}

Vulnerable code: 		$targetGalaxy 			= HTTP::_GP('galaxy', $PLANET['galaxy']);
		$targetSystem 			= HTTP::_GP('system', $PLANET['system']);
		$targetPlanet			= HTTP::_GP('planet', $PLANET['planet']);
		$targetType 			= HTTP::_GP('type', $PLANET['planet_type']);
		$targetGalaxy	= HTTP::_GP('galaxy', $PLANET['galaxy']);
		$targetSystem	= HTTP::_GP('system', $PLANET['system']);
		$targetPlanet	= HTTP::_GP('planet', $PLANET['planet']);
		$targetType		= HTTP::_GP('planettype', $PLANET['planet_type']);
		$galaxy			= min(max(HTTP::_GP('galaxy', $PLANET['galaxy']), 1), Config::get('max_galaxy'));
		$system			= min(max(HTTP::_GP('system', $PLANET['system']), 1), Config::get('max_system'));
		$planet			= min(max(HTTP::_GP('planet', $PLANET['planet']), 1), Config::get('max_planets'));
			
		$TargetPlanet = HTTP::_GP('jmpto', $PLANET['id']);
Fixed code: 		$targetGalaxy 			= HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
		$targetSystem 			= HTTP::_GP('system', (int) $PLANET['system']);
		$targetPlanet			= HTTP::_GP('planet', (int) $PLANET['planet']);
		$targetType 			= HTTP::_GP('type', (int) $PLANET['planet_type']);
		$targetGalaxy	= HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
		$targetSystem	= HTTP::_GP('system', (int) $PLANET['system']);
		$targetPlanet	= HTTP::_GP('planet', (int) $PLANET['planet']);
		$targetType		= HTTP::_GP('planettype', (int) $PLANET['planet_type']);
		$galaxy			= min(max(HTTP::_GP('galaxy', (int) $PLANET['galaxy']), 1), Config::get('max_galaxy'));
		$system			= min(max(HTTP::_GP('system', (int) $PLANET['system']), 1), Config::get('max_system'));
		$planet			= min(max(HTTP::_GP('planet', (int) $PLANET['planet']), 1), Config::get('max_planets'));
		
		$TargetPlanet = HTTP::_GP('jmpto', (int) $PLANET['id']);