Unauthenticated local-path APIs disclose arbitrary server files

Abierto
#601 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

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
Activo
Stack tecnológico
python
Área
api, backend, security

Línea de trabajo

Start with api/repository.py and api/services/codemap.py, then trace the public /codemap/file, /local_repo/structure, and /repo/prepare routes. Verify how repo_url becomes save_path and how containment is checked for local paths. Done means local paths are restricted to an operator-owned allowlisted root before file reading, structure access, or indexing; the issue notes that a fix is included in #594.

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

Descripción

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

Summary

Multiple public routes (/codemap/file, /local_repo/structure, /repo/prepare) accept a caller-chosen local filesystem root via repo_url. Repo.is_local treats any value that isn't an http(s)/ftp URL with a host as a trusted local path, and Repo.save_path returned it unchanged with no containment. Selecting repo_url=/ makes any server-readable file reachable: /codemap/file returns its content directly, and /repo/prepare's indexer reads and embeds the whole tree.

Details

# api/repository.py
@property
def is_local(self) -> bool:
    return not _path_is_url(self.repo_url)

@property
def save_path(self) -> str:
    if self.is_local:
        return self.repo_url   # no allowlist at all
    return os.path.join(self.root_path, self.name)
# api/services/codemap.py
def read_repo_file(repo_url, repo_type, file_path):
    repo_dir = os.path.realpath(Repo(repo_url=repo_url, repo_type=repo_type).save_path)
    target = os.path.realpath(os.path.join(repo_dir, file_path))
    if os.path.commonpath([repo_dir, target]) != repo_dir:
        raise ValueError(...)
    ...

Selecting repo_url=/ makes repo_dir resolve to /, so the containment check against repo_dir is a no-op: every absolute path is "within" /.

POC

(available upon request)

Impact

Any unauthenticated caller who can reach the API can read arbitrary server-readable files via GET /codemap/file?repo_url=/&file_path=<any absolute path minus the leading slash>, or have the RAG indexer embed and persist an entire arbitrary directory tree via /repo/prepare.

Suggested fix: require a local repository path to resolve within an operator-owned allowlisted root before any file/structure/indexing operation uses it. A fix is included in the linked PR.

Fix: #594

Lenguaje dominante
Python
Estrellas
18.1k
Forks
2k
Merge medio
5 min
PR fusionados (30 d)
5

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 AsyncFuncAI/deepwiki-open

Todos los issues de AsyncFuncAI/deepwiki-open

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.