mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 14:51:24 +00:00
fix(security): clarify denyCommands exact-match guidance
This commit is contained in:
@@ -330,7 +330,7 @@ export const FIELD_HELP: Record<string, string> = {
|
||||
"gateway.nodes.allowCommands":
|
||||
"Extra node.invoke commands to allow beyond the gateway defaults (array of command strings). Enabling dangerous commands here is a security-sensitive override and is flagged by `openclaw security audit`.",
|
||||
"gateway.nodes.denyCommands":
|
||||
"Commands to block even if present in node claims or default allowlist.",
|
||||
"Node command names to block even if present in node claims or default allowlist (exact command-name matching only, e.g. `system.run`; does not inspect shell text inside that command).",
|
||||
nodeHost:
|
||||
"Node host controls for features exposed from this gateway node to other nodes or clients. Keep defaults unless you intentionally proxy local capabilities across your node network.",
|
||||
"nodeHost.browserProxy":
|
||||
|
||||
@@ -365,6 +365,31 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("denies semicolon-chained shell payloads in allowlist mode without explicit approval", async () => {
|
||||
const payloads = ["openclaw status; id", "openclaw status; cat /etc/passwd"];
|
||||
for (const payload of payloads) {
|
||||
const command =
|
||||
process.platform === "win32"
|
||||
? ["cmd.exe", "/d", "/s", "/c", payload]
|
||||
: ["/bin/sh", "-lc", payload];
|
||||
const { runCommand, sendInvokeResult } = await runSystemInvoke({
|
||||
preferMacAppExecHost: false,
|
||||
security: "allowlist",
|
||||
ask: "on-miss",
|
||||
command,
|
||||
});
|
||||
expect(runCommand, payload).not.toHaveBeenCalled();
|
||||
expect(sendInvokeResult, payload).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
ok: false,
|
||||
error: expect.objectContaining({
|
||||
message: "SYSTEM_RUN_DENIED: approval required",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("denies nested env shell payloads when wrapper depth is exceeded", async () => {
|
||||
if (process.platform === "win32") {
|
||||
return;
|
||||
|
||||
@@ -955,11 +955,11 @@ export function collectNodeDenyCommandPatternFindings(cfg: OpenClawConfig): Secu
|
||||
severity: "warn",
|
||||
title: "Some gateway.nodes.denyCommands entries are ineffective",
|
||||
detail:
|
||||
"gateway.nodes.denyCommands uses exact command-name matching only.\n" +
|
||||
"gateway.nodes.denyCommands uses exact node command-name matching only (for example `system.run`), not shell-text filtering inside a command payload.\n" +
|
||||
detailParts.map((entry) => `- ${entry}`).join("\n"),
|
||||
remediation:
|
||||
`Use exact command names (for example: ${examples.join(", ")}). ` +
|
||||
"If you need broader restrictions, remove risky commands from allowCommands/default workflows.",
|
||||
"If you need broader restrictions, remove risky command IDs from allowCommands/default workflows and tighten tools.exec policy.",
|
||||
});
|
||||
|
||||
return findings;
|
||||
|
||||
Reference in New Issue
Block a user