Skip to content

twig/twig patches - #24

Merged
aembler merged 4 commits into
masterfrom
twig-patches
May 26, 2026
Merged

twig/twig patches#24
aembler merged 4 commits into
masterfrom
twig-patches

Conversation

@aembler

@aembler aembler commented May 26, 2026

Copy link
Copy Markdown
Member

This pull request updates the composer.json patches for twig/twig to version 3.11.3, adding several important security and documentation patches. These changes address multiple CVEs, improving the security of template rendering, sandboxing, and profiling in Twig. The most important changes are grouped below:

Security Fixes:

  • Documented the dangers of using template_from_string() in sandboxed environments, warning that it can bypass sandbox policies and lead to untrusted code execution.
  • Documented resource exhaustion caveats in the sandbox, clarifying that Twig's sandbox does not protect against CPU, memory, or time exhaustion, and advising process-level containment for untrusted templates.
  • Fixed code injection vulnerabilities via template names in the use tag by escaping single quotes in compiled template names and improving error handling.
  • Ensured the spaceless filter pre-escapes HTML input, preventing XSS when the filter is used with untrusted input.
  • Escaped template and profile names in the HTML profiler output to prevent HTML injection and XSS in profiling tools.
  • Fixed sandbox includes with preloaded templates to ensure security checks are enforced even if templates are already loaded.

Patch Management:

  • Updated composer.json to include and reference all the above patches for twig/twig version 3.11.3.

@wordish wordish left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, assume these are all copy/paste from source without modification. The inversion of logic in 2026-46638 looked particularly scary if it was an accident.


// in a sandbox tag, only include tags are allowed
- if (!$body instanceof IncludeNode) {
+ if ($body instanceof IncludeNode) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Double check: really invert logic?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, as crazy as it looks that's part of the original commit

twigphp/Twig@1a023fe

@aembler
aembler merged commit 8b20a03 into master May 26, 2026
1 check passed
@mlocati
mlocati deleted the twig-patches branch August 21, 2026 07:35
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