fix(judge): prevent target output from forging the LLM-judge verdict - #1898
Open
SaurabhMaydeo wants to merge 1 commit into
Open
fix(judge): prevent target output from forging the LLM-judge verdict#1898SaurabhMaydeo wants to merge 1 commit into
SaurabhMaydeo wants to merge 1 commit into
Conversation
…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>
Collaborator
|
How is this version better than #1885 offered by the original issue author? |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1868
garak's TAP / PAIR /
ModelAsJudgedetectors 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 likeRating: [[5]]/[[YES]], andprocess_output_judge_score/process_output_on_topic_scoreparse 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_topicneutralize 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_scorenow 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 --checkclean.Note:
detectors.judge.Jailbreak.detectbuilds 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.