SkillSpector icon indicating copy to clipboard operation
SkillSpector copied to clipboard

opencode_cli on OpenCode 2.x: the 1.x deny-all policy is ignored; a project opencode.jsonc resolves to deny-all

Open MJ0006 opened this issue 3 weeks ago • 1 comments

#712 notes that OpenCode 2.x is tracked separately; I could not find a public issue for it, so here are measurements from OpenCode 2.2.6 (npm @opencode/cli, whose latest tag is now 2.2.7). SkillSpector v2.13.4 fails closed on this version, as designed: a scan with SKILLSPECTOR_PROVIDER=opencode_cli exited 2, every LLM call failed with AgentCLIError, llm_available was false and the report said it may reflect static analysis only (the reason in the provider source is the _OPENCODE_SUPPORTED_VERSION = "1.18.31" gate). That refusal is correct, and the measurements below show why simply widening the version set would be unsafe on 2.x. Windows 11, every check in a fresh temporary directory; none of it made an inference call.

1. The 1.x deny-all policy is silently ignored on 2.2.6

_opencode_config() passes the policy through OPENCODE_CONFIG_CONTENT (1.x shape: agent map, permission: {"*": "deny"}, default_agent). On 2.2.6:

  • opencode debug config no longer prints the resolved config. It prints a list of configuration sources (for example {"type": "directory", "path": ".../.config/opencode"}), so the preflight's subset check has nothing to compare against.
  • opencode debug agents printed output of the same length (11,628 characters) with and without OPENCODE_CONFIG_CONTENT, and neither listed the policy's agent.
  • The default build agent's resolved permissions begin with {"action": "*", "resource": "*", "effect": "allow"}.

The same held when OPENCODE_CONFIG_CONTENT carried the 2.x shape (agents map, a permissions list), and when that JSON was put in a file named by OPENCODE_CONFIG: in all three cases debug agents listed only build, compaction, explore, general, plan, summary, title.

2. A project opencode.jsonc in the working directory is honoured

With this file in the temporary working directory (both agents and agent as the key loaded the agent):

{"$schema": "https://opencode.ai/config.json",
 "agents": {"ssprobe": {"description": "probe", "mode": "primary",
   "permissions": [{"action": "*", "resource": "*", "effect": "deny"}]}},
 "permissions": [{"action": "*", "resource": "*", "effect": "deny"}]}

opencode debug agents listed ssprobe with these resolved permissions, in this order:

0 * * allow
1 read *.env ask
2 read *.env.* ask
3 read *.env.example allow
4 * * deny
5 * * deny
6 browser * deny
7 skill browser deny

OpenCode's permission docs say the last matching rule wins, so every action resolves to deny for this agent. The built-in agents keep their defaults (the build agent still starts with * * allow), so the provider would have to select the agent explicitly (opencode run --agent ...) and refuse if it is missing.

Not measured: actual behaviour under this policy. The account I tested with had used its free allowance ("Free usage limit reached" on every free model), so no request ran; whether the resolved denies hold for every tool, and whether a user-level config or an organisation-provided config document (the sources list showed one) can add rules after the project file, are open.

3. What this suggests (yours to weigh)

  • A 2.x provider could deliver its policy as a project opencode.jsonc in the per-run temporary directory rather than through OPENCODE_CONFIG_CONTENT.
  • opencode debug agents looks usable as the 2.x preflight: confirm the selected agent exists and that its resolved permission list ends in a deny-all with no later allow.
  • Keeping 2.x rejected until such a check exists is the right default; the current pin already does that.

Happy to re-run with a working allowance or on a newer 2.x release.

MJ0006 avatar Nov 10 '26 11:11 MJ0006

Hi, I would like to take this on. The measurements check out as a real gap: on OpenCode 2.x the 1.x deny-all policy passed through OPENCODE_CONFIG_CONTENT is silently ignored, so a scan that admitted 2.x would run with the build agent at allow-all. I will implement the 2.x path the issue suggests: deliver the policy as a project opencode.jsonc in the per-run temporary directory, select the probe agent explicitly, and preflight with opencode debug agents, confirming the agent exists and its resolved permission list ends in a deny-all with no later allow. 2.x stays rejected until that check exists. Could you please assign this issue to me?

Varshith-Kali avatar Nov 10 '26 19:11 Varshith-Kali