validator permission pin bypassable via an empty line inside the block #244

Closed
opened 2026-11-21 20:38:58 +01:00 by motoko · 0 comments
Collaborator

Location

scripts/verify-agent-config.sh, the extraction awk inside
check_permissions (n == 1 && inblock && /^ / { print; next } with
the fall-through { inblock = 0 }).

Evidence

The extracted block ends at the first genuinely empty line, but a YAML
block sequence survives empty lines: rules indented after an empty
line are invisible to the exact-text comparison while OpenCode still
parses them as part of the same permissions: list. So an adapter
whose pinned rules are followed by an empty line and a hidden
- action: "webfetch" / resource: "*" / effect: "allow" rule passes
the pin and the mixing rule unchanged, quietly widening a read-only
agent. Reproduced against the real program at f491863; the same
craft passes main's pre-V2 extraction too, so the flaw predates the
V2 migration.

Scenario

Template content or a low-privilege downstream edit plants the hidden
grant in an adapter file. The validation suite — the mechanism that
exists to catch exactly that — reports the file as pinned, and the
role gains web access (or edit).

Smallest fix

One line in the extraction, so a block containing an empty line can
never equal the pin (fail-closed):

n == 1 && inblock && /^$/ { print; next }

plus one tamper case beside the other OpenCode reviewer cases in
tests/agent-config/reviewer-adapters.sh.

Seen at f491863; reported by security-reviewer in the review round
of pull request #242. A fix branch follows.

## Location `scripts/verify-agent-config.sh`, the extraction awk inside `check_permissions` (`n == 1 && inblock && /^ / { print; next }` with the fall-through `{ inblock = 0 }`). ## Evidence The extracted block ends at the first genuinely empty line, but a YAML block sequence survives empty lines: rules indented after an empty line are invisible to the exact-text comparison while OpenCode still parses them as part of the same `permissions:` list. So an adapter whose pinned rules are followed by an empty line and a hidden `- action: "webfetch" / resource: "*" / effect: "allow"` rule passes the pin and the mixing rule unchanged, quietly widening a read-only agent. Reproduced against the real program at `f491863`; the same craft passes main's pre-V2 extraction too, so the flaw predates the V2 migration. ## Scenario Template content or a low-privilege downstream edit plants the hidden grant in an adapter file. The validation suite — the mechanism that exists to catch exactly that — reports the file as pinned, and the role gains web access (or `edit`). ## Smallest fix One line in the extraction, so a block containing an empty line can never equal the pin (fail-closed): ```awk n == 1 && inblock && /^$/ { print; next } ``` plus one tamper case beside the other OpenCode reviewer cases in `tests/agent-config/reviewer-adapters.sh`. Seen at `f491863`; reported by `security-reviewer` in the review round of pull request #242. A fix branch follows.
Sign in to join this conversation.
No description provided.