Repository navigation
fix(dotprompt-go): add per-render nonce to template markers - #641
Merged
Merged
Conversation
The role, history, section and media helpers emit in-band markers that are split back out of the rendered string, which also contains user-supplied values verbatim. An end user controlling any interpolated value could forge system/model turns, inject media parts with arbitrary URLs, move history, or inject pending section parts. Every marker now carries a random 128-bit nonce generated per render, and the parser only honors markers with that nonce, classifying pieces by position rather than prefix. Anything else that looks like a marker stays literal text.
This was referenced Nov 16, 2026
This was referenced Nov 16, 2026
govulncheck flags GO-2026-5970 (infinite loop on invalid input in golang.org/x/text norm), reachable via ValidatePromptName. Fixed in v0.39.0.
Collaborator
Author
|
/gemini review |
pavelgj
added a commit
that referenced
this pull request
Nov 16, 2026
- zizmor fails on Medium/High findings in touched workflows: move deploy.yml's pages/id-token write to the deploy job, set persist-credentials: false on checkouts that don't push, and disable caching in publishing workflows (drop sccache from promptly-npm, set package-manager-cache/enable-cache to false). - Bump golang.org/x/text to v0.39.0 (GO-2026-5970, flagged by govulncheck via ValidatePromptName). Same change as #641. - gRPC example: the client is pinned to protobuf 4.x (Flutter 3.27) and the server to protobuf 6.0.x, so a single unpinned protoc_plugin can't generate code for both. Pin protoc_plugin per side (22.4.0 / 25.0.0). - requirements.txt: restore the export command in the header.
pavelgj
added a commit
that referenced
this pull request
Nov 16, 2026
* ci: fix CI checks broken by tool and dependency drift Several checks fail on every PR for reasons unrelated to the change under test: - Lock-file checks (pnpm-lock.yaml, go.sum) check out with RELEASE_PLEASE_TOKEN on all PRs and fail at checkout; only use it (and head_ref) on release-please branches, matching python/rust/bazel. - govulncheck@latest now requires Go 1.26, breaking the Go 1.25 leg; pin v1.7.0. - golangci-lint v2.10.1 (built with Go 1.26) panics on Go 1.27 (stable); bump to v2.15.0. - Unpinned biome picked up new markdown/import rules; pin 2.3.15 to match biome.json's $schema. - pysentry flags soupsieve (dev-only, via jupyter); upgrade it where a fixed release is installable and ignore the advisories that remain only on the older-Python fork. * ci: remove release-please from CI Release-please is no longer used; its token is broken and the release workflow has been failing on main. Remove the Release Please and config validation workflows, the per-workflow steps that pushed lockfile updates back to release-please PRs (and the write permissions / PAT checkout they needed), and the release-please PR labels. The release-triggered publish workflows are kept; they still run when a GitHub release is created manually. * ci: pin actions to commit SHAs and set explicit permissions The org-level zizmor check fails on mandatory audits for any workflow a PR touches. Pin every action to a full commit SHA (latest release within the already-referenced major, version in a trailing comment), move tj-actions/changed-files off v45 (GHSA-mrrh-fwg8-r2c3) to the v47.0.6 pin python.yml already uses, and add top-level `permissions: contents: read` to every workflow that lacked one (jobs that need more already declare it). Also drop the now-unneeded workflow-level write permissions in js.yml and go.yml, fix a redundant clone flagged by current stable clippy (the Rust workflow runs because rust.yml changed), and regenerate requirements.txt with current uv. * ci: fix remaining zizmor findings, Go vuln scan, and gRPC example - zizmor fails on Medium/High findings in touched workflows: move deploy.yml's pages/id-token write to the deploy job, set persist-credentials: false on checkouts that don't push, and disable caching in publishing workflows (drop sccache from promptly-npm, set package-manager-cache/enable-cache to false). - Bump golang.org/x/text to v0.39.0 (GO-2026-5970, flagged by govulncheck via ValidatePromptName). Same change as #641. - gRPC example: the client is pinned to protobuf 4.x (Flutter 3.27) and the server to protobuf 6.0.x, so a single unpinned protoc_plugin can't generate code for both. Pin protoc_plugin per side (22.4.0 / 25.0.0). - requirements.txt: restore the export command in the header.
The media/section marker regex used `.*?`, which does not match newlines. A user-controlled media url or section name containing a newline made the trusted marker fail to match, so the media part was dropped and the raw marker, nonce included, was emitted as text. Prefix the pattern with (?s) so the body can span lines while still stopping at the first `>>>`. Adds regex and splitter unit tests for multiline bodies and an end-to-end render test asserting the media part survives and no marker leaks.
apascal07
reviewed
Nov 16, 2026
The nonce-carrying marker regexps can't be package-level, but toParts compiled the media/section regexp for every message source, so a render with N messages compiled N+1 regexps. ToMessages now compiles both regexps once after nonce validation and passes the media/section regexp down to messageSourcesToMessages and toParts. Adds a toParts test and a ToMessages benchmark.
apascal07
approved these changes
Nov 18, 2026
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.
What's new
<<<dotprompt:{nonce}:role:system>>>.<<<dotprompt:...>>>markers written in template source, passed in input, or returned by custom helpers are no longer interpreted. No in-repo templates rely on this.Go specifics
data.Context; helpers readoptions.Data(...)and panic with an error (returned byExecWith) if missing.{{json}}was not exploitable in Go (json.Marshalescapes</>); test kept for parity.Why
The
role,history,sectionandmediahelpers emit in-band markers (<<<dotprompt:role:system>>>) into the rendered string, which is then split back into messages. The rendered string also contains user-supplied values verbatim, so any end user who controls an interpolated value can forge markers:This forges system/model turns, injects media parts with arbitrary URLs (server-side fetch / SSRF when a model plugin downloads media, e.g. Genkit's Vertex AI plugin), moves history insertion, and injects pending section parts. It works through
{{x}},{{{x}}},{{json x}},#each, and partials. Escaping input can't reliably fix it (triple-stash andSafeStringhelpers skip escaping, and markers can be assembled from adjacent values), so markers are now authenticated instead.Not in this PR
spec/conformance test for injection (follow-up after all runtimes land).{{media url=...}}against user URLs with spaces or>>>(pre-existing parsing quirk, can't forge markers).downloadRequestMediaSSRF hardening (separate repo).Sibling PRs (one per runtime, independent, no stacking): JS #640, Go #641, Python #642, Dart #643, Java #644, Rust #645.