Skip to content

fix: Prevent context attributes from influencing judge template parsing (SEC-8020)#361

Merged
knfreemLD merged 3 commits into
v7from
kfreeman/hotfix-mustache
Apr 13, 2026
Merged

fix: Prevent context attributes from influencing judge template parsing (SEC-8020)#361
knfreemLD merged 3 commits into
v7from
kfreeman/hotfix-mustache

Conversation

@knfreemLD
Copy link
Copy Markdown
Contributor

@knfreemLD knfreemLD commented Apr 9, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.


Note

Medium Risk
Changes judge message rendering logic to avoid Mustache parsing on user-controlled content, which can affect evaluation prompts and is security-adjacent. Risk is limited to judge prompt construction but could change output text in edge cases.

Overview
Prevents user-controlled context attributes containing Mustache control sequences from affecting judge prompt construction by replacing the pass-2 Mustache render with literal placeholder string substitution in Judge.buildMessages.

Centralizes the reserved judge placeholders ({{message_history}}, {{response_to_evaluate}}) as shared constants in ldai and updates JudgeConfig to inject those constants. Adds regression tests covering Mustache injection variants, multiple placeholder occurrences, and preserving Mustache-like syntax in history/response text.

Reviewed by Cursor Bugbot for commit 1793aa5. Bugbot is set up for automated code reviews on this repo. Configure here.

@knfreemLD knfreemLD requested a review from a team as a code owner April 9, 2026 13:22
@knfreemLD knfreemLD changed the title [SEC-8020] fix mustache server side injection fix: fix mustache server side injection (SEC-8020) Apr 9, 2026
@jsonbailey jsonbailey changed the title fix: fix mustache server side injection (SEC-8020) fix: Prevent context attributes from influencing judge template parsing (SEC-8020) Apr 9, 2026
Comment thread ldai/judge/judge.go Outdated
Co-authored-by: Jason Bailey <jbailey@launchdarkly.com>
@knfreemLD knfreemLD merged commit a14fc86 into v7 Apr 13, 2026
34 checks passed
@knfreemLD knfreemLD deleted the kfreeman/hotfix-mustache branch April 13, 2026 16:31
jsonbailey pushed a commit that referenced this pull request May 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.9.0](ldai/v0.8.1...ldai/v0.9.0)
(2026-05-11)


### ⚠ BREAKING CHANGES

* Tracker no longer returned alongside AI Configs, use
Config.CreateTracker() instead
* Add per-execution runId, at-most-once tracking, and cross-process
tracker resumption
([#363](#363))

### Features

* Add per-execution runId, at-most-once tracking, and cross-process
tracker resumption
([#363](#363))
([c11294f](c11294f))
* Rename TrackUsage to TrackTokens
([#364](#364))
([9b0863a](9b0863a))
* Tracker no longer returned alongside AI Configs, use
Config.CreateTracker() instead
([c11294f](c11294f))


### Bug Fixes

* Prevent context attributes from influencing judge template parsing
(SEC-8020)
([#361](#361))
([a14fc86](a14fc86))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low code risk since this PR only bumps version metadata and changelog
entries, but it publishes a new `ldai` release that includes documented
breaking changes for consumers.
> 
> **Overview**
> Bumps the `ldai` package release from `0.8.1` to `0.9.0` by updating
the release manifest and `ldai` version constant.
> 
> Updates `ldai/CHANGELOG.md` with the `0.9.0` release notes, including
**breaking changes** around tracker creation/return behavior plus new
tracking semantics and a `TrackUsage`→`TrackTokens` rename, and a judge
template parsing fix.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7582350. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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