unserialize __wakeup bypass
还没有人认领这个 Issue。
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.2k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
The following code:
<?php
class A
{
public $info;
private $end = "1";
public function __destruct()
{
$this->info->func();
}
}
class B
{
public $end;
public function __wakeup()
{
$this->end = "exit();";
echo '__wakeup';
}
public function __call($method, $args)
{
eval('echo "aaaa";' . $this->end . 'echo "bbb"');
}
}
unserialize($_POST['data']);
I found an interesting bug. When the deserialized string contains a variable name with the wrong string length, the deserialization continues, but the __destruct() function is called before __wakeup is called. This way you can bypass __wakeup().
I've tested it on some versions and I'm not sure if others have this problem, it's also useful in the latest version.
- 7.4.x -7.4.30
- 8.0.x
[POST]data=O:1:"A":2:{s:4:"info";O:1:"B":1:{s:3:"end";N;}s:6:"Aend";s:1:"1";}
This event also is triggered when
- delete )
- Inconsistent number of class attributes
- The length of the attribute key does not match.
- The length of the attribute value does not match.
- delete ;
Expected Results:
aaaa bbb __wakeup
PHP Version
PHP 7.4.x PHP8.0.x
Operating System
Windows/Linux
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用列出的 PHP 7.4 和 8.0 版本重现所提供的 POST 数据,然后跟踪 B::__wakeup() 和 A::__destruct() 周围的 unserialize 生命周期。将观察到的顺序与预期输出进行比较,并确定一个可测试的生命周期不变量;该 issue 未标识源文件,也未指定所需的修复方案。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- backend, security
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100