Dec 3, 2026·13 min read·7 visits
AG2's SandboxShellTool command filter (check_ignore) only validates explicit file paths written in the command string against configured ignore patterns. Whitelisted read-only utilities capable of autonomous directory traversal—specifically grep, egrep, fgrep, and diff—can bypass these restrictions when invoked recursively on a parent directory or the implicit current working directory, exposing sensitive files in tool execution outputs. Upgrading to AG2 v1.3.4 resolves this issue.
CVE-2026-141554 (GHSA-xhqj-2fcc-8vf7) is an incorrect authorization vulnerability (CWE-863) in AG2 (formerly AutoGen), an open-source AgentOS framework for multi-agent AI systems. In versions from 0.13.3 prior to 1.3.4, the SandboxShellTool component configured with readonly=True and an ignore pattern list fails to prevent recursive search and comparison utilities (grep, egrep, fgrep, and diff) from accessing and disclosing restricted files. Because the command-line security filter only inspects explicit path tokens passed as arguments rather than files discovered autonomously during directory traversal, an AI agent processing untrusted input or prompt injections can be induced to read and expose protected files such as .env configurations, cryptographic keys, and credentials.
AG2 (formerly AutoGen, published under the ag2 and autogen packages on PyPI) is an open-source framework designed for orchestrating multi-agent AI workflows. To allow Large Language Model (LLM) agents to interact with their environment safely, AG2 provides SandboxShellTool, a tool wrapper that executes shell commands within a designated workspace. Developers configure SandboxShellTool with security parameters including readonly=True (which restricts command execution to a whitelist of non-destructive utilities) and ignore (a list of glob patterns specifying sensitive files that the agent is prohibited from accessing).
In AG2 versions 0.13.3 through 1.3.3, a flaw exists in how SandboxShellTool enforces the ignore policy. The pre-execution filter function ShellAdapter._filter() in ag2/tools/sandbox/adapter/shell.py delegates path validation to check_ignore() in ag2/tools/sandbox/filter.py. This function parses the command string and compares explicit command-line tokens against the configured ignore glob patterns.
While this approach blocks direct file access commands such as cat .env or grep SECRET secrets/db.txt, it fails to account for utilities that traverse directories autonomously. When readonly=True is active, utilities including grep, egrep, fgrep, and diff remain permitted. When an agent executes these commands with recursive flags (such as grep -r) targeting a parent directory (e.g., .) or with no file operand at all, the command string contains no token matching the restricted file patterns.
Classified under CWE-863 (Incorrect Authorization), this discrepancy between argument-level validation and actual runtime file access allows the spawned utility to traverse the directory tree, read ignored files, and return their contents to the agent execution context. If the agent processes attacker-controlled inputs (via indirect prompt injection or untrusted user messages) and its output or observation history is visible to an external actor, sensitive project secrets are disclosed.
The root cause of CVE-2026-141554 lies in the lexical, token-based design of check_ignore() within ag2/tools/sandbox/filter.py. When an agent submits a shell command for execution via ShellAdapter.run(), the adapter invokes ShellAdapter._filter() to verify that the command complies with the sandbox's read-only and path-filtering constraints before passing the command string to the underlying execution environment.
Prior to version 1.3.4, check_ignore() split the incoming command string into discrete tokens using shlex.split(). It then iterated over these tokens, treating them as candidate relative paths or shell globs within the sandbox workdir. Each candidate token was resolved relative to workdir and tested against the configured ignore patterns using standard filename matching logic. If none of the tokens in the command string matched an ignored pattern, check_ignore() returned None, signaling that the command was safe to execute.
This architecture makes an invalid assumption: that every file read by a command must appear explicitly as an argument or shell-expanded wildcard on the command line. For standard file viewers like cat, head, or tail, this assumption holds because they require explicit file operands. However, two families of whitelisted read-only utilities violate this assumption:
grep family (grep, egrep, fgrep): When invoked with recursive flags (-r, -R, --recursive, -d recurse, or --directories=recurse), grep accepts a directory path as an operand and uses OS directory-listing system calls (opendir/readdir) to inspect every file inside that subtree. Furthermore, in GNU and BSD implementations of grep, if a recursive flag is specified without any path operand (e.g., grep -r SECRET), grep defaults to searching the current working directory (.) implicitly.diff utility: When invoked across two directories (e.g., diff -r src . or diff -N . src), diff walks the directory trees to compare files. Using flags such as -N (--new-file), diff outputs the complete contents of files present in one directory but absent in the other, effectively dumping the contents of ignored files located inside the target directory.Additionally, if an allowed directory contains a symbolic link pointing to an ignored file or a file outside the workspace, recursive traversal commands that follow symlinks (such as grep -R) will follow the link and expose the target file's contents without the target path ever appearing in the command string.
In the vulnerable versions of AG2 (< 1.3.4), ag2/tools/sandbox/filter.py evaluated command tokens without inspecting the contents of directory operands or accounting for implicit working directory searches. The pre-patch verification flow conceptually performed direct token resolution:
# Vulnerable logic representation (pre-v1.3.4 in ag2/tools/sandbox/filter.py)
def check_ignore(command: str, workdir: Path | PurePath, patterns: list[str]) -> str | None:
tokens = shlex.split(command)
for token in tokens:
# Only checks the literal token (e.g., '.') against patterns (e.g., '**/.env')
resolved = (workdir / token).resolve()
if _matches_any(resolved, workdir, patterns):
return f"Access denied: {token}"
return NoneTo remediate this flaw across commits 92e842709be3010853e9964905cd23487385e570 through b14405f5cd770197dabe36b327a7ade0a013d707, the AG2 maintainers re-engineered ag2/tools/sandbox/filter.py to perform pre-execution directory tree inspection whenever a directory-reading program (grep, egrep, fgrep, diff) is invoked.
# Patched implementation in ag2/tools/sandbox/filter.py (v1.3.4)
_DIRECTORY_READERS = frozenset({"grep", "egrep", "fgrep", "diff"})
_GREP_FAMILY = frozenset({"grep", "egrep", "fgrep"})
_GREP_SHORT_WITH_VALUE = "efmABCdD"
_GREP_LONG_WITH_VALUE = (
"regexp", "file", "max-count", "after-context", "before-context",
"context", "directories", "devices", "label", "include", "exclude",
"exclude-from", "exclude-dir", "binary-files", "group-separator",
)
def check_ignore(
command: str,
workdir: "Path | PurePath",
patterns: list[str],
*,
max_entries: int = 20_000,
) -> str | None:
# ... [token parsing and basic validation] ...
# 1. Fail-closed on remote backends where host Path traversal is impossible
if not isinstance(workdir, Path):
if tokens and PurePosixPath(tokens[0]).name in _DIRECTORY_READERS:
return (
f"Access denied: {tokens[0]} can read files inside a directory, "
f"which cannot be checked on this backend"
)
return None
# 2. Local backend: enforce traversal budget and inspect host paths
try:
return _check_host_paths(tokens, expanded_tokens, workdir, patterns, _Budget(max_entries))
except _UncheckableError as exc:
return f"Access denied: {exc}"When a command invokes one of the _DIRECTORY_READERS, the patched filter identifies all directory operands—including the implicit working directory when grep is called without file operands—and recursively scans them using os.scandir() prior to allowing the command:
def _check_directory_operands(
tokens: list[str],
words: list[tuple[str, list[PurePath]]],
workdir: Path,
resolved_workdir: Path,
patterns: list[str],
budget: _Budget,
) -> str | None:
starts: list[tuple[PurePath, Path]] = [
(PurePath(os.path.normpath(resolved_workdir / path)), _resolve(workdir / path))
for _, paths in words
for path in paths
if _is_dir(workdir / path)
]
# Detect implicit '.' search when grep is called with no file operands
if PurePosixPath(tokens[0]).name in _GREP_FAMILY and not any(
_exists(workdir / operand) for operand in _grep_file_operands(tokens[1:])
):
starts.append((resolved_workdir, resolved_workdir))
return _ignored_inside(starts, resolved_workdir, patterns, budget)
def _ignored_inside(
starts: list[tuple[PurePath, Path]],
resolved_workdir: Path,
patterns: list[str],
budget: _Budget,
) -> str | None:
pending = [(lexical, real, frozenset({real})) for lexical, real in starts]
while pending:
lexical, real, ancestors = pending.pop()
try:
with os.scandir(real) as entries:
for entry in entries:
budget.spend() # Enforces max_entries=20,000 limit to prevent DoS
child = lexical / entry.name
target = _resolve(real / entry.name)
# Check both the lexical path (symlink name) and resolved target path
for candidate in (child, target):
denied = _denied(candidate, resolved_workdir, patterns)
if denied is not None:
return denied
# Recurse into subdirectories while preventing symlink loops via ancestors set
if entry.is_dir() and target not in ancestors:
pending.append((child, target, ancestors | {target}))
except OSError as exc:
raise _UncheckableError(f"cannot list {lexical}") from exc
return NoneThe patch in v1.3.4 is thorough regarding the whitelisted read-only command set. It addresses several edge cases and potential bypass variants:
_grep_file_operands() accurately strips short options taking values (-e, -f, -m, -A, -B, -C, -d, -D) and long options so that option arguments are not mistaken for file operands._ignored_inside() checks both the lexical path (child) and the canonical resolved path (target). If a symlink inside an allowed directory points to an ignored file or outside resolved_workdir, _denied() blocks the command. Tracking ancestors prevents infinite recursion on circular directory symlinks._Budget(max_entries=20_000) prevents denial-of-service from deep filesystem trees. If the budget is exhausted, if os.scandir() encounters a permission error (OSError), if an unbounded recursive glob (**) is passed in the command string, or if the sandbox uses a virtual/remote PurePath backend where host inspection is impossible, the filter fails closed and returns Access denied.Exploiting CVE-2026-141554 requires an AG2 deployment that exposes SandboxShellTool (or ShellAdapter) to an agent with readonly=True and an ignore list intended to hide confidential files on the filesystem. Because readonly=True is specifically designed to make shell execution safe for untrusted or semi-trusted agent workflows, this configuration is used when agents inspect codebases, analyze logs, or answer user queries about a repository.
An attacker interacts with the agent either directly (via a chat interface or API) or indirectly (by embedding prompt injection payloads inside documents, issues, pull requests, or web pages ingested by the agent). The attacker's objective is to induce the LLM to execute a recursive search or directory comparison command that traverses the workspace and outputs the contents of ignored files.
Any of the following command constructs bypass the pre-1.3.4 check_ignore() filter when ignore=["**/.env", "*.key", "secrets/**"] is configured:
Implicit Current Directory Traversal:
grep -r ""
grep -rn API_KEY
egrep -R "KEY|SECRET|PASSWORD"Because no file or directory token is present in the command, check_ignore() only evaluates the command name, flags, and search pattern. None match the file globs, and grep automatically searches . recursively.
Explicit Directory Operand Traversal:
grep -r SECRET .
grep --recursive PASSWORD .
grep -d recurse KEY .Here, the only path token is ., which resolves to the workspace root and does not match file-level or subdirectory patterns like **/.env or secrets/**.
Directory Comparison via diff:
diff -rN src .
diff -N empty_dir .By comparing a directory lacking secrets against . with the -N (--new-file) flag, diff treats every file present only in . (including .env) as a newly added file and prints its entire contents in the diff output.
The following standalone Python test demonstrates how ShellAdapter leaks ignored secrets in affected versions (>= 0.13.3, < 1.3.4) and verifies the block behavior introduced in 1.3.4:
import asyncio
from pathlib import Path
import tempfile
from ag2.tools.sandbox.adapter import ShellAdapter
from ag2.tools.sandbox.local import LocalSandbox
SECRETS_IGNORE = ["**/.env", "*.key", "secrets/**"]
async def reproduce():
with tempfile.TemporaryDirectory() as tmpdir:
project = Path(tmpdir)
(project / ".env").write_text("OPENAI_API_KEY=sk-live-secret-value\n")
(project / "deploy.key").write_text("PRIVATE-DEPLOY-KEY-DATA\n")
(project / "secrets").mkdir()
(project / "secrets" / "db.txt").write_text("DB_PASSWORD=supersecretdb\n")
(project / "src").mkdir()
(project / "src" / "app.py").write_text("print('hello world')\n")
adapter = ShellAdapter(
LocalSandbox(project),
readonly=True,
ignore=SECRETS_IGNORE
)
# Direct access is properly blocked in both vulnerable and patched versions:
direct_res = await adapter.run("cat .env")
print(f"Direct cat .env: {direct_res}")
# Bypass 1: Explicit '.' recursive grep
# Vulnerable (< 1.3.4): Outputs OPENAI_API_KEY, PRIVATE-DEPLOY-KEY-DATA, DB_PASSWORD
# Patched (>= 1.3.4): Returns 'Access denied: ...'
grep_dot_res = await adapter.run("grep -r '' .")
print(f"Recursive grep on '.': {grep_dot_res}")
# Bypass 2: Implicit working directory recursive grep
grep_implicit_res = await adapter.run("grep -r KEY")
print(f"Implicit recursive grep: {grep_implicit_res}")
if __name__ == "__main__":
asyncio.run(reproduce())The primary impact of CVE-2026-141554 is the unauthorized disclosure of confidential files located within or reachable from the agent's workspace directory. Developers using SandboxShellTool with ignore rules rely on this control to prevent LLM agents from reading environment files (.env), private SSH or TLS keys (*.pem, *.key), cloud provider credential files, and proprietary configuration data stored alongside application code.
When this control is bypassed, the contents of those files are returned as standard tool output (stdout) into the agent's conversation history. This leads to two distinct exposure paths:
The vulnerability carries a CVSS v3.1 Base Score of 3.1 (Low) with vector CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N:
AV:N): The vulnerable agent workflow can be triggered remotely over network interfaces processing user messages or external data.AC:H): Exploitation requires a specific deployment configuration (SandboxShellTool initialized with both readonly=True and ignore patterns) as well as an accessible output channel for the attacker to retrieve the leaked tool output.PR:N): No host or application authentication is required by default to supply untrusted context to the agent.UI:R): Typically requires an agent run to be initiated or a user/system to trigger ingestion of attacker-supplied content.S:U) and Confidentiality: Low (C:L): The disclosure is constrained to readable files within the sandbox workspace, with Integrity (I:N) and Availability (A:N) unaffected due to readonly=True enforcement.> [!NOTE]
> While the baseline CVSS score is rated Low due to the architectural preconditions (AC:H, UI:R), the practical impact in an exposed multi-agent deployment can be significant if the disclosed .env file or secret key grants lateral access to production databases, cloud infrastructure, or LLM API accounts.
Users of AG2 (ag2 or autogen on PyPI) should upgrade to version 1.3.4 or later immediately. Version 1.3.4 updates ag2/tools/sandbox/filter.py and ag2/tools/sandbox/adapter/shell.py to recursively pre-scan directory operands (including implicit working directory targets) before executing grep, egrep, fgrep, or diff, and rejects directory-reading commands outright on non-local backends where host-side directory inspection cannot be performed.
# Upgrade using pip
pip install --upgrade "ag2>=1.3.4"
# Upgrade using uv
uv add "ag2>=1.3.4"If an immediate upgrade to v1.3.4 is not possible, or when hardening agent execution environments against broader file disclosure risks, engineering teams should implement the following controls:
.env, private keys, credential JSONs) inside the directory tree mounted or assigned as the workdir for SandboxShellTool. Inject required configuration into the host application via runtime environment variables rather than filesystem dot-files inside the agent workspace.LocalSandbox directly against a host repository folder containing secrets, use a containerized sandbox environment (such as DockerEnvironment) and bind-mount only the specific source subdirectories required by the agent, omitting secret directories at the OS mount layer.SandboxShellTool's ignore parameter is a command-line filter, not an OS-level Mandatory Access Control (MAC) mechanism. If non-readonly mode is used or if general interpreters (python, bash, sh, node, perl) are manually added to the allowed command whitelist, an agent can read ignored files via inline code execution (e.g., python -c "print(open('.env').read())") without referencing the filename as a separate CLI token. Never combine general scripting interpreters in allowed with reliance on ignore patterns for secret protection.CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
ag2 ag2ai | >= 0.13.3, < 1.3.4 | 1.3.4 |
autogen ag2ai | >= 0.13.3, <= 0.14.1 | 1.3.4 (via ag2 package) |
| Attribute | Detail |
|---|---|
| CVE ID | CVE-2026-141554 (GHSA-xhqj-2fcc-8vf7) |
| Weakness Class | CWE-863: Incorrect Authorization |
| Affected Component | SandboxShellTool / ShellAdapter (ag2/tools/sandbox/filter.py) |
| CVSS v3.1 Score | 3.1 Low (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N) |
| Attack Vector | Network (Prompt Injection / Untrusted Agent Context) |
| Impact | Unauthorized disclosure of ignored files (.env, keys, secrets) |
| Exploit Status | Functional PoC available via regression unit tests |
| Fixed Version | AG2 v1.3.4 |
The software performs an authorization check when an actor attempts to access a resource, but it does not correctly perform the check. In this vulnerability, the command filter evaluates only explicit CLI arguments rather than the actual underlying filesystem resources opened during recursive binary execution.
CVE-2026-135390 is an authentication bypass vulnerability in the Pion DTLS Go library caused by improper validation of cached DTLS 1.2 sessions. When an application shares a single SessionStore across both outbound client connections and inbound server listeners, a remote server previously contacted by the application's client can reuse the negotiated session identifier and master secret to authenticate against the application's server listener via abbreviated session resumption, bypassing mutual TLS and Pre-Shared Key checks.
CVE-2026-77132 is an authorization bypass and information disclosure vulnerability in the TYPO3 CMS backend localization wizard (ext:backend). Multiple backend AJAX endpoints failed to validate page-level and record-level access permissions before processing requests. As a result, authenticated backend users with restricted privileges can query these routes directly to enumerate sensitive metadata, record titles, unique identifiers, and layout structures across unauthorized sections of the page tree.
Pion DTLS versions from 2.0.0 prior to 3.1.13 and 4.0.0-rc.6 fail to enforce an upper bound on the modulus bit length of peer RSA public keys during handshake signature and certificate chain verification. Because RSA verification performs modular exponentiation whose computational complexity grows superlinearly with modulus size, a remote unauthenticated peer can transmit a synthetic certificate containing an arbitrary multi-thousand-bit RSA modulus and an invalid signature to trigger CPU exhaustion.
Vapor JWTKit versions 4.0.0 prior to 5.8.0 fail to validate the audience (aud) claim in built-in vendor identity token payload types for Apple, Google, and Microsoft. This improper authentication flaw allows an attacker to obtain a legitimately signed ID token for a third-party client application and replay it against a relying party application using JWTKit, resulting in cross-client authentication bypass and account takeover.
GHSA-QMJC-65WP-7V34 documents a software supply-chain compromise targeting the Python Package Index (PyPI) package magique. Threat actors utilized stolen maintainer credentials to publish unauthorized phantom releases (versions 0.6.8 and 0.6.9) directly to PyPI on June 8, 2026. These distributions contain a malicious .pth path configuration file that automatically triggers an embedded JavaScript payload via the Bun runtime upon Python interpreter startup, resulting in credential theft, process memory scraping, and worm-like self-propagation.
CVE-2026-140231 is a memory exhaustion vulnerability in the node-tar package for Node.js prior to version 8.0.0. Because archive decompression lacks backpressure enforcement and zero-size archive entries queue in memory without upper bounds, an attacker who supplies a crafted compressed archive can force the host application to exhaust available resident memory and terminate via an Out-of-Memory (OOM) condition, bypassing existing decompression ratio checks.