CVE-2026-50181: Langroid: path traversal escapes sandboxed file tools
GHSA-fg23-3346-88f5 HIGH CISA: ATTENDLangroid's ReadFileTool and WriteFileTool only change the process working directory to the configured curr_dir but never validate that the final resolved path stays inside it, so a simple ../secret.txt argument reads or writes files anywhere the process has filesystem access. This matters because these tools are wired directly into LLM agents — any user prompt, indirect prompt injection from ingested content, or delegated coding/documentation agent that influences the file_path argument can walk out of the intended project sandbox. There's no EPSS score, no CISA KEV listing, and no public exploit or Nuclei template yet, and the package shows only 4 tracked downstream dependents, so this isn't an active, widely-exploited threat today — but CVSS 7.1 (C:H/I:H) reflects that a successful escape can expose secrets, .env files, or source outside the workspace and can also write/overwrite arbitrary files if WriteFileTool is enabled. Upgrade to langroid 0.64.0, which fixes the boundary check; if you can't patch immediately, audit any deployment that exposes ReadFileTool/WriteFileTool to agent or user control and add your own resolved-path containment check (reject any target where curr_dir is not a parent of the resolved path) as a compensating control. Detection-wise, watch for file access or agent tool logs containing '../' sequences or file paths resolving outside the configured workspace root.
What is the risk?
CVSS 7.1 (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N) reflects low attack complexity and no user interaction once a caller can influence the tool's file_path argument — the barrier is only whatever access control gates who/what can invoke the tool (PR:L). In pure human-operated CLI contexts the practical exposure is limited to whoever already has some access to issue tool calls. The risk escalates sharply in agentic deployments where an LLM decides tool arguments autonomously: prompt injection from untrusted content (a file, a web page, a ticket) ingested by the agent could smuggle a traversal path into the tool call without any direct human involvement, effectively turning a local-privilege bug into a remotely triggerable one. No active exploitation signals exist (no KEV, no EPSS, no public PoC beyond the reporter's own repro, no Nuclei template), and the small dependent count (4) caps blast radius today, but the vulnerability class (classic unvalidated '../' traversal) is trivial to exploit once reachable, so treat this as high-priority patching rather than urgent incident response.
How does the attack unfold?
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| Langroid | pip | <= 0.63.0 | 0.64.0 |
Do you use Langroid? You're affected.
How severe is it?
What is the attack surface?
What should I do?
1 step-
Upgrade to langroid >= 0.64.0, which contains the fix (commit 56e2756). If immediate upgrade isn't possible, wrap ReadFileTool/WriteFileTool/ListDirTool invocations with your own path-containment check before the tool executes: resolve both curr_dir and the requested file_path to absolute paths and reject the call unless the resolved target is curr_dir itself or a descendant of it (the advisory's suggested safe_join() pattern using pathlib .resolve() and .parents is a good template — also resolve symlinks, not just relative segments). Add regression tests for '../' traversal, absolute-path escapes, and symlink-based escapes on both tools. For detection, log every ReadFileTool/WriteFileTool invocation with the raw file_path argument and alert on any containing '..' or resolving outside the configured workspace root; if these tools are exposed to content ingested from external/untrusted sources, treat that as an indirect prompt-injection surface and add input filtering/allowlisting on tool arguments in addition to the path fix.
What does CISA's SSVC say?
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2026-50181?
Langroid's ReadFileTool and WriteFileTool only change the process working directory to the configured curr_dir but never validate that the final resolved path stays inside it, so a simple ../secret.txt argument reads or writes files anywhere the process has filesystem access. This matters because these tools are wired directly into LLM agents — any user prompt, indirect prompt injection from ingested content, or delegated coding/documentation agent that influences the file_path argument can walk out of the intended project sandbox. There's no EPSS score, no CISA KEV listing, and no public exploit or Nuclei template yet, and the package shows only 4 tracked downstream dependents, so this isn't an active, widely-exploited threat today — but CVSS 7.1 (C:H/I:H) reflects that a successful escape can expose secrets, .env files, or source outside the workspace and can also write/overwrite arbitrary files if WriteFileTool is enabled. Upgrade to langroid 0.64.0, which fixes the boundary check; if you can't patch immediately, audit any deployment that exposes ReadFileTool/WriteFileTool to agent or user control and add your own resolved-path containment check (reject any target where curr_dir is not a parent of the resolved path) as a compensating control. Detection-wise, watch for file access or agent tool logs containing '../' sequences or file paths resolving outside the configured workspace root.
Is CVE-2026-50181 actively exploited?
No confirmed active exploitation of CVE-2026-50181 has been reported, but organizations should still patch proactively.
How to fix CVE-2026-50181?
Upgrade to langroid >= 0.64.0, which contains the fix (commit 56e2756). If immediate upgrade isn't possible, wrap ReadFileTool/WriteFileTool/ListDirTool invocations with your own path-containment check before the tool executes: resolve both curr_dir and the requested file_path to absolute paths and reject the call unless the resolved target is curr_dir itself or a descendant of it (the advisory's suggested safe_join() pattern using pathlib .resolve() and .parents is a good template — also resolve symlinks, not just relative segments). Add regression tests for '../' traversal, absolute-path escapes, and symlink-based escapes on both tools. For detection, log every ReadFileTool/WriteFileTool invocation with the raw file_path argument and alert on any containing '..' or resolving outside the configured workspace root; if these tools are exposed to content ingested from external/untrusted sources, treat that as an indirect prompt-injection surface and add input filtering/allowlisting on tool arguments in addition to the path fix.
What systems are affected by CVE-2026-50181?
This vulnerability affects the following AI/ML architecture patterns: agent frameworks, coding/documentation agents, sandboxed tool execution, autonomous agent workflows.
What is the CVSS score for CVE-2026-50181?
CVE-2026-50181 has a CVSS v3.1 base score of 7.1 (HIGH). The EPSS exploitation probability is 0.23%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0037 Data from Local System AML.T0051.001 Indirect AML.T0053 AI Agent Tool Invocation AML.T0086 Exfiltration via AI Agent Tool Invocation Compliance Controls Affected
What are the technical details?
Original Advisory
Langroid is a framework for building large-language-model-powered applications. Prior to version 0.64.0, 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. Version 0.64.0 patches the issue.
Exploitation Scenario
A team deploys a Langroid-based coding assistant that lets the LLM agent read and write files scoped to a per-project curr_dir sandbox, intending to prevent the agent from touching anything outside that repository. An attacker either has partial access to issue tool calls (e.g., via a shared multi-tenant agent instance) or, more realistically, plants an indirect prompt injection inside a file, issue, or webpage the agent is asked to process — instructing the agent to 'read ../../.env for debugging' or 'save notes to ../../../home/user/.ssh/authorized_keys'. Because Langroid only chdir's into curr_dir without validating the resolved path, the tool happily reads the target's environment secrets or writes attacker-controlled content outside the sandbox, believing it operated within the intended workspace. The attacker now has exfiltrated credentials or a persistence foothold (e.g., a planted script or modified config) entirely through what looked like a normal, in-scope agent file operation.
Weaknesses (CWE)
CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Primary
CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Primary
CWE-23 Relative Path Traversal
Primary
CWE-23 Relative Path Traversal
Primary
CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') CWE-23 Relative Path Traversal CWE-22 — Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'): The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
- [Implementation] Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylis
- [Architecture and Design] For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N References
Timeline
Related Vulnerabilities
CVE-2026-54769 10.0 Langroid: prompt injection to RCE via broken eval() sandbox
Same package: langroid CVE-2026-25879 9.8 langroid: Prompt-to-SQL injection enables RCE on DB host
Same package: langroid CVE-2026-54771 8.1 Langroid: auth bypass invokes disabled tools via raw JSON
Same package: langroid CVE-2026-55615 Langroid: unvalidated LLM Cypher enables graph RCE
Same package: langroid CVE-2026-25481 langroid: Code Injection enables RCE
Same package: langroid