Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Template delimiters (Jinja2, Liquid, ERB, JavaScript, Jekyll) weren't being sanitized. Defense-in-depth gap if content flows to downstream template engines.

Changes

  • Added neutralizeTemplateDelimiters() to sanitize_content_core.cjs

    • Escapes: {{\{\{, <%=\<%=, ${\$\{, {#\{#, {%\{%
    • Logs detection warnings for visibility
    • Runs after bot trigger neutralization, before markdown balancing
  • Test coverage for all patterns, edge cases (nested, already-escaped, in code blocks)

  • Documentation in scratchpad/template-syntax-sanitization.md

Example

// Input from issue body
"Check {{ secrets.TOKEN }} and <%= config %>"

// After sanitization
"Check \\{\\{ secrets.TOKEN }} and \\<%= config %>"

Context

GitHub markdown doesn't evaluate template syntax (no current risk), but this prevents issues if content is later processed by template engines - standard defense-in-depth.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Changeset

  • Type: patch
  • Description: Documented sanitization of template delimiters (Jinja2/Liquid/ERB/JS/Jekyll) in sanitize_content_core.cjs to prevent downstream template injection bypasses.

Generated by Changeset Generator

Copilot stopped work on behalf of pelikhan due to an error February 11, 2026 22:08
Copilot stopped work on behalf of pelikhan due to an error February 11, 2026 22:08
Copilot AI and others added 6 commits February 11, 2026 22:13
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add neutralizeTemplateDelimiters function to sanitize_content_core.cjs
- Detects and escapes Jinja2/Liquid ({{), ERB (<%=), JS template literals (${), Jinja2 comments ({#), and Jekyll directives ({%)
- Logs info messages for each detected template pattern
- Logs warning message summarizing defense-in-depth approach
- Integrates template neutralization into sanitizeContentCore pipeline
- Add comprehensive test suite covering all template types and edge cases
- All 233 tests passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Create comprehensive documentation in scratchpad/template-syntax-sanitization.md
- Explains the T24 security concern and solution
- Documents all template patterns detected and their escaping strategy
- Includes defense-in-depth rationale and test coverage summary
- Manual testing confirms all T24 test payloads are properly escaped

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Keep PR focused on template sanitization only
- Fix comment in sanitize_content_core.cjs to accurately describe ERB escaping
- Revert unrelated lock file recompilation changes to keep PR focused

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Use explicit newline characters instead of template literal
- Makes test clearer that we're testing ${ not \$

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix template syntax sanitization vulnerabilities Add template syntax sanitization to prevent injection bypass (T24) Feb 11, 2026
Copilot AI requested a review from pelikhan February 11, 2026 22:28
@pelikhan pelikhan marked this pull request as ready for review February 11, 2026 22:50
Copilot AI review requested due to automatic review settings February 11, 2026 22:50
@pelikhan pelikhan added the smoke label Feb 11, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

🧪 Smoke Project is now testing project operations...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2026

Changeset Generator completed successfully!

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements template syntax sanitization to prevent potential template injection attacks as a defense-in-depth security measure. While GitHub's markdown rendering doesn't currently evaluate template syntax, this change protects against scenarios where content might be processed by downstream template engines (Jinja2, Liquid, ERB, JavaScript template literals, Jekyll).

Changes:

  • Added neutralizeTemplateDelimiters() function that escapes template delimiters using backslash escaping (e.g., {{\{\{)
  • Integrated the function into the core sanitization pipeline between bot trigger neutralization and markdown code region balancing
  • Added 17 comprehensive test cases covering all template types and edge cases
  • Created detailed documentation explaining the security rationale, implementation details, and usage

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
scratchpad/template-syntax-sanitization.md Comprehensive documentation describing the template injection defense, patterns detected, implementation details, and security rationale
actions/setup/js/sanitize_content_core.cjs Implementation of neutralizeTemplateDelimiters() function with backslash escaping for 5 template types, integration into sanitization pipeline, and proper exports
actions/setup/js/sanitize_content.test.cjs 17 new test cases covering individual template types, multiple occurrences, mixed patterns, edge cases (double-escaping, code blocks, GitHub Actions expressions, nested patterns)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.52.0
jq 1.7
yq 4.52.2
curl 8.5.0
gh 2.86.0
node 20.20.0
python3 3.12.3
go 1.24.12
java 21.0.10 (OpenJDK)
dotnet 10.0.102

Result: 12/12 tools available ✅

All required development tools are present and functional in the agent container environment.

AI generated by Agent Container Smoke Test

@github-actions github-actions bot mentioned this pull request Feb 11, 2026
@github-actions
Copy link
Contributor

Smoke Project completed successfully. All project operations validated.

@github-actions
Copy link
Contributor

PRs: #15018 Sort GH_AW_RATE_LIMIT_EVENTS alphabetically
PRs: #15017 Apply shell escaping with @Q to environment variables in echo statements
GitHub MCP ✅
Serena MCP ✅
Playwright ✅
File write ✅
Bash cat ✅
Build ✅
Overall: PASS

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

Smoke Test Results

Status:PASS

Tests:

Run: §21926186000

cc @pelikhan @Copilot

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@pelikhan pelikhan merged commit 4d131a4 into main Feb 11, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/fix-template-sanitization-issue branch February 11, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants