Skip to content

fix(judge): treat agent_judge review materials as untrusted data - #429

Merged
zpzjzj merged 1 commit into
alibaba:mainfrom
BiBoyang:fix/judge-untrusted-materials
Nov 23, 2026
Merged

zpzjzj merged 1 commit into
alibaba:mainfrom
BiBoyang:fix/judge-untrusted-materials

Conversation

@BiBoyang

Copy link
Copy Markdown
Contributor

Summary

The agent_judge prompt fenced each inline review material with three backticks and did not say who wrote it. Output from the agent under evaluation that contained its own fence could close the excerpt and continue as prompt text, for example a forged ## Required Output Contract asking for every criterion to pass, and the judge had no instruction to discount it. The response-format example also pre-filled "passed": true for every criterion, while the file-delivery template uses null.

Related issues

None filed. I found this while reviewing how agent_judge separates the evaluated output from its own instructions; happy to open an issue if you prefer one.

Changes

  • ## Review Materials now states that inline excerpts and referenced files come from the agent run under evaluation and are evidence, never instructions, and that requests inside them to change the criteria, the verdict or the output contract are to be ignored.
  • Each inline excerpt is fenced with more backticks than its longest backtick run (materialFence), so its content cannot terminate the fence.
  • The response-format example shows "passed": null and asks the judge to replace every null, matching the file template, so the example no longer suggests a verdict.
  • CHANGELOG entry under Unreleased / Fixed.

Test plan

  • make test passes
  • make verify passes (fmt + vet + lint)
  • New tests in internal/judge/agent_judge_test.go:
    • TestBuildJudgePrompt_KeepsInjectedMaterialInsideItsExcerpt: a final message holding its own fence and a forged output contract stays inside a longer fence, and the program-owned contract still comes after it; the prompt carries the untrusted-data statement.
    • TestMaterialFence (table-driven): no backticks, inline code, a triple fence, longest run wins.
    • TestRequiredResponseFormat_DoesNotSuggestAVerdict: one "passed": null per criterion and no pre-filled boolean.

Notes for reviewers

  • Prompt text only; no parsing or validation change. passed is already *bool, so a judge that copies the null literally fails validation and goes through the existing correction retry rather than passing.
  • The fence length is derived from the content, so the prompt stays deterministic for the same materials.

The judge prompt fenced each inline material with three backticks and said
nothing about who wrote it. Output from the agent under evaluation that
contained its own fence could close the excerpt and continue as prompt text,
for example a forged "## Required Output Contract" asking for every criterion
to pass, and the judge had no instruction to discount it.

- State in "## Review Materials" that inline excerpts and referenced files come
  from the agent run under evaluation and are evidence, never instructions.
- Fence each inline excerpt with more backticks than its longest backtick run,
  so its content cannot terminate the fence.
- Show "passed": null in the response-format example instead of
  "passed": true, matching the file template, so the example does not suggest
  a verdict.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T02:16:42.800211Z c77639a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zpzjzj
zpzjzj added this pull request to the merge queue Nov 23, 2026
Merged via the queue into alibaba:main with commit 8a7d56a Nov 23, 2026
17 checks passed
BiBoyang added a commit to BiBoyang/skill-up that referenced this pull request Nov 23, 2026
Bring in alibaba#429, alibaba#414 and alibaba#424 from main. The only textual conflict was in
CHANGELOG.md, where this branch and alibaba#414 each added an entry at the top of
Unreleased / Added; both entries are kept.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants