Concrete5 <= 220.127.116.11 Sendmail Remote Code Execution Vulnerability
Concrete5 version 18.104.22.168.
Minded Security ReferenceID:
Egidio Romano of Minded Security
egidio.romano [_at_] mindedsecurity.com
Update to version 5.7.4 or later.
Minded Security Consultants discovered during a Secure Code Review activity that Concrete5 <= 22.214.171.124 is vulnerable to a Remote Code Execution (RCE) vulnerability affecting websites which use sendmail as mail server.
The vulnerable code is located within the Open::update_registration_type() method, within the /concrete/controllers/single_page/dashboard/system/registration/open.php script (lines 13-53).
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.
An attacker can leverage a Cross-Site Request Forgery (CSRF) vulnerability related to the Public Registration Settings to force an authenticated administrator user into browsing to a web page like this:
<form method="POST" action="http://[host]/index.php/dashboard/system/registration/open/update_registration_type">
<input type="hidden" name="registration_type" value="enabled">
<input type="hidden" name="register_notification" value="1">
<input type="hidden" name="register_notification_email" value="email@example.com -OQueueDirectory=/tmp -X /var/www/concrete5/updates/test.php">
<input type="hidden" name="ccm-submit-registration-type-form" value="Save">
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 firstname.lastname@example.org -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. When the new account will be created a notification email will be sent, and the attacker can browse to http://[host]/updates/test.php in order to execute the injected PHP code
[05/05/2015] - Vulnerability details sent through HackerOne
[05/05/2015] - Vendor said a patch has been committed and will be available in the next version
[05/07/2015] - Version 5.7.4 released along with the patch for this vulnerability
[06/06/2015] - Vulnerability publicly disclosed on HackerOne
[06/11/2015] - CVE number requested
[06/23/2015] - CVE number assigned
The information within this paper may change without notice. Use of this information constitutes acceptance for use in an AS IS condition. There are NO warranties with regard to this information.
In no event shall the author be liable for any damages whatsoever arising out of or in connection with the use or spread of this information.
Any use of this information is at the user's own risk. Permission is hereby granted for the redistribution of this Alert electronically. It is not to be edited in any way without express consent of Minded Security Research Lab. If you wish to reprint the whole or any part of this Alert in any other medium excluding
electronic medium, please e-mail research_at_mindedsecurity.com for permission.
Copyright (c) 2015 Minded Security, S.r.l..
All rights reserved worldwide.