highVulnerability

CVE-2026-49981

### Description The per-template filter, tag and function allow-list check is compiled into the `checkSecurity()` method of each `Template` subclass and was invoked once from the constructor, gated by `SandboxExtension::isSandboxed($source)`. `Template` instances are then cached on the `Environment` in `$loadedTemplates`, so the verdict computed at construction time was sticky for the rest of the process. Any later change of sandbox state on the same `Environment` left that cached verdict in place: toggling `SandboxExtension::enableSandbox()`/`disableSandbox()`, swapping the policy via `setSecurityPolicy()`, a `SourcePolicyInterface` decision flip, or simply having a parent, macro or included template pre-instantiated outside the sandbox before a sandboxed render reached it. In all of these cases, the filters, tags and functions used by the affected template kept running with the original (typically empty) check, bypassing the `SecurityPolicy` allow-list. Method, property and `__toString` allow-lists are not affected: they are enforced at every call site at runtime through `SandboxExtension::checkMethodAllowed()`, `checkPropertyAllowed()` and `ensureToStringAllowed()`, which re-read the current state on every call. Long-lived workers (FrankenPHP, RoadRunner, Symfony Messenger consumers, FPM with hot autoloading) that share a single `Environment` between sandboxed and non-sandboxed renders are the most exposed: a single non-sandboxed render of a shared layout pre-warms its `Template` instance, after which any later sandboxed render that extends, uses, includes or imports from that layout silently skips the filter/tag/function allow-list for the pre-warmed instance. ### Resolution The allow-list check is no longer run from the constructor. `Template` gains a public `ensureSecurityChecked()` method that calls the compiled `checkSecurity()` only when `SandboxExtension::isSandboxed($source)` returns true for the current source, and it is invoked at every entry poin

Properties

ghsa_id
GHSA-529h-vh3j-85hq
summary
Twig: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders for a cached `Template`
severity
high
epss_score
0.00212
cve_id
CVE-2026-49981
is_ghsa_only
false
ghsa_published
2026-07-01T18:55:49Z
source_url
https://github.com/advisories/GHSA-529h-vh3j-85hq
epss_percentile
0.11799
ghsa_updated
2026-07-01T18:55:50Z

Related Entities (6)

ENRICHED_BY (1)

[Source]FIRST EPSS

AFFECTS (1)

[Software]composer/twig/twig

HAS_WEAKNESS (2)

[Weakness]Protection Mechanism Failure
[Weakness]Incorrect Authorization

REPORTED_BY (1)

[Source]GitHub Advisory Database

VULNERABLE_TO (1)

[Software]composer/twig/twig

Explore deeper with Ninja Signal's threat intelligence graph

CVE-2026-49981 — Ninja Signal Threat Intelligence | Ninja Signal