Skip to content

Conversation

@brandonkelly
Copy link
Member

Adds a new enableTwigSandbox config setting, which when enabled, configures Twig with the Sandbox extension with a custom security policy that doesn’t block any tags, filers, methods, or properties. However by simply being enabled, Twig will block all non-Closure arrow functions, fixing several security issues.

{# no longer works #}
{% set names = names|map('ucfirst') %}

{# do this instead #}
{% set names = names|map(n => n|capitalize) %}

The config setting is false by default in core, but will be enabled by default for new craftcms/craft-based projects.

Support for calling non-Closure arrow functions is deprecated and will be removed in a future version of Twig, so updating templates and enabling the setting should be encouraged.

@brandonkelly brandonkelly changed the title Feature/disallow string arrows Disallow non-Closure arrow functions Jan 2, 2026
@brandonkelly brandonkelly merged commit 4ab0179 into 4.17 Jan 2, 2026
15 checks passed
@brandonkelly brandonkelly deleted the feature/disallow-string-arrows branch January 2, 2026 22:50
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