Skip to content

fix(template): prevent injection via #each data values#1240

Merged
chaliy merged 1 commit intomainfrom
fix/1164-template-each-injection
Apr 12, 2026
Merged

fix(template): prevent injection via #each data values#1240
chaliy merged 1 commit intomainfrom
fix/1164-template-each-injection

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 12, 2026

Summary\n\n- Escape {{ in data values before substitution in #each blocks using a sentinel\n- Sentinel is restored after render_template_inner so literal {{ is preserved in output\n- JSON data containing {{SECRET_KEY}} now produces the literal string, not the variable's value\n\n## Test plan\n\n- [x] test_each_data_injection_blocked — secret variable not leaked through data\n- [x] test_each_nested_directive_in_data_not_evaluated{{#if}} in data preserved literally\n- [x] Existing test_each_block still passes\n- [x] cargo clippy and cargo fmt clean\n\nCloses #1164

Escape {{ in data values before substitution so template directives
embedded in JSON data are not re-evaluated. Uses a sentinel that is
restored after rendering, preserving literal {{ in output.

Closes #1164
@chaliy chaliy merged commit 948ff27 into main Apr 12, 2026
27 checks passed
@chaliy chaliy deleted the fix/1164-template-each-injection branch April 12, 2026 09:51
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.

1 participant