fix(core): prevent SIGHUP kills in PTY environments (WSL2/Kitty/Alacritty) (#27267)

This commit is contained in:
PROTHAM
2026-05-21 02:13:14 +05:30
committed by GitHub
parent d7384c446f
commit f79d5e059c
5 changed files with 145 additions and 11 deletions
@@ -56,7 +56,11 @@ export async function getCommandName(req: SandboxRequest): Promise<string> {
const roots = getCommandRoots(stripped).filter(
(r) => r !== 'shopt' && r !== 'set',
);
if (roots.length > 0) {
// Single-root enforcement: only grant named-command permissions when the
// command is unambiguous. Multi-root chains fall back to basename so that
// a chained command like `git; malicious_cmd` never inherits `git`'s
// sandbox policy for the entire chain.
if (roots.length === 1) {
return roots[0];
}
return path.basename(req.command);