mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 12:20:26 +00:00
fix(security): block HOME and ZDOTDIR env override injection
This commit is contained in:
@@ -26,6 +26,17 @@ describe("node-host sanitizeEnv", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("blocks dangerous override-only env keys", () => {
|
||||
withEnv({ HOME: "/Users/trusted", ZDOTDIR: "/Users/trusted/.zdot" }, () => {
|
||||
const env = sanitizeEnv({
|
||||
HOME: "/tmp/evil-home",
|
||||
ZDOTDIR: "/tmp/evil-zdotdir",
|
||||
});
|
||||
expect(env.HOME).toBe("/Users/trusted");
|
||||
expect(env.ZDOTDIR).toBe("/Users/trusted/.zdot");
|
||||
});
|
||||
});
|
||||
|
||||
it("drops dangerous inherited env keys even without overrides", () => {
|
||||
withEnv({ PATH: "/usr/bin:/bin", BASH_ENV: "/tmp/pwn.sh" }, () => {
|
||||
const env = sanitizeEnv(undefined);
|
||||
|
||||
Reference in New Issue
Block a user