/

CVE-2026-50181

Severity:

HIGH RISK

(7.1)

Path Traversal (CWE-22) in Langroid File Tools

CVE-2026-50181

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22, CWE-23

Impact:

Unauthorized File Read/Write

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Langroid's file tools treat a configured curr_dir as a workspace boundary but fail to enforce that user-supplied file paths stay within that directory.

When exposed to LLM agents or user-controlled tool calls, this can allow reading or writing files outside the intended project directory via path traversal sequences.

Affected context

This vulnerability affects applications built with Langroid that use ReadFileTool and WriteFileTool while assuming curr_dir safely constrains file access.

It becomes relevant when:

  • The tools are exposed to LLM agents, delegated coding/documentation agents, or user-driven tool invocation, and
  • Those agents can influence the file_path parameter, and
  • The host environment contains sensitive files reachable via parent directory traversal.

In such setups, the process working directory is changed to curr_dir, but the actual paths are never normalized or checked against this boundary.

Exploit preconditions

  • Attack surface: File tool interfaces in Langroid-based applications (LLM agent tools, user tool calls, or automation agents).
  • Required access: Ability to supply or influence the file_path argument to ReadFileTool or WriteFileTool.
  • Trigger point: Execution of a file operation where file_path includes traversal like ../ or other constructs that reach outside curr_dir.
  • Why exploitation is possible: The code relies solely on changing the process working directory to curr_dir and does not canonicalize or validate that the resolved file path remains under this directory, enabling path traversal.

Why this happens

The underlying issue is a missing authorization check on filesystem paths, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory and CWE-23: Relative Path Traversal.

Instead of treating curr_dir as a hard boundary and enforcing that resolved paths are descendants of this directory, the tools simply set the process working directory and operate on user-controlled file_path values as-is.

Without canonicalization (e.g., resolving .., symlinks, and absolute paths) and post-checks to confirm the final path remains within curr_dir, an attacker-controlled path can escape the intended workspace and target arbitrary accessible files.

Potential impact

  • Reading sensitive files outside the intended workspace directory, such as configuration files, secrets, or source code.
  • Writing or overwriting files outside the workspace, potentially altering application behavior or corrupting data.
  • Expanding an LLM agent's visibility into the host filesystem beyond what the application designer intended.
  • Facilitating further compromise if the accessible files include credentials, API keys, or other security-sensitive material.

General mitigation guidance

Effective mitigation focuses on enforcing a strict directory boundary and reducing trust in user-controlled paths:

  • Canonicalize and normalize any user-supplied path (resolving .., symbolic links, and relative segments) before use.
  • Enforce that the resolved absolute path is a descendant of the configured curr_dir (e.g., prefix or common-path checks) and reject any that escape this boundary.
  • Avoid relying solely on the process working directory for access control; treat directory constraints as explicit authorization checks.
  • Limit the file operations exposed to LLM agents or external callers to a narrow, well-defined subset of files or directories where possible.
  • Run file-accessing components with least-privilege OS permissions so that even escaped paths cannot reach highly sensitive system locations.

How teams detect issues like this

Organizations can look for this class of issue using:

  • Static analysis: Rules that flag file operations using user-controlled paths without prior normalization and directory-boundary checks.
  • Code review: Indicators include:
  • Direct use of user-provided file_path in open(), read(), or write() calls.
  • Reliance on chdir() or equivalent as the only mechanism for constraining file access.
  • Absence of checks comparing resolved paths against an allowed base directory.
  • Runtime monitoring: Logging and analyzing file access patterns from LLM tools for unexpected directories or repeated ../ usage.
  • Policy enforcement: CI/CD checks enforcing that file tools must validate paths against declared workspace roots, optionally supported by automated security review tools.

Sources

SourceLink
github.comgithub.com/langroid/langroid/commit/56e2756ecab70a70a7e6edbee2f2187b8484683e
github.comgithub.com/langroid/langroid/security/advisories/GHSA-fg23-3346-88f5

Frequently asked

questions

It can be, depending on how the application exposes Langroid tools. If remote users or LLM agents can indirectly influence file_path over a network API, then the path traversal can be triggered remotely.

The attacker must be able to control or significantly influence the file_path input used by ReadFileTool or WriteFileTool. No direct shell or OS-level access is required if a higher-level interface exposes these tools.

The most robust approach is to canonicalize paths and enforce that every resolved path remains within a predefined base directory. Any request that resolves outside this directory should be denied before performing file operations.

Design file-handling features with explicit directory-based authorization checks, avoid trusting relative paths or the process working directory as a security boundary, and include automated checks for path traversal patterns in code review and testing pipelines.

Find out what's already
exploitable in your codebase.