Skip to content

[5.x] Antlers hardening#14092

Draft
jasonvarga wants to merge 22 commits into5.xfrom
antlers-safer
Draft

[5.x] Antlers hardening#14092
jasonvarga wants to merge 22 commits into5.xfrom
antlers-safer

Conversation

@jasonvarga
Copy link
Member

This PR improves the safety net of Antlers by defaulting to a stricter subset of features.

When parsing user content, you'd get reduced features such as php syntax being disabled.
These have been tightened further, for example only a subset of tags and modifiers may be used.

This PR changes Antlers::parse() to assume it's user data by default. You may opt into the trusted mode with a boolean.

The behavior of actual Antlers templates/views do not change and get the full behavior they previously did. No need to opt into any additional tags or modifiers.

This also reverts the Antlers::parseUserContent() method added in #14058.


This PR is a small breaking change for the sake of security.
If you're using antlers in content fields, and you are using tags or modifiers, you will need to opt into them via the statamic.antlers.allowedContentTags and allowedContentModifiers.

'allowedContentTags' => ['some_tag:*'],
'allowedContentModifiers' => ['some_modifier'],

JohnathonKoster and others added 22 commits February 26, 2026 11:22
Remove the redundant isPhpEnabled global and make isEvaluatingUserData the single trust gate, while forcing parseView to render in trusted mode and preserving state boundaries in site config parsing.

Made-with: Cursor
Use a trusted parameter instead of php, carry it through parseLoop and endpoint facades, and ensure tag-rendered templates execute in trusted mode to preserve view-time behavior.

Made-with: Cursor
Default parser test helpers to trusted mode for legacy runtime expectations and mark method/PHP execution assertions as trusted where they verify developer-template behavior.

Made-with: Cursor
Derive trusted from the current user-content evaluation state instead of hardcoding trusted mode so nested tag parsing preserves caller safety context.

Made-with: Cursor
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