PT-2012-30: Administrator Privilege Gaining in OpenCart

CRITICAL
(9.3) (AV:N/AC:M/Au:N/C:C/I:C/A:C)

(PT-2012-30) Positive Technologies Security Advisory
Administrator Privilege Gaining in OpenCart

Vulnerable software

OpenCart
Version: 1.5.3.1 and earlier

Application link:
http://www.opencart.com/

Severity level

Severity level: High
Impact: Administrator Privilege Gaining
Access Vector: Remote  

CVSS v2:
Base Score: 9.3
Vector: (AV:N/AC:M/Au:N/C:C/I:C/A:C)

CVE: not assign

Software description

OpenCart is a powerful open source shopping cart system that is designed feature rich and user friendly.

Vulnerability description

The specialists of the Positive Research center have detected "Administrator Privilege Gaining" vulnerability in OpenCart.

An attacker can get administrator password and other forum users' passwords because of insecure random number generator used in password recovery feature.

1. Predictable confirmation code used for administrator password recovery

Vulnerable code: admin/controller/common/forgotten.php

$code = md5(mt_rand());

Administrator email is necessary for password recovery. If an attacker knows administrator email (mostly emails like admin@host.com are used), he can easily change its password.
It is possible as OpenCart gets random numbers from  PHP function mt_rand that implements Mersenne Twister algorithm and does not initiate random number generator with mt_srand function.
In this case, PHP automatically uses quasi-random 32 bit integer number based on the current process environmental data to initiate the generator.
With mt_rand result an attacker is able to get the source value used to initialize the random generator via brute force (2^32 alternatives).
It is possible to get  mt_rand  results in MD5 hash form in OpenCart:

POST /admin/index.php?route=user/user HTTP/1.0
Host: host
host 0
Connection: keep-alive

 

HTTP/1.1 302
...
Location: http://host/admin/index.php?route=common/home&token=2ead018af57862dda59cb67b77f19075

Therefore, if an attacker decrypts MD5 and gets the random number, he is able to get the source value used for random number generating.  With this value, he is able to predict all further random numbers.
The attacker has to send 2 keep-alive requests to implement the attack. The first request allows the attacker to get MD-5 hash of the random value, the second one is used to call for the page that recovers administrator's password. This allows the attacker to get confirmation code and change the password.

2. Predictable generated password in case user or affiliate password is recovered

Vulnerable code: catalog/controller/account/forgotten.php, catalog/controller/affiliate/forgotten.php

$password = substr(md5(mt_rand()), 0, 10);

User email is necessary for password recovery. If an attacker knows user's email, he is able to change its password without confirmation, new password is just sent to user's email.
An attacker can use the same method as for administrator account to predict user's password.

How to fix

Update your software up to the latest version

Advisory status

23.08.2012 - Vendor is notified
23.08.2012 - Vendor gets vulnerability details
23.08.2012 - Vendor releases fixed version and details
11.09.2012 - Public disclosure

Credits

The vulnerabilities has discovered by Arseny Reutov, Positive Research Center (Positive Technologies Company)

References

http://en.securitylab.ru/lab/PT-2012-30

Reports on the vulnerabilities previously discovered by Positive Research:

http://ptsecurity.com/research/advisory/
http://en.securitylab.ru/lab/

About Positive Technologies

Positive Technologies www.ptsecurity.com is among the key players in the IT security market in Russia.

The principal activities of the company include the development of integrated tools for information security monitoring (MaxPatrol); providing IT security consulting services and technical support; development of the Securitylab leading Russian information security portal.

Among the clients of Positive Technologies, there are more than 40 state enterprises, more than 50 banks and financial organizations, 20 telecommunication companies, more than 40 plant facilities, as well as IT, service and retail companies from Russia, the CIS countries, the Baltic States, China, Ecuador, Germany, Great Britain, Holland, Iran, Israel, Japan, Mexico, the Republic of South Africa, Thailand, Turkey, and the USA.

Positive Technologies is a team of highly skilled developers, advisers and experts with years of vast hands-on experience. The company specialists possess professional titles and certificates; they are the members of various international societies and are actively involved in the IT security field development.

Vendor:
OpenCart Limited
Vulnerable product:
OpenCart 1.x

Get in touch

Fill in the form and our specialists
will contact you shortly