Repository navigation
fix(notes): escape few-shot example interpolation to stop prompt self-poisoning - #572
Merged
Merged
Conversation
Contributor
|
Standing release PR: #555 · v0.41.0 queued (4 packages) · open 5h 13m · ✅ ready to merge Release Preview — v0.40.0 → v0.40.1
These changes will be added to the release PR (#555) when merged: Changelogmonorepo 0.40.0 → 0.40.1
After merge — predicted release
Updated automatically by ReleaseKit |
goosewobbler
force-pushed
the
fix/escape-example-interpolation
branch
from
July 19, 2026 19:13
8a24e00 to
8734b0f
Compare
…-poisoning renderExamplesBlock interpolated example fields (version, category, scope, leadIn, description) into the prompt's <example> block unescaped. Examples are built from past release bodies and release-notes output becomes a future example — a self-poisoning loop where an entry could forge a </example> tag or inject instructions into a later prompt. Escape every interpolated field, reusing the existing escAttr/escBody helpers (as already done for PR bodies in renderPRBlocks). Same prompt-injection hardening family as #540/#565. Closes #571 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011i1KvoyxATU3bz5V5Sf1Xu
goosewobbler
force-pushed
the
fix/escape-example-interpolation
branch
from
July 19, 2026 19:18
8734b0f to
591b9e7
Compare
This was referenced Jul 19, 2026
Merged
Closed
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 #571. Carved out of #542 (the eval-harness epic) as a standalone 0.41.0 fix.
Problem
renderExamplesBlock(packages/notes/src/llm/examples/parser.ts) interpolated example fields —version,category,scope,leadIn,description— into the prompt's<example>block unescaped. The examples are built from past release bodies (parseReleaseBodyToExample→fetchExamples), and release-notes output becomes a future example — a self-poisoning loop: an entry containing</example>or marker/instruction-like text could forge a closing tag or inject instructions into a later prompt.Same unescaped-interpolation class already fixed for PR bodies (
renderPRBlocksusesescAttr/escBody) and for task-prompt entry rendering (#540, #565).Fix
Escape every interpolated field, reusing the existing helpers in
packages/notes/src/llm/tasks/shared.ts:version(attribute) →escAttrcategory/scope/leadIn/description(body) →escBodyNo behavior change for well-formed input — it only neutralizes tag/marker-forging content. Added a
renderExamplesBlockspec that feeds hostile fields and asserts they're escaped (and the block's own</example>is the only literal one left).Verification
pnpm turbo run lint typecheck test --filter=@releasekit/notes— green (403 tests, incl. the new one).🤖 Generated with Claude Code
Greptile Summary
This PR closes the prompt self-poisoning loop in
renderExamplesBlockby HTML-escaping every interpolated field derived from past release bodies before they enter the few-shot<example>block. Without this fix, a crafted release description containing</example>or instruction-like text could forge a closing tag or inject markup into a later prompt.version(XML attribute) is now escaped withescAttr;category,scope,leadIn, anddescription(body text) are escaped withescBody— reusing the same helpers already applied to<pr>and<entry>blocks.renderExamplesBlockspec feeds hostile values in every field and asserts all</>/&characters are encoded, with exactly one literal</example>(the block's own closing tag) remaining.Confidence Score: 5/5
Safe to merge — the escaping is correct, complete, and consistent with the existing pattern used for PR and entry blocks.
Every interpolated field in renderExamplesBlock is now escaped at render time with the right helper (attribute vs body context), the raw-then-escape flow through the cache is correct, and the new test exercises hostile values in all five fields with both negative and positive assertions.
No files require special attention.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(notes): escape few-shot example inte..." | Re-trigger Greptile