fix: harden host exec env validation (#4896) (thanks @HassanFleyah)

This commit is contained in:
Peter Steinberger
2026-02-01 15:35:48 -08:00
parent 0a5821a811
commit a87a07ec8a
4 changed files with 28 additions and 5 deletions

View File

@@ -109,3 +109,17 @@ describe("exec PATH login shell merge", () => {
expect(shellPathMock).not.toHaveBeenCalled();
});
});
describe("exec host env validation", () => {
it("blocks LD_/DYLD_ env vars on host execution", async () => {
const { createExecTool } = await import("./bash-tools.exec.js");
const tool = createExecTool({ host: "gateway", security: "full", ask: "off" });
await expect(
tool.execute("call1", {
command: "echo ok",
env: { LD_DEBUG: "1" },
}),
).rejects.toThrow(/Security Violation: Environment variable 'LD_DEBUG' is forbidden/);
});
});