-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: block bash commands in Prometheus mode to respect permission config #1449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: block bash commands in Prometheus mode to respect permission config #1449
Conversation
Prometheus mode was bypassing the bash permission setting in opencode.jsonc. When users configured bash: "ask", Prometheus could still execute bash commands without confirmation, posing a security risk since Prometheus is designed as a read-only planner. Changes: - Add 'bash' to BLOCKED_TOOLS in prometheus-md-only hook - Block bash commands with a clear error message explaining Prometheus is read-only - Add test case to verify bash blocking behavior Fixes code-yeongyu#1428
|
All contributors have signed the CLA. Thank you! ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
|
@code-yeongyu This is a security fix for issue #1428. Could you please review when you have a moment? |
|
@sisyphus-dev-ai review |
Code Review SummaryReviewer: @sisyphus-dev-ai OverviewThis PR addresses a security vulnerability reported in #1428 where Prometheus mode could execute bash commands despite having Changes Reviewed
Implementation Quality1. constants.ts export const BLOCKED_TOOLS = ["Write", "Edit", "write", "edit", "bash"]
2. index.ts - Bash Blocking Logic (lines 109-121) if (toolName === "bash") {
log(`[${HOOK_NAME}] Blocked: Prometheus cannot execute bash commands`, {
sessionID: input.sessionID,
tool: toolName,
agent: agentName,
})
throw new Error(
`[${HOOK_NAME}] ${getAgentDisplayName("prometheus")} cannot execute bash commands. ` +
`${getAgentDisplayName("prometheus")} is a READ-ONLY planner. Use /start-work to execute the plan. ` +
`APOLOGIZE TO THE USER, REMIND OF YOUR PLAN WRITING PROCESSES, TELL USER WHAT YOU WILL GOING TO DO AS THE PROCESS, WRITE THE PLAN`
)
}
3. Test Coverage test("should block bash commands from Prometheus", async () => {
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
const input = { tool: "bash", sessionID: TEST_SESSION_ID, callID: "call-1" }
const output = { args: { command: "echo test" } }
await expect(hook["tool.execute.before"](input, output)).rejects.toThrow("cannot execute bash commands")
})
Verification
Security ImpactThis fix ensures Prometheus mode is truly read-only by:
RecommendationLGTM - Ready to merge. Clean implementation, good test coverage, addresses the security concern appropriately. |
Summary
Fixes #1428 - Prometheus mode was bypassing the bash permission setting in
opencode.jsonc.Problem
When users configured
"bash": "ask"in theiropencode.jsoncpermission config, Prometheus (Plan Builder) mode could still execute bash commands without user confirmation. This posed a security risk since Prometheus is designed as a read-only planner that should only analyze and create plans, not execute commands.Root Cause
The
prometheus-md-onlyhook only blockedwriteandedittools but did NOT includebashin theBLOCKED_TOOLSlist. Since Prometheus hasbash: "allow"in its default permission configuration, bash commands executed directly without respecting the user's global permission settings.Solution
Added
bashto theBLOCKED_TOOLSarray in the prometheus-md-only hook, making Prometheus truly read-only as intended.Changes
src/hooks/prometheus-md-only/constants.ts: Added"bash"toBLOCKED_TOOLSsrc/hooks/prometheus-md-only/index.ts: Added specific handling for bash commands with a clear error messagesrc/hooks/prometheus-md-only/index.test.ts: Added test case to verify bash blocking behaviorSecurity Impact
This fix ensures Prometheus respects the security model by:
/start-workfor plan executionTesting
Checklist
devbranchSummary by cubic
Block bash command execution in Prometheus (Plan Builder) mode to honor opencode.jsonc permissions and keep Prometheus read-only. Fixes #1428.
Written for commit 8515ad7. Summary will update on new commits.