Skip to content

fix(judge): prevent target output from forging the LLM-judge verdict - #1898

Open
SaurabhMaydeo wants to merge 1 commit into
NVIDIA:mainfrom
SaurabhMaydeo:fix/judge-verdict-injection
Open

fix(judge): prevent target output from forging the LLM-judge verdict#1898
SaurabhMaydeo wants to merge 1 commit into
NVIDIA:mainfrom
SaurabhMaydeo:fix/judge-verdict-injection

Conversation

@SaurabhMaydeo

Copy link
Copy Markdown

Closes #1868

garak's TAP / PAIR / ModelAsJudge detectors score jailbreak success with an LLM-as-judge: the target's response is interpolated into the judge prompt, the judge is asked to reply with a verdict like Rating: [[5]] / [[YES]], and process_output_judge_score / process_output_on_topic_score parse that token. Because the (attacker-controlled) target response was interpolated unescaped and the parser took the first [[...]] match, a target could append a forged verdict (e.g. Rating: [[1]]) to make a harmful response score as safe — a prompt injection of the judge. The issue includes a working PoC against a live judge.

This hardens the shared judge primitives in resources/red_team/evaluation.py, addressing both halves of the gap:

  • get_evaluator_prompt / get_evaluator_prompt_on_topic neutralize the double-bracket verdict markers in interpolated text ([[1]][1]), so untrusted output can't carry a forged verdict into the judge's context.
  • process_output_judge_score / process_output_on_topic_score now read the judge's final verdict instead of the first match, so any earlier token that still leaks through can't win.

Both layers have regression tests.

Verified: pytest tests/resources/red_team/test_evaluation.py tests/detectors/test_detectors_judge.py → 41 passed; black --check clean.

Note: detectors.judge.Jailbreak.detect builds its own <BEGIN RESPONSE>… evaluation prompt rather than going through these helpers. It benefits from the final-verdict parsing here, but its inline interpolation could get the same neutralization in a follow-up if you'd like it in scope.

…VIDIA#1868)

Sanitize untrusted text interpolated into the judge prompt and parse the
judge's final verdict, so a target response cannot inject a forged
[[N]]/[[YES]] rating to skew the score.

Signed-off-by: Saurabh Maydeo <saurabhmaydeo@gmail.com>
@jmartin-tech

Copy link
Copy Markdown
Collaborator

How is this version better than #1885 offered by the original issue author?

@jmartin-tech jmartin-tech changed the title fix(judge): prevent target output from forging the LLM-judge verdict (#1868) fix(judge): prevent target output from forging the LLM-judge verdict Jul 15, 2026
@jmartin-tech jmartin-tech self-assigned this Jul 15, 2026
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.

TAP/PAIR LLM-judge prompt interpolates target response unescaped — model output can forge Rating rail and flip jailbreak to safe

2 participants