anomalyco / anomalyco/opencode
fix(core): custom agent frontmatter permission adds to defaults instead of replacing them
@neriousy is already working on this.
Since Sep 7, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
The permissive default is documented (permissions.mdx: "Most permissions default to allow"). What is not: an agent frontmatter permission ADDS to the defaults instead of replacing them (agent.ts:293 additive merge; Permission.merge = rulesets.flat(), permission/index.ts:200-202). So a partial agent allowlist closes NOTHING unless the author knows to put "*": deny first (evaluate = findLast, last match wins — wildcard.ts:8 *→.*).
Repro (v1.18.29, Linux)
- subagent with bash allowlist, no
*: deny2. runstatoutside the worktree — executes; log:evaluated permission=bash pattern="stat ..." action.permission=* action.action=allow(catch-all rule). 3. with"*": denyas first bash rule the agent should lock (grep allow still passes — code-verified via findLast + insertion order, not runtime-tested).
Risk
A "read-only" agent runs everything. Non-FILE-aware commands (ls/stat) bypass external_directory too (scan.dirs unfed, shell.ts:378-414).
Proposed fix
If agent frontmatter defines permission, merge by replacement — or inject implicit *: deny for subagents. Minimum: document that every allowlist must start with "*": deny.
Verified to dev@57ef382843. Searched "permission allowlist", "agent default allow" — no duplicate found.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.