FileStore: symlinked parent directories escape the store root

Đang mở
#2,078 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

@caiotheodoro đang làm issue này rồi.

Từ ngày 25/11/2026.

  • #2079 của @caiotheodoro — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend, security

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
4.1k
Fork
915
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anthropics/anthropic-sdk-python

Tất cả issue của anthropics/anthropic-sdk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.