validator trusts frontmatter delimiters the client does not #245
Labels
No labels
bug
cannot reproduce
duplicate
enhancement
help wanted
invalid
need info
need triage
need verification
not a bug
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
claudiomaradonna/agent-foundry#245
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Location
scripts/verify-agent-config.sh,check_permissions: the frontmatterregion is chosen at line 431 (
frontmatter=$(awk '/^---$/ …')), the blockextraction counts the same delimiters at line 444, and the comparison is at
line 449.
Evidence
The validator treats a line that is exactly
---as the frontmatter'sopening and closing delimiter. OpenCode follows YAML's document boundaries,
which tolerate a leading byte-order mark, a trailing space or tab, and a
\rline break, and which do not require a delimiter at all. Where the twodisagree, the check compares text the client never reads: the pinned block
can sit in the body, and the frontmatter the client parses can hold nothing
that the pin sees.
security-reviewerreproduced this on OpenCode v2.3.2 atf491863and onthe
validator-blankline-pintip, reading the parsed grants withopencode debug agents. The crafted files and their exact bytes stay inthe review record, not here.
Scenario
A contributor's pull request against an adopting project changes only the
first bytes of
.opencode/agents/change-reviewer.md— a UTF-8 BOM, whichno editor shows and which
git diffrenders as---on both sides — andcopies the permissions block into the body as a fenced example.
bash tests/verify-agent-config.sh, CI, and the maintainer's ownscripts/verify-agent-config.shprintstatically valid, while OpenCoderuns that read-only reviewer with its defaults:
edit,write,shell,webfetchandwebsearchall available. The same disagreement also disarmsthe mixing rule at lines 434-435, which greps the same region: a frontmatter
carrying both a V1
permission:map and a V2permissions:list passes.A checkout with CRLF line endings fails in the other direction, refusing a
legitimate adapter because no delimiter is counted; the template ships no
.gitattributes.Smallest fix
Fail closed on the region rather than on the block: strip a leading BOM,
accept
/^---[ \t]*\r?$/as the delimiter in both awk programs, and reportfrontmatter delimiters missing or alteredwhen line 1 is not one, or noclosing delimiter follows. The seven shipped adapters open with
---andno tracked file holds a BOM or a CR, so this refuses nothing today. A
...document-end marker belongs with the same family: neither programrecognizes it. The permanent fix is extracting through a YAML parser, which
needs a dependency the Test and Verify commands do not have.
Seen at
f491863, and unchanged on89f4139. Reported bysecurity-reviewerduring the review of the branch that closes #244.