Auto-loaded .c2pconfig path key overrides the caller-specified root, redirecting file reads
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start in config_loader::load_config, where .c2pconfig is auto-loaded from the working directory, then follow the value into config::build_session to see where the config path wins over the CLI path argument. Reproduce first: create a directory with a .c2pconfig setting path to another dir, run the command with an explicit path, and confirm the wrong directory is scanned. After flipping the precedence so CLI wins, check the config and CLI parsing tests and add a case covering an explicit path plus an auto-loaded config. Done means the explicit path argument is used and the reproduction no longer emits the other directory's contents.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Rust
- Stars
- 7.8k
- Forks
- 459
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mufeedvh/code2prompt
-
Symlink-to-file inside scanned root reads file content outside the root without --follow-symlinksOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mufeedvh/code2prompt#354 ·
-
No tag 4.3.0Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
mufeedvh/code2prompt#340 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
mufeedvh/code2prompt#356 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
mufeedvh/code2prompt#352 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
mufeedvh/code2prompt#345 ·
All issues in mufeedvh/code2prompt
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
topgrade-rs/topgrade#2540 ·
Maintainers usually reply within 1 day
-
Invalid JSON options for ngram and edge_ngram silently use defaultsPossibly taken @Tilendlesa claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
noemaforge/vimanam#153 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day