Can open files using invalid paths
未关闭
还没有人认领这个 Issue。
Bug
Category: Filesystem
Category: Streams
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.2k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
The path / /../ /../ /../ /../path/to/file is considered invalid by some file check functions:
<?php
is_file("/ /../ /../ /../ /../path/to/file"); // -> false
realpath("/ /../ /../ /../ /../path/to/file"); // -> false
filesize("/ /../ /../ /../ /../path/to/file"); // -> false
However, the path can actually be used to open /path/to/file :
<?php
echo file_get_contents("/ /../ /../ /../ /../path/to/file");
$res = fopen("/ /../ /../ /../ /../path/to/file", "r");
echo fread($res, 1024);
PHP Version
< 8.3
Operating System
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
复现 issue 中的确切路径,并将 file_get_contents() 和 fopen() 与 is_file()、realpath() 以及 filesize() 进行比较。由于没有指定源文件或测试,首先定位 PHP 文件打开和路径验证的入口点,然后添加覆盖,展示这些 API 是否应以一致的方式处理该路径。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100