Nested unserialize() can expose an outer object while its __unserialize() data is still being parsed
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
The issue provides a PHP reproducer that triggers the bug in php-src's unserialize. Investigate the C parser handling nested unserialize calls and shared reference tables; no specific files are named. A fix requires a design decision on rejecting references versus preserving cyclic payloads, and validation with the reproducer.
由索引模型根据 Issue 内容生成。
描述
Description
A nested unserialize() call from Serializable::unserialize() shares the outer reference table. An r/R record can therefore resolve to an outer object whose __unserialize() data is still being parsed. At that point __unserialize() has not been queued and cannot be called because the outer parser frame is suspended.
If inner code only stores the object, identity is preserved and it is initialized later. If it accesses the object immediately, it observes incomplete userland properties and could reach uninitialized native state for internal classes.
Unlike GH-19860, this object is not fully parsed, so finishing pending callbacks at the nested boundary cannot fix this case.
Reproducer
<?php
class Outer {
public string $value;
public function __unserialize(array $data): void {
$this->value = "ready";
}
}
class Legacy implements Serializable {
public function serialize(): string {
return "";
}
public function unserialize(string $data): void {
$object = unserialize($data);
var_dump(isset($object->value));
}
public function __serialize(): array {
return [];
}
public function __unserialize(array $data): void {}
}
$result = unserialize("O:5:\"Outer\":1:{i:0;C:6:\"Legacy\":4:{r:1;}}");
echo $result->value, "\n";
Output:
bool(false)
ready
Expected behavior
This needs a separate design decision. Rejecting these references prevents unsafe access, but breaks cyclic payloads that previously retained the object until initialization completed.
- 主要语言
- C
- 星标
- 41.8k
- 派生
- 8.5k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 137
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
php/php-src 的其他 Issue
-
SNMP accepts malformed remote ports可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
Bug Status: Needs Triage
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
quoted_printable_encode() produces lines longer than 76 characters for bytes 0xF5 to 0xFF可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Bug Status: Needs Triage
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
Feature Status: Needs Triage
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
相似的 Issue
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 82/100
-
bug multiplayer status: planned
难度 2/5 1-3 小时 新手友好度 67/100
ChupathingyCE/chupathingyce#851 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 73/100
HigherOrderCO/Bend#2104 ·
-
research-radar
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
good first issue help wanted program
难度 2/5 1-3 小时 新手友好度 83/100
hffgzktbcc-blip/ounce-core#297 ·
维护者通常 1 天内回复