FileStore: symlinked parent directories escape the store root

オープン
#2,078 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

@caiotheodoro がすでに取り組んでいます。

2026年11月25日 から。

  • #2079 @caiotheodoro による — オープン

評価

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

調査の方向性

Start with anthropic/lib/tools/_file_store.py and trace how each listed operation resolves paths beneath the store root; the issue identifies parent symlinks as the gap in the leaf-only O_NOFOLLOW check. Run the reproduction on macOS or Linux and check the FileStore tests for the affected verbs. Done means paths through a symlinked parent raise FileStoreError instead of accessing files outside the root; an open linked pull request is already addressing this issue.

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

説明

FileStore paths can escape the root through a symlinked parent

FileStore blocks lexical .. paths and refuses symlinked leaf files, but it doesn't validate symlinked directories in the middle of a path. A pre-existing symlink below the root is enough to read, write, move, or delete files outside the store.

Repro on macOS/Linux:

import os
import tempfile
from pathlib import Path

import anyio

from anthropic.lib.tools._file_store import FileStore

async def repro():
    with tempfile.TemporaryDirectory() as td:
        base = Path(td)
        outside = base / "outside"
        outside.mkdir()
        (outside / "secret.md").write_text("secret")

        store = await FileStore.open(base / "store")
        await store.create_root()
        os.symlink(outside, store.root().path / "link")

        await store.put("link/new.md", "written outside")
        assert (outside / "new.md").read_text() == "written outside"

        assert await store.get("link/secret.md") == b"secret"

        await store.remove("link/secret.md")
        assert not (outside / "secret.md").exists()

anyio.run(repro)

Expected: each operation raises FileStoreError, since link/... escapes the confined root.

Actual: the operations follow the symlink and act on the outside directory.

This affects every verb that resolves a path below the root (put, get, ls, find_symlinks, hashtree, hash_file, move, and remove). The leaf-only O_NOFOLLOW check doesn't protect parent components.

主要言語
Python
スター
4.1k
フォーク
915
PR マージ指標
30日以内にマージされた PR はありません

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

anthropics/anthropic-sdk-python のほかの issue

anthropics/anthropic-sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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