Skip to content

fix: restrict write and apply_patch permissions for plan mode#8360

Closed
shssoichiro wants to merge 1 commit into
Kilo-Org:mainfrom
shssoichiro:write-permissions
Closed

fix: restrict write and apply_patch permissions for plan mode#8360
shssoichiro wants to merge 1 commit into
Kilo-Org:mainfrom
shssoichiro:write-permissions

Conversation

@shssoichiro

Copy link
Copy Markdown
Contributor

Context

This was discovered while debugging #8358. The permissions in agent.ts were restricting the directories where the Plan agent can use the Edit tool, but not the ApplyPatch and Write tools. This change also applies the restrictions to ApplyPatch and Write to ensure that Plan mode cannot edit outside of the plans directory.

Get in Touch

ExpedientFalcon on Discord.

external_directory: {
[path.join(Global.Path.data, "plans", "*")]: "allow",
},
apply_patch: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: These new apply_patch/write rules do not enforce the plan-mode restriction.

WriteTool and ApplyPatchTool both call ctx.ask({ permission: "edit", ... }), so the path check still comes from the existing edit rules. PermissionNext.disabled() also maps write to edit, but not apply_patch, which means this block leaves apply_patch exposed to the model while not changing the runtime restriction. The fix likely needs to reuse the edit permission for apply_patch tool gating instead of adding separate apply_patch/write entries here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Well then this patch isn't needed.

@kilo-code-bot

kilo-code-bot Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/agent/agent.ts 237 Separate apply_patch/write permission entries do not affect runtime edit checks, so apply_patch remains available and the new restriction is ineffective.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

None.

Files Reviewed (1 files)
  • packages/opencode/src/agent/agent.ts - 1 issue

Reviewed by gpt-5.4-20260305 · 453,687 tokens

@kilo-code-bot

kilo-code-bot Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Closing this PR — its guidance and changes have been incorporated into PR #8417, which takes a more comprehensive approach to hardening plan mode permissions (including sub-agent restriction propagation, read-only bash enforcement, and MCP tool access). Thanks for identifying the apply_patch/write permission gap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant