FileStore: symlinked parent directories escape the store root

Abierto
#2,078 2 comentarios 0 reacciones 0 asignados Ver en GitHub

@caiotheodoro ya está trabajando en esto.

Desde el 25/11/2026.

  • #2079 de @caiotheodoro — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend, security

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
4.1k
Forks
915
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de anthropics/anthropic-sdk-python

Todos los issues de anthropics/anthropic-sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.