Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:29781
HistorySep 09, 2013 - 12:00 a.m.

[KIS-2013-06] vtiger CRM <= 5.4.0 (SOAP Services) Multiple SQL Injection Vulnerabilities

2013-09-0900:00:00
vulners.com
28

vtiger CRM <= 5.4.0 (SOAP Services) Multiple SQL Injection Vulnerabilities

[-] Software Link:

http://www.vtiger.com/

[-] Affected Versions:

All versions from 5.0.0 to 5.4.0.

[-] Vulnerability Description:

1) The vulnerable code is located in the get_picklists SOAP method defined in /soap/customerportal.php:

  1. $id = $input_array[&#39;id&#39;];
    
  2. $sessionid = $input_array[&#39;sessionid&#39;];
    
  3. $picklist_name = $adb-&gt;sql_escape_string&#40;$input_array[&#39;picklist_name&#39;]&#41;;
    
  4. if&#40;!validateSession&#40;$id,$sessionid&#41;&#41;
    
  5. return null;
    
  6. $picklist_array = Array&#40;&#41;;
    
  7. $admin_role = &#39;H2&#39;;
    
  8. $userid = getPortalUserid&#40;&#41;;
    
  9. $roleres = $adb-&gt;pquery&#40;&quot;SELECT roleid from vtiger_user2role where userid = ?&quot;, array&#40;$userid&#41;&#41;;
    
  10. $RowCount = $adb-&gt;num_rows&#40;$roleres&#41;;
    
  11. if&#40;$RowCount &gt; 0&#41;{
    
  12.     $admin_role = $adb-&gt;query_result&#40;$roleres,0,&#39;roleid&#39;&#41;;
    
  13. }
    
  14. $res = $adb-&gt;pquery&#40;&quot;select vtiger_&quot;. $picklist_name.&quot;.* from vtiger_&quot;. $picklist_name.&quot; inner join [...]
    

User input passed through the "picklist_name" parameter seems to be correctly sanitised by the
sql_escape_string() method, but the vulnerability exists because it's used in the query at line 1194
without single or double quotes. This can be exploited to conduct blind SQL injection attacks.

2) The vulnerable code is located in the get_tickets_list SOAP method defined in /soap/customerportal.php:

  1. $id = $input_array[&#39;id&#39;];
    
  2. $only_mine = $input_array[&#39;onlymine&#39;];
    
  3. $where = $input_array[&#39;where&#39;]; //addslashes is already added with where condition fields in portal itself
    
  4. $match = $input_array[&#39;match&#39;];
    
  5. $sessionid = $input_array[&#39;sessionid&#39;];
    
  6. if&#40;!validateSession&#40;$id,$sessionid&#41;&#41;
    
  7.     return null;
    
  8. // Prepare where conditions based on search query
    
  9. $join_type = &#39;&#39;;
    
  10. $where_conditions = &#39;&#39;;
    
  11. if&#40;trim&#40;$where&#41; != &#39;&#39;&#41; {
    
  12.     if&#40;$match == &#39;all&#39; || $match == &#39;&#39;&#41; {
    
  13.         $join_type = &quot; AND &quot;;
    
  14.     } elseif&#40;$match == &#39;any&#39;&#41; {
    
  15.         $join_type = &quot; OR &quot;;
    
  16.     }
    
  17.     $where = explode&#40;&quot;&amp;&amp;&amp;&quot;,$where&#41;;
    
  18.     $where_conditions = implode&#40;$join_type, $where&#41;;
    

[…]

  1. $query = &quot;SELECT vtiger_troubletickets.*, vtiger_crmentity.smownerid,vtiger_crmentity.createdtime, [...]
    
  2.     FROM vtiger_troubletickets
    
  3.     INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid AND [...]
    
  4.     WHERE vtiger_troubletickets.parent_id IN &#40;&quot;. generateQuestionMarks&#40;$entity_ids_list&#41; .&quot;&#41;&quot;;
    
  5. // Add conditions if there are any search parameters
    
  6. if &#40;$join_type != &#39;&#39; &amp;&amp; $where_conditions != &#39;&#39;&#41; {
    
  7.     $query .= &quot; AND &#40;&quot;.$where_conditions.&quot;&#41;&quot;;
    
  8. }
    

User input passed through the "where" parameter isn't properly validated before being
used in a SQL query at line 713. This can be exploited to conduct SQL injection attacks.

3) The vulnerable code is located in the SearchContactsByEmail SOAP method defined in /soap/thunderbirdplugin.php:

  1. function SearchContactsByEmail($username,$password,$emailaddress)
  2. {
  3.  if&#40;authentication&#40;$username,$password&#41;&#41;
    
  4.  {
    
  5.     require_once&#40;&#39;modules/Contacts/Contacts.php&#39;&#41;;
    
  6.     $seed_contact = new Contacts&#40;&#41;;
    
  7.     $output_list = Array&#40;&#41;;
    
  8.     $response = $seed_contact-&gt;get_searchbyemailid&#40;$username,$emailaddress&#41;;
    

User input passed through the "emailaddress" parameter isn't properly validated before being used
in a call to the Contacts::get_searchbyemailid() method at line 195. This can be exploited to conduct
SQL injection attacks. Successful exploitation of this vulnerability requires authentication.

4) The vulnerable code is located in the SearchContactsByEmail SOAP method defined in /soap/vtigerolservice.php:

  1. function SearchContactsByEmail($username,$session,$emailaddress)
  2. {
  3.    if&#40;!validateSession&#40;$username,$session&#41;&#41;
    
  4.    return null;
    
  5.    require_once&#40;&#39;modules/Contacts/Contacts.php&#39;&#41;;
    
  6.     $seed_contact = new Contacts&#40;&#41;;
    
  7.     $output_list = Array&#40;&#41;;
    
  8.     $response = $seed_contact-&gt;get_searchbyemailid&#40;$username,$emailaddress&#41;;
    

User input passed through the "emailaddress" parameter isn't properly validated before being used in
a call to the Contacts::get_searchbyemailid() method at line 291. This can be exploited to conduct SQL
injection attacks. Successful exploitation of this vulnerability requires knowledge of a valid username.

[-] Solution:

Apply the vendor patch:http://www.vtiger.com/blogs/?p=1467

[-] Disclosure Timeline:

[13/01/2013] - Vendor notified
[06/02/2013] - Vendor asked feedback abouthttp://trac.vtiger.com/cgi-bin/trac.cgi/changeset/13848
[05/03/2013] - Feedback provided to the vendor
[26/03/2013] - Vendor patch released
[18/04/2013] - CVE number requested
[20/04/2013] - CVE number assigned
[01/08/2013] - Public disclosure

[-] CVE Reference:

The Common Vulnerabilities and Exposures project (cve.mitre.org)
has assigned the name CVE-2013-3213 to these vulnerabilities.

[-] Credits:

Vulnerabilities discovered by Egidio Romano.

[-] Original Advisory:

http://karmainsecurity.com/KIS-2013-06