Malicious repository symlinks escape the clone root during indexing

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend, security

調査の方向性

api/config.py の iterate_files から始め、wiki-structure の一覧表示と api/rag/pipeline.py にある呼び出し元を追跡してください。checkout の外部を指すシンボリックリンクを含むリポジトリで動作を検証し、走査とインデックス作成でシンボリックリンクが除外され、そのリンク先を読み取れないことを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Affected versions: confirmed on main at commit d92819a9 (the project publishes no tagged release).

Summary

The repository walker used for both the wiki-structure listing and the RAG indexer (iterate_files in api/config.py) follows symlinks: it calls is_file(), which dereferences a symlink, with no is_symlink() guard. A submitted repository containing a symlink pointing outside the checkout (to any file the server process can read) has that symlink listed as a normal file, and the indexer's open() on it dereferences straight to the external target.

Details

for p in Path(root_dir).rglob("*"):
    if not p.is_file():   # follows the symlink
        continue
    ...
    results.append(os.path.relpath(p, root_dir)...)
# api/rag/pipeline.py
for relative_path in iterate_files(path, ...):
    file_path = Path(path) / relative_path
    with open(file_path, "r", ...) as f:   # dereferences the symlink
        content = f.read()

POC

(available upon request)

Impact

A repository author can commit a symlink (with an admitted extension) pointing to a server-readable file outside the checkout. Indexing that repository embeds the target's content into the wiki's RAG store, where it can later be recovered through chat/retrieval.

Suggested fix: skip symlinks during traversal rather than following them. A fix is included in the linked PR.

Fix: #596

主要言語
Python
スター
18.1k
フォーク
2k
平均マージ
5分
マージ済み PR(30日)
5

環境構築

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

はじめの一歩

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

AsyncFuncAI/deepwiki-open のほかの issue

AsyncFuncAI/deepwiki-open の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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