exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

CakePHP 3.0.5 XML Class SSRF

CakePHP 3.0.5 XML Class SSRF
Posted Oct 15, 2015
Authored by Takeshi Terada

CakePHP version 3.0.5 suffers from server-side request forgery attacks that can cause a denial of service condition.

tags | exploit, denial of service
SHA-256 | 884781604e0f231e38b3b0939d779f308df6b316c6f28e028451352741412abe

CakePHP 3.0.5 XML Class SSRF

Change Mirror Download
=============================================================================
Title : CakePHP Xml class SSRF Vulnerability
CVE Number : N/A (not assigned)
Affected Software : Confirmed on CakePHP v3.0.5 (prior versions may
also be affected)
Credit : Takeshi Terada of Mitsui Bussan Secure Directions, Inc.
http://www.mbsd.jp/
Issue Status : v3.0.6/2.6.6 was released which fixes this issue
=============================================================================

Overview:
-----------------------------------------------------------------------------
CakePHP is an open-source web application framework for PHP.
CakePHP (v3.0.5) was confirmed to be vulnerable to SSRF (Server Side
Request Forgery) attacks. Remote attacker can utilize it for at least
DoS (Denial of Service) attacks, if the target application accepts
XML as an input. It is caused by insecure design of Cake's Xml class.

Details:
-----------------------------------------------------------------------------
Here is an abstract from Cake\Utility\Xml.php (v3.0.3).

96: public static function build($input, array $options = [])
97: {
....
104: if (is_array($input) || is_object($input)) {
105: return static::fromArray($input, $options);
106: }
107:
108: if (strpos($input, '<') !== false) {
109: return static::_loadXml($input, $options);
110: }
111:
112: if (file_exists($input)) {
113: return static::_loadXml(file_get_contents($input), $options);
114: }

The problematic part is line 112-114, where $input is treated as a
URL (file path) and the method tries to fetch the content of the URL,
if it does not contain any '<' character.

Therefore, if values such as those shown below are given to it,
the application will block.

1. file:///dev/random
-> blocks permanently (until so much entropy supplied)

2. /dev/urandom
-> blocks until hitting memory limit

3. ftp://very_slow_host/a
-> blocks until socket timeout

Attackers can exhaust MaxClients (on Apache), just by sending
the number of requests with these values instead of normal XML.

CakePHP seems to accept XML inputs when RequestHandlerComponent,
which is designed to handle XHR requests that may contain XML or
JSON in their body, is enabled.

http://book.cakephp.org/3.0/en/development/rest.html
http://book.cakephp.org/3.0/en/controllers/components/request-handling.html

When the component is enabled and a request has necessary headers
(Content-Type and X-Requested-With), raw body of the request is
passed to Xml::build() directly (i.e. without validation), which
can obviously be used for attacks.

However, it seems hard to successfully conduct other types of
attack than DoS, because there are some hurdles for attackers.
Firstly, usual web applications are unlikely to return the full
request data. This means there is very little opportunity for file
theft attacks, regardless of whether the target file is XML or not.
The second hurdle is file_exists() check in line 112, which results
in URLs with interesting schemes like "expect" and "http" being
rejected.

But still DoS and timing attacks like internal network scan using
ftp URL's are possible. Additionally, in CakePHP v2, attackers can
also use http(s) URLs for such attacks, as Cake2 accepts URLs with
these schemes.

Timeline:
-----------------------------------------------------------------------------
2015/05/27 Reported to CakePHP Security ML
2015/05/29 Vender announced v3.0.6 & 2.6.6
2015/10/15 Disclosure of this advisory

Recommendation:
-----------------------------------------------------------------------------
Upgrading to the latest versions is recommended, if your app
accepts XML data, as stated in the release note.

https://github.com/cakephp/cakephp/releases/tag/3.0.6

One thing I think should be noted is that the default behavior
of the method (Xml::build()) was kept as it had been, in order to
avoid compatibility problems.

https://github.com/cakephp/cakephp/commit/2cde19f24c3679e8162e3abbce73818a8b0c02a0

This means you need to modify your program, if you pass untrusted
data to the method in your own program code to deal with XML.
Technically, specifying a newly created option (readFile = false)
for the method disables URL loading feature, thus can prevent DoS
and other relevant attacks. See the URL above (github commit log)
for details.

--
Takeshi Terada
Mitsui Bussan Secure Directions, Inc.
http://www.mbsd.jp/


Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    34 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    19 Files
  • 23
    Jul 23rd
    17 Files
  • 24
    Jul 24th
    47 Files
  • 25
    Jul 25th
    31 Files
  • 26
    Jul 26th
    13 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    27 Files
  • 30
    Jul 30th
    49 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close