CVE-2011-10003: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: A vulnerability was found in XpressEngine up to 1.4.4. It has been rated as critical. This issue affects some unknown processing of the component Update Query Handler. The manipulation leads to sql injection. Upgrading to version 1.4.5 is able to address this issue. The patch is named c6e94449f21256d6362450b29c7847305e756ad5. It is recommended to upgrade the affected component. The associated identifier of this vulnerability is VDB-220247.
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-02-07T21:15Z
Repository: https://github.com/haegyung/xe-core
Language: PHP
Files changed: classes/db/DBCubrid.class.php, classes/db/DBMssql.class.php, classes/db/DBMysql.class.php, classes/db/DBPostgresql.class.php, classes/db/DBSqlite2.class.php, classes/db/DBSqlite3_pdo.class.php
Commit date: 2011-05-02 06:43:49 +0000
Commit message: #19727459 SQL Injection fixed in Update Query


git-svn-id: http://xe-core.googlecode.com/svn/branches/1.4.5@8350 201d5d3c-b55e-5fd7-737f-ddc643e51545

Diff: diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php
index f9eb0c469..0c72b0e58 100644
--- a/classes/db/DBCubrid.class.php
+++ b/classes/db/DBCubrid.class.php
@@ -731,13 +731,12 @@
                 else {
                     if ($output->column_type[$name] != 'number') {
                         $check_column = false;
                         $value = "'".$this->addQuotes ($value)."'";
                     }
-                    elseif (!$value || is_numeric ($value)) {
-                        $value = (int) $value;
-                    }
+					// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
+					else $value = (int)$value;
 
                     $column_list[] = sprintf ("\"%s\" = %s", $name, $value);
                 }
             }
 
diff --git a/classes/db/DBMssql.class.php b/classes/db/DBMssql.class.php
index 84273c7d1..f1e9101ae 100644
--- a/classes/db/DBMssql.class.php
+++ b/classes/db/DBMssql.class.php
@@ -593,12 +593,10 @@
 						$column_list[] = sprintf("[%s] = ?",  $name);
 					}else{
 						if(!$value) $value = '';
 						$column_list[] = sprintf("[%s] = %s",  $name, $value);
 					}
-
-					
                 }
             }
 
             // 조건절 정리
             $condition = $this->getCondition($output);
diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php
index 06828f4f2..1ecf09179 100644
--- a/classes/db/DBMysql.class.php
+++ b/classes/db/DBMysql.class.php
@@ -483,11 +483,12 @@
                 $name = $val['name'];
                 $value = $val['value'];
                 if(strpos($name,'.')!==false&&strpos($value,'.')!==false) $column_list[] = $name.' = '.$value;
                 else {
                     if($output->column_type[$name]!='number') $value = "'".$this->addQuotes($value)."'";
-                    elseif(!$value || is_numeric($value)) $value = (int)$value;
+					// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
+                	else $value = (int)$value;
 
                     $column_list[] = sprintf("`%s` = %s", $name, $value);
                 }
             }
 
diff --git a/classes/db/DBPostgresql.class.php b/classes/db/DBPostgresql.class.php
index 1acd019bd..1b6b64fcf 100644
--- a/classes/db/DBPostgresql.class.php
+++ b/classes/db/DBPostgresql.class.php
@@ -615,12 +615,12 @@ class DBPostgresql extends DB
             if (strpos($name, '.') !== false && strpos($value, '.') !== false)
                 $column_list[] = $name . ' = ' . $value;
             else {
                 if ($output->column_type[$name] != 'number')
                     $value = "'" . $this->addQuotes($value) . "'";
-                elseif (!$value || is_numeric($value))
-                    $value = (int)$value;
+				// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
+				else $value = (int)$value;
 
                 $column_list[] = sprintf("%s = %s", $name, $value);
             }
         }
 
diff --git a/classes/db/DBSqlite2.class.php b/classes/db/DBSqlite2.class.php
index b998701d2..2dc441050 100644
--- a/classes/db/DBSqlite2.class.php
+++ b/classes/db/DBSqlite2.class.php
@@ -461,11 +461,12 @@
                     $name = $val['name'];
                     $value = $val['value'];
                     if(strpos($name,'.')!==false&&strpos($value,'.')!==false) $column_list[] = $name.' = '.$value;
                     else {
                         if($output->column_type[$name]!='number') $value = "'".$this->addQuotes($value)."'";
-                        elseif(!$value || is_numeric($value)) $value = (int)$value;
+						// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
+						else $value = (int)$value;
 
                         $column_list[] = sprintf("%s = %s", $name, $value);
                     }
                 }
 
diff --git a/classes/db/DBSqlite3_pdo.class.php b/classes/db/DBSqlite3_pdo.class.php
index c624eba11..d8f9db650 100644
--- a/classes/db/DBSqlite3_pdo.class.php
+++ b/classes/db/DBSqlite3_pdo.class.php
@@ -498,11 +498,12 @@
                     $name = $val['name'];
                     $value = $val['value'];
                     if(strpos($name,'.')!==false&&strpos($value,'.')!==false) $column_list[] = $name.' = '.$value;
                     else {
                         if($output->column_type[$name]!='number') $value = "'".$this->addQuotes($value)."'";
-                        elseif(!$value || is_numeric($value)) $value = (int)$value;
+						// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
+						else $value = (int)$value;
 
                         $column_list[] = sprintf("%s = %s", $name, $value);
                     }
                 }
 

Vulnerable code:                     elseif (!$value || is_numeric ($value)) {
                        $value = (int) $value;
                    }

					
                    elseif(!$value || is_numeric($value)) $value = (int)$value;
                elseif (!$value || is_numeric($value))
                    $value = (int)$value;
                        elseif(!$value || is_numeric($value)) $value = (int)$value;
                        elseif(!$value || is_numeric($value)) $value = (int)$value;
Fixed code: 					// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
					else $value = (int)$value;
					// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
                	else $value = (int)$value;
				// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
				else $value = (int)$value;
						// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
						else $value = (int)$value;
						// sql injection 문제로 xml 선언이 number인 경우이면서 넘어온 값이 숫자형이 아니면 숫자형으로 강제 형변환
						else $value = (int)$value;