fix: enforce strict read-only permissions on explore agent#37
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the explore subagent to be strictly read-only by fixing the permission merge order and removing bash access. Previously, the explore agent could write files through bash commands or via permissive user config overrides.
Changes:
- Moved
userconfig before the hard restrictions inPermissionNext.merge()so user config cannot override the read-only enforcement, and added explicit denials forbash,edit,write,todowrite,todoread, andtask. - Strengthened the explore prompt to unambiguously prohibit any write operations and removed the bash usage guideline.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/opencode/src/agent/agent.ts |
Fixes permission merge order (defaults, user, restrictions), removes bash: "allow", adds explicit denials for write-capable tools |
packages/opencode/src/agent/prompt/explore.txt |
Removes bash guideline, replaces soft "Do not create" wording with strict read-only directive |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
fix: enforce strict read-only permissions on explore agent
The
exploresubagent was able to write files despite being intended as read-only. Two vulnerabilities allowed this:bash: "allow"— bash access lets an agent write files via shell commands (e.g.echo > file,sed -i), bypassingwrite/editpermission checks entirely.userconfig was merged last, meaning a permissive user config could grantwrite/editand it would stick.inspectandkeeperalready use the safe pattern (merge(defaults, user, hardRestrictions)).learn,exploredidn't explicitly denyedit,write,todowrite,todoread,task.Fix: Remove
bash: "allow", add explicit denials forbash,edit,write,todowrite,todoread,task, move hard restrictions to the final non-overridable merge position, and strengthen prompt wording.feat: add /biblion reset TUI command
Adds
/biblion resetslash command to the TUI prompt, mirroring the existing/memory resetcommand. Shows a confirmation dialog then callssdk.client.biblion.clear()to wipe all biblion entries. Only enabled whenbiblion_status.type === "ready".