CVE-2012-4237 - Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Severity

68%

Complexity

86%

Confidentiality

106%

Multiple SQL injection vulnerabilities in TCExam before 11.3.008 allow remote authenticated users with level 5 or greater permissions to execute arbitrary SQL commands via the subject_module_id parameter to (1) tce_edit_answer.php or (2) tce_edit_question.php.

Multiple SQL injection vulnerabilities in TCExam before 11.3.008 allow remote authenticated users with level 5 or greater permissions to execute arbitrary SQL commands via the subject_module_id parameter to (1) tce_edit_answer.php or (2) tce_edit_question.php.

CVSS 2.0 Base Score 6.8. CVSS Attack Vector: network. CVSS Attack Complexity: medium. CVSS Vector: (AV:N/AC:M/Au:N/C:P/I:P/A:P).

Demo Examples

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

CWE-89

In 2008, a large number of web servers were compromised using the same SQL injection attack string. This single string worked against many different programs. The SQL injection was then used to modify the web sites to serve malicious code.

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

CWE-89

The following code dynamically constructs and executes a SQL query that searches for items matching a specified name. The query restricts the items displayed to those where owner matches the user name of the currently-authenticated user.


               
...

The query that this code intends to execute follows:


               
SELECT * FROM items WHERE owner = <userName> AND itemname = <itemName>;

However, because the query is constructed dynamically by concatenating a constant base query string and a user input string, the query only behaves correctly if itemName does not contain a single-quote character. If an attacker with the user name wiley enters the string:


               
name' OR 'a'='a

for itemName, then the query becomes the following:


               
SELECT * FROM items WHERE owner = 'wiley' AND itemname = 'name' OR 'a'='a';

The addition of the:


               
OR 'a'='a

condition causes the WHERE clause to always evaluate to true, so the query becomes logically equivalent to the much simpler query:


               
SELECT * FROM items;

This simplification of the query allows the attacker to bypass the requirement that the query only return items owned by the authenticated user; the query now returns all entries stored in the items table, regardless of their specified owner.

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

CWE-89

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

CWE-89

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

CWE-89

This code intends to print a message summary given the message ID.


               
mysql_query("SELECT MessageID, Subject FROM messages WHERE MessageID = '$id'");

The programmer may have skipped any input validation on $id under the assumption that attackers cannot modify the cookie. However, this is easy to do with custom client code or even in the web browser.

While $id is wrapped in single quotes in the call to mysql_query(), an attacker could simply change the incoming mid cookie to:


               
1432' or '1' = '1

This would produce the resulting query:


               
SELECT MessageID, Subject FROM messages WHERE MessageID = '1432' or '1' = '1'

Not only will this retrieve message number 1432, it will retrieve all other messages.

In this case, the programmer could apply a simple modification to the code to eliminate the SQL injection:


               
mysql_query("SELECT MessageID, Subject FROM messages WHERE MessageID = '$id'");

However, if this code is intended to support multiple users with different message boxes, the code might also need an access control check (CWE-285) to ensure that the application user has the permission to see that message.

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

CWE-89

This example attempts to take a last name provided by a user and enter it into a database.


               
$query = "INSERT INTO last_names VALUES('$userKey', '$name')";# ensure only letters, hyphens and apostrophe are allowed

While the programmer applies a whitelist to the user input, it has shortcomings. First of all, the user is still allowed to provide hyphens which are used as comment structures in SQL. If a user specifies -- then the remainder of the statement will be treated as a comment, which may bypass security logic. Furthermore, the whitelist permits the apostrophe which is also a data / command separator in SQL. If a user supplies a name with an apostrophe, they may be able to alter the structure of the whole statement and even change control flow of the program, possibly accessing or modifying confidential information. In this situation, both the hyphen and apostrophe are legitimate characters for a last name and permitting them is required. Instead, a programmer may want to use a prepared statement or apply an encoding routine to the input to prevent any data / directive misinterpretations.

Overview

Type

Tecnick TCExam

First reported 12 years ago

2012-08-20 20:55:00

Last updated 12 years ago

2012-09-11 04:00:00

Affected Software

Tecnick TCExam 10.1.000

10.1.000

Tecnick TCExam 10.1.001

10.1.001

Tecnick TCExam 10.1.002

10.1.002

Tecnick TCExam 10.1.003

10.1.003

Tecnick TCExam 10.1.004

10.1.004

Tecnick TCExam 10.1.005

10.1.005

Tecnick TCExam 10.1.006

10.1.006

Tecnick TCExam 10.1.007

10.1.007

Tecnick TCExam 10.1.008

10.1.008

Tecnick TCExam 10.1.009

10.1.009

Tecnick TCExam 10.1.010

10.1.010

Tecnick TCExam 10.1.011

10.1.011

Tecnick TCExam 10.1.012

10.1.012

Tecnick TCExam 10.1.013

10.1.013

Tecnick TCExam 11.0.000

11.0.000

Tecnick TCExam 11.0.001

11.0.001

Tecnick TCExam 11.0.002

11.0.002

Tecnick TCExam 11.0.003

11.0.003

Tecnick TCExam 11.0.004

11.0.004

Tecnick TCExam 11.0.005

11.0.005

Tecnick TCExam 11.0.006

11.0.006

Tecnick TCExam 11.0.007

11.0.007

Tecnick TCExam 11.0.008

11.0.008

Tecnick TCExam 11.0.009

11.0.009

Tecnick TCExam 11.0.010

11.0.010

Tecnick TCExam 11.0.011

11.0.011

Tecnick TCExam 11.0.012

11.0.012

Tecnick TCExam 11.0.013

11.0.013

Tecnick TCExam 11.0.014

11.0.014

Tecnick TCExam 11.0.015

11.0.015

Tecnick TCExam 11.0.016

11.0.016

Tecnick TCExam 11.1.000

11.1.000

Tecnick TCExam 11.1.001

11.1.001

Tecnick TCExam 11.1.002

11.1.002

Tecnick TCExam 11.1.003

11.1.003

Tecnick TCExam 11.1.004

11.1.004

Tecnick TCExam 11.1.005

11.1.005

Tecnick TCExam 11.1.006

11.1.006

Tecnick TCExam 11.1.007

11.1.007

Tecnick TCExam 11.1.008

11.1.008

Tecnick TCExam 11.1.009

11.1.009

Tecnick TCExam 11.1.010

11.1.010

Tecnick TCExam 11.1.011

11.1.011

Tecnick TCExam 11.1.012

11.1.012

Tecnick TCExam 11.1.013

11.1.013

Tecnick TCExam 11.1.014

11.1.014

Tecnick TCExam 11.1.015

11.1.015

Tecnick TCExam 11.1.016

11.1.016

Tecnick TCExam 11.1.017

11.1.017

Tecnick TCExam 11.1.018

11.1.018

Tecnick TCExam 11.1.019

11.1.019

Tecnick TCExam 11.1.020

11.1.020

Tecnick TCExam 11.1.021

11.1.021

Tecnick TCExam 11.1.022

11.1.022

Tecnick TCExam 11.1.023

11.1.023

Tecnick TCExam 11.1.024

11.1.024

Tecnick TCExam 11.1.025

11.1.025

Tecnick TCExam 11.1.026

11.1.026

Tecnick TCExam 11.1.027

11.1.027

Tecnick TCExam 11.1.028

11.1.028

Tecnick TCExam 11.1.029

11.1.029

Tecnick TCExam 11.1.030

11.1.030

Tecnick TCExam 11.1.031

11.1.031

Tecnick TCExam 11.2.000

11.2.000

Tecnick TCExam 11.2.001

11.2.001

Tecnick TCExam 11.2.002

11.2.002

Tecnick TCExam 11.2.003

11.2.003

Tecnick TCExam 11.2.004

11.2.004

Tecnick TCExam 11.2.005

11.2.005

Tecnick TCExam 11.2.006

11.2.006

Tecnick TCExam 11.2.007

11.2.007

Tecnick TCExam 11.2.008

11.2.008

Tecnick TCExam 11.2.010

11.2.010

Tecnick TCExam 11.2.011

11.2.011

Tecnick TCExam 11.2.012

11.2.012

Tecnick TCExam 11.2.013

11.2.013

Tecnick TCExam 11.2.014

11.2.014

Tecnick TCExam 11.2.015

11.2.015

Tecnick TCExam 11.2.016

11.2.016

Tecnick TCExam 11.2.017

11.2.017

Tecnick TCExam 11.2.018

11.2.018

Tecnick TCExam 11.2.020

11.2.020

Tecnick TCExam 11.2.021

11.2.021

Tecnick TCExam 11.2.022

11.2.022

Tecnick TCExam 11.2.023

11.2.023

Tecnick TCExam 11.2.025

11.2.025

Tecnick TCExam 11.2.026

11.2.026

Tecnick TCExam 11.2.027

11.2.027

Tecnick TCExam 11.2.028

11.2.028

Tecnick TCExam 11.2.029

11.2.029

Tecnick TCExam 11.2.030

11.2.030

Tecnick TCExam 11.2.031

11.2.031

Tecnick TCExam 11.2.032

11.2.032

Tecnick TCExam 11.3.000

11.3.000

Tecnick TCExam 11.3.001

11.3.001

Tecnick TCExam 11.3.002

11.3.002

Tecnick TCExam 11.3.003

11.3.003

Tecnick TCExam 11.3.004

11.3.004

Tecnick TCExam 11.3.005

11.3.005

Tecnick TCExam 11.3.006

11.3.006

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.