fix: Prevent context attributes from influencing judge template parsing#129
Draft
jsonbailey wants to merge 1 commit intomainfrom
Draft
fix: Prevent context attributes from influencing judge template parsing#129jsonbailey wants to merge 1 commit intomainfrom
jsonbailey wants to merge 1 commit intomainfrom
Conversation
Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Requirements
Related issues
Addresses SEC-8020. Mirrors the fix applied in the Go server AI SDK (
go-server-sdkcommit3317871). A parallel PR is also being created forlaunchdarkly/js-core.Describe the solution you've provided
The judge's
_interpolate_messagemethod previously usedchevron.render()(Mustache templating) for its second-pass interpolation of{{message_history}}and{{response_to_evaluate}}placeholders. This is vulnerable to template injection: attacker-controlled values resolved during pass 1 (e.g. Mustache delimiter-change tags like{{=[ ]=}}) would be interpreted as control syntax by the second Mustache pass, potentially blinding the judge to the actual content being evaluated.This PR replaces the Mustache-based interpolation with simple
str.replace()calls. Since the judge only ever substitutes two known placeholder strings, a full template engine is unnecessary, and literal string replacement is both safer and simpler.Note:
chevronis still used inclient.pyfor the first-pass template interpolation (which is expected behavior — pass 1 needs Mustache to resolve context variables).Describe alternatives you've considered
Additional context
Key items for review:
chevronimport removal from the judge module doesn't affect other code paths (it doesn't —chevronis only used inclient.pyfor pass 1).Link to Devin session: https://app.devin.ai/sessions/651e799b906748a4834bafefb4a3e3e5
Requested by: @jsonbailey