Skip to content

Commit 6151d1c

Browse files
authored
fix: block bash commands in Prometheus mode to respect permission config (#1449)
Fixes #1428 - Prometheus bash bypass security issue
1 parent 13e1d7c commit 6151d1c

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/hooks/prometheus-md-only/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const ALLOWED_EXTENSIONS = [".md"]
99

1010
export const ALLOWED_PATH_PREFIX = ".sisyphus"
1111

12-
export const BLOCKED_TOOLS = ["Write", "Edit", "write", "edit"]
12+
export const BLOCKED_TOOLS = ["Write", "Edit", "write", "edit", "bash"]
1313

1414
export const PLANNING_CONSULT_WARNING = `
1515

src/hooks/prometheus-md-only/index.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,25 @@ describe("prometheus-md-only", () => {
173173
).rejects.toThrow("can only write/edit .md files")
174174
})
175175

176-
test("should not affect non-Write/Edit tools", async () => {
176+
test("should block bash commands from Prometheus", async () => {
177+
// given
178+
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
179+
const input = {
180+
tool: "bash",
181+
sessionID: TEST_SESSION_ID,
182+
callID: "call-1",
183+
}
184+
const output = {
185+
args: { command: "echo test" },
186+
}
187+
188+
// when / #then
189+
await expect(
190+
hook["tool.execute.before"](input, output)
191+
).rejects.toThrow("cannot execute bash commands")
192+
})
193+
194+
test("should not affect non-blocked tools", async () => {
177195
// given
178196
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
179197
const input = {

src/hooks/prometheus-md-only/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ export function createPrometheusMdOnlyHook(ctx: PluginInput) {
106106
return
107107
}
108108

109+
// Block bash commands completely - Prometheus is read-only
110+
if (toolName === "bash") {
111+
log(`[${HOOK_NAME}] Blocked: Prometheus cannot execute bash commands`, {
112+
sessionID: input.sessionID,
113+
tool: toolName,
114+
agent: agentName,
115+
})
116+
throw new Error(
117+
`[${HOOK_NAME}] ${getAgentDisplayName("prometheus")} cannot execute bash commands. ` +
118+
`${getAgentDisplayName("prometheus")} is a READ-ONLY planner. Use /start-work to execute the plan. ` +
119+
`APOLOGIZE TO THE USER, REMIND OF YOUR PLAN WRITING PROCESSES, TELL USER WHAT YOU WILL GOING TO DO AS THE PROCESS, WRITE THE PLAN`
120+
)
121+
}
122+
109123
const filePath = (output.args.filePath ?? output.args.path ?? output.args.file) as string | undefined
110124
if (!filePath) {
111125
return

0 commit comments

Comments
 (0)