Skip to content
GitHub Security Advisories·Indexed by this site · Originally published· Event →SelectedAttention39

AG2 SandboxShellTool newline injection bypasses allowed whitelist and readonly=True, allowing arbitrary command execution

AG2: Newline injection in SandboxShellTool bypasses allowed=[...] and readonly=True, enabling arbitrary command execution

AI summary

AG2's SandboxShellTool has a newline injection vulnerability (CVE-2026-113663): embedding a newline character in a command string bypasses the allowed command whitelist and the readonly=True read-only restriction, allowing execution of arbitrary shell commands. The cause is that the filter's _SHELL_OPERATORS tuple does not include \n and \r, and when commands are executed via sh -c, the POSIX shell treats newlines as statement separators equivalent to ;. Both restricted modes share the same filter, so one bypass works for both. The advisory authors reproduced it on the main branch (commit a05ff1cb, ag2 1.0.5): conventional concatenation with ;, &&, |, etc. is correctly blocked, while the newline variant passes the filter and is executed by the shell as two statements. Recommended fixes include adding \n and \r to _SHELL_OPERATORS, or executing whitelisted commands without a shell in restricted mode.

Why it was selected

The advisory gives the mechanism and reproduction steps for the newline bypass of the command whitelist; teams using AG2 sandbox restrictions on agent command permissions can check against it and upgrade to 1.1.1.

Read originalgithub.com