fix(redis): block FLUSHDB in MCP instead of running it unconfirmed

This commit is contained in:
BASIL K AJI authored and GitHub committed 2026-10-04 03:43:49 +08:00
1 parent a9990d5fdb
commit 92a29cb715
7 files changed
+11 -12

No files matched your search

@@ -25,7 +25,7 @@ describe("AI Redis console routing", () => {
it("uses the console safety path and rejects unavailable command input", () => {
expect(classifyRedisCommandSafety("CONFIG SET requirepass secret")).toBe("blocked");
expect(classifyRedisCommandSafety("FLUSHDB")).toBe("confirm");
expect(classifyRedisCommandSafety("FLUSHDB")).toBe("blocked");
expect(classifyRedisCommandSafety("SET issue:846 fixed")).toBe("write");
expect(classifyRedisCommandSafety("INFO server")).toBe("allowed");
@@ -2,7 +2,7 @@ import { isRedisMonitorCommand } from "./redisMonitor";
export type RedisCommandSafety = "allowed" | "write" | "confirm" | "blocked";
const BLOCKED_COMMANDS = new Set(["KEYS", "FLUSHALL", "SHUTDOWN", "CONFIG", "SAVE", "BGSAVE", "SLAVEOF", "REPLICAOF", "MIGRATE", "MODULE", "SCRIPT", "EVAL", "EVALSHA"]);
const BLOCKED_COMMANDS = new Set(["KEYS", "FLUSHALL", "FLUSHDB", "SHUTDOWN", "CONFIG", "SAVE", "BGSAVE", "SLAVEOF", "REPLICAOF", "MIGRATE", "MODULE", "SCRIPT", "EVAL", "EVALSHA"]);
// Explicit allowlist matching the backend's read-command classification.
// Unknown commands fall through to "blocked" (fail-closed).
@@ -199,7 +199,6 @@ const CONFIRM_COMMANDS = new Set([
"ZUNIONSTORE",
"PFMERGE",
"GEOSEARCHSTORE",
"FLUSHDB",
]);
const WRITE_COMMANDS = new Set([
@@ -377,7 +377,7 @@ const RAW_COMMANDS: Record<string, Spec> = {
DBSIZE: [1, "server"],
FAILOVER: [-1, "server", "confirm"],
FLUSHALL: [-1, "server", "blocked"],
FLUSHDB: [-1, "server", "confirm"],
FLUSHDB: [-1, "server", "blocked"],
INFO: [-1, "server"],
LASTSAVE: [1, "server"],
"MEMORY USAGE": [-3, "server"],