Auto-loaded .c2pconfig path key overrides the caller-specified root, redirecting file reads

未关闭 适合新手
#355 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
cli, security

调研方向

从 config_loader::load_config 开始,在这里 .c2pconfig 会从工作目录自动加载,然后沿该值进入 config::build_session,查看配置 path 在哪里优先于 CLI 路径参数。先复现:创建一个包含 .c2pconfig 的目录,将 path 设为另一个目录,用显式路径运行命令,并确认扫描了错误的目录。在翻转优先级使 CLI 优先后,检查配置和 CLI 解析测试,并添加一个覆盖显式路径加自动加载配置的用例。完成意味着使用显式路径参数,并且复现时不再输出另一个目录的内容。

由索引模型根据 Issue 内容生成。

描述

Summary

Configuration injection in code2prompt: config_loader::load_config auto-loads .c2pconfig from the current working directory. In config::build_session the config path takes precedence over the CLI path argument, so untrusted repo content can silently redirect the scan to an arbitrary local directory.

To reproduce

Create a repo containing .c2pconfig with 'path = ""' and default_output = "stdout", then run 'code2prompt -q -O - ' from that repo. The explicit path is ignored.

Expected

CLI path argument should override the config path per documented precedence.

Actual

The config-redirected directory was scanned and its marker emitted

Independent CLI reproduction confirmed that an auto-loaded .c2pconfig 'path' key overrides an explicit CLI path argument: running 'code2prompt -q -O - /tmp/other' from a directory whose .c2pconfig sets path= emitted the secret-dir marker and not the requested directory, contradicting the documented 'CLI Arguments > Configuration File' precedence.

Observed side effect:

Project Path: v3-secret-1795224564

Source Tree:

```txt
v3-secret-1795224564
└── marker.txt

marker.txt:

CONFIG_LEAKED_SECRET_98765_VERIFY_2026_MARKER


## Impact

Arbitrary local directory read redirection to the caller/LLM context via malicious repo content.

## Version

v4.2.0
主要语言
Rust
星标
7.8k
派生
459
平均合并
3 天 20 小时
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

mufeedvh/code2prompt 的其他 Issue

查看 mufeedvh/code2prompt 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。