Skip to content

Configurable allowlist-based Twig sandbox#18216

Merged
brandonkelly merged 1 commit into
4.17from
feature/twig-sandbox
Jan 6, 2026
Merged

Configurable allowlist-based Twig sandbox#18216
brandonkelly merged 1 commit into
4.17from
feature/twig-sandbox

Conversation

@brandonkelly

Copy link
Copy Markdown
Member

Adds three new View methods:

  • renderSandboxedTemplate()
  • renderSandboxedString()
  • renderSandboxedObjectTemplate()

Twig’s Sandbox extension is now enabled when both:

The Sandbox extension is now configured with a security policy that prevents tags, filters, functions, methods, and properties, based on built-in allowlist. Additional things can be added to the allowlist via config/twig-sandbox.php, which will be merged into the default array (recursively).

Only system message templates are currently rendered as sandboxed. Any plugins that have user-editable templates are recommended to use these new methods as well.

@brandonkelly brandonkelly changed the title Configurable allowlist-based Twig sandbox + View::renderSandboxed*() Configurable allowlist-based Twig sandbox Jan 6, 2026
@brandonkelly brandonkelly merged commit 1fb4dea into 4.17 Jan 6, 2026
15 checks passed
@brandonkelly brandonkelly deleted the feature/twig-sandbox branch January 6, 2026 22:17
brandonkelly added a commit that referenced this pull request Jan 6, 2026
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