Symlink-to-file inside scanned root reads file content outside the root without --follow-symlinks
还没有人认领这个 Issue。
评估
调研方向
从 discover_files() 构建队列的文件发现代码开始,然后沿着已入队的条目进入 read_file_with_binary_check。比较 Path::is_file() 和 entry.metadata() 对 root 内 symlink 与 symlink_metadata 的报告结果,并用该 issue 的 canary 设置和在默认模式下运行 code2prompt -q -O - <root> 来复现。完成意味着默认模式不输出任何 canary 字节,且有一个测试覆盖指向 root 外部的 symlink。
由索引模型根据 Issue 内容生成。
描述
Summary
discover_files() enqueues any entry whose relative path strips inside the canonical root when Path::is_file() is true. Path::is_file() follows symlinks, so a symlink to an outside regular file is queued even with follow_links=false (default). entry.metadata() returns symlink lstat metadata, whose len is the target path string length, so read_file_with_binary_check opens the link target and reads min(8192, symlink_target_len) bytes of the outside file.
To reproduce
Create an outside canary file, then an in-root symlink pointing to it (../canary.txt), and run 'code2prompt -q -O - '. Default mode still emits the canary prefix.
Expected
Symlink targets must not be read when follow_symlinks is false.
Actual
Output contains the first symlink_target_len bytes of the outside canary
Independent CLI reproduction in default mode (no -L) leaked the first 35 bytes of a canary file located outside the scanned root through an in-root symlink. The leak is bounded by the symlink target path string length (min(8192, symlink_target_len, target_file_len)); it is not a full-file read.
Observed side effect:
Project Path: v1-root-1795224537
Source Tree:
```txt
v1-root-1795224537
└── leak.txt
leak.txt:
INDEPENDENT_VERIFIER_CANARY_MARKER_
## Impact
Partial read outside the configured root, bounded by symlink target path length (up to PATH_MAX ~4096 bytes).
## Version
v4.2.0
- 主要语言
- Rust
- 星标
- 7.8k
- 派生
- 459
- 平均合并
- 3 天 20 小时
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
mufeedvh/code2prompt 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
mufeedvh/code2prompt#355 ·
-
No tag 4.3.0未关闭
难度 1/5 1 小时以内 新手友好度 72/100
mufeedvh/code2prompt#340 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 62/100
mufeedvh/code2prompt#356 ·
-
难度 3/5 1-2 天 新手友好度 66/100
mufeedvh/code2prompt#352 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 52/100
mufeedvh/code2prompt#345 ·
查看 mufeedvh/code2prompt 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
topgrade-rs/topgrade#2540 ·
维护者通常 1 天内回复
-
Invalid JSON options for ngram and edge_ngram silently use defaults可能已有人在做 @Tilendlesa 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
noemaforge/vimanam#153 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复