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

オープン 初心者向け
#355 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mufeedvh/code2prompt のほかの issue

mufeedvh/code2prompt の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。