[null, null, {"document_url": "http://console-cowboys.blogspot.com/2012/07/extending-your-ganglia-install-with.html", "unformatted_src": "http://2.bp.blogspot.com/-jV6F-dDsWz4/T_8c_sgmXUI/AAAAAAAAAb0/9gRSHgMXzhQ/s400/2.PNG", "src": "http://2.bp.blogspot.com/-jV6F-dDsWz4/T_8c_sgmXUI/AAAAAAAAAb0/9gRSHgMXzhQ/s400/2.PNG", "rendered_width": 400, "rendered_height": 312}, null, {"document_url": "http://console-cowboys.blogspot.com/2012/07/extending-your-ganglia-install-with.html", "unformatted_src": "http://4.bp.blogspot.com/-Dj14_NK-wL4/T_8gG4lzqCI/AAAAAAAAAcA/2z90zBEEXkg/s400/3.PNG", "src": "http://4.bp.blogspot.com/-Dj14_NK-wL4/T_8gG4lzqCI/AAAAAAAAAcA/2z90zBEEXkg/s400/3.PNG", "rendered_width": 400, "rendered_height": 270}, null, {"document_url": "http://console-cowboys.blogspot.com/2012/07/extending-your-ganglia-install-with.html", "unformatted_src": "http://1.bp.blogspot.com/-aBZs3vzLWtA/T_8hMpRrOYI/AAAAAAAAAcI/iEw5EMls3NI/s400/4.PNG", "src": "http://1.bp.blogspot.com/-aBZs3vzLWtA/T_8hMpRrOYI/AAAAAAAAAcI/iEw5EMls3NI/s400/4.PNG", "rendered_width": 400, "rendered_height": 313}, null, null]

Extending Your Ganglia Install with the Remote Code Execution API

Previously I had gone over a somewhat limited local file include in the Ganglia monitoring application (http://ganglia.info). The previous article can be found here -

I recently grabbed the latest version of the Ganglia web application to take a look to see if this issue has been fixed and I was pleasantly surprised... github is over here -
Looking at the code the following (abbreviated "graph.php") sequence can be found -

$graph = isset($_GET["g"])  ?  sanitize ( $_GET["g"] )   : "metric";
$graph_arguments = NULL;
$pos = strpos($graph, ",");
$graph_arguments = substr($graph, $pos + 1);
eval('$graph_function($rrdtool_graph,' . $graph_arguments . ');');

I can only guess that this previous snippet of code was meant to be used as some sort of API put in place for remote developers, unfortunately it is slightly broken. For some reason when this API was being developed part of its interface was wrapped in the following function -

This limitation of the API means we cannot simply pass in a function like eval, exec, system, or use backticks to create our Ganglia extension. Our only option is to use PHP functions that do not require "(" or ")" a quick look at the available options (http://www.php.net/manual/en/reserved.keywords.php) it looks like "include" would work nicely. An example API request that would help with administrative reporting follows: Very helpful, we can get a nice report with a list of current system users. Reporting like this is a nice feature but what we really would like to do is create a new extension that allows us to execute system commands on the Ganglia system. After a brief examination of the application it was found that we can leverage some other functionality of the application to finalize our Ganglia extension. The "events" page allows for a Ganglia user to configure events in the system, I am not exactly sure what type of events you would configure, but I hope that I am invited. As you can see in the screen shot I have marked the "Event Summary" with "php here". When creating our API extension event we will fill in this event with the command we wish to run, see the following example request - This request will set up an "event" that will let everyone know who you are, that would be the friendly thing to do when attending an event. We can now go ahead and wire up our API call to attend our newly created event. Since we know that Ganglia keeps track of all planned events in the following location "/var/lib/ganglia/conf/events.json" lets go ahead and include this file in our API call - As you can see we have successfully made our API call and let everyone know at the "event" that our name is "www-data". From here I will leave the rest of the API development up to you. I hope this article will get you started on your Ganglia API development and you are able to implement whatever functionality your environment requires. Thanks for following along.

Update: This issue has been assigned CVE-2012-3448
Posted by someLuser at 11:21 AM Labels: code execution, CVE-2012-3448, el oh el, exploit, ganglia, LFI, local file include, lolguide, rce, vulnerability


