/

CVE-2026-48808

Severity:

HIGH RISK

(7.5)

Sandbox Bypass (CWE-693) via Twig Column Filter Policy

CVE-2026-48808

Analyzed

Vulnerability type

Category:

Sandbox Policy Enforcement Failure

CWE:

CWE-693, CWE-863

Impact:

Sandbox Escape and Unauthorized Data Access

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Twig's sandbox mode can be bypassed when using the column filter because it fails to forward the current template Source to the sandbox policy checks.

Under certain configurations, a template author may read public or magic object properties that should be blocked by the sandbox, weakening isolation between untrusted templates and application internals.

Affected context

This vulnerability appears in PHP applications that embed Twig templates with sandbox mode enabled and use the column filter on objects or arrays of objects.

It is most relevant in environments where template authors are partially untrusted or where templates are treated as less-privileged code compared to the host application.

The issue surfaces when sandbox policies rely on Source-aware decisions via SourcePolicyInterface, but the column filter only passes a boolean and omits the current Source, causing policy checks to be evaluated without full context.

Exploit preconditions

  • Attack surface: Template execution paths that use Twig with sandbox mode and the column filter.
  • Required access: Ability to author or modify Twig templates, such as in CMS, multi-tenant, or user-customizable templating scenarios.
  • Trigger point: Rendering a template that calls the column filter on objects whose properties are expected to be restricted by sandbox policy.
  • Why exploitation is possible: The sandbox extension receives an incomplete policy context (no Source object), causing SandboxExtension::checkPropertyAllowed() to ignore Source-specific rules and allow reading of properties that should be denied.

Why this happens

The underlying problem is a mismatch between the sandbox policy contract and how the column filter invokes sandbox checks.

Sandbox enforcement depends on SourcePolicyInterface to decide if a property access is allowed, requiring both the active sandbox state and the current Source.

The column filter passes only a boolean flag rather than the full Source object into SandboxExtension::checkPropertyAllowed(), degrading the policy evaluation.

This is a classic CWE-693: Protection Mechanism Failure, where a security control (sandbox) is implemented but not correctly wired into all code paths, allowing restricted data access.

Potential impact

  • A template author may read public properties that were intended to be blocked by sandbox rules.
  • A template author could access magic properties exposing internal state or configuration details.
  • Sensitive application data may be disclosed via templates that should have limited visibility.
  • Defense-in-depth provided by sandboxing can be weakened, increasing the blast radius of template misuse.

General mitigation guidance

Mitigation generally focuses on ensuring sandbox policies are consistently applied and context-complete across all template operations.

Patterns that help reduce risk include:

  • Auditing template helpers and filters to confirm they pass full policy context (including Source) into sandbox checks.
  • Designing sandbox rules so they fail closed when context is missing or ambiguous.
  • Limiting the set of objects and properties exposed to untrusted templates by default and using explicit whitelists.
  • Treating template authors as potentially untrusted and assigning them least-privilege access to the data model surfaced in templates.

How teams detect issues like this

Detection usually involves:

  • Static analysis and code review of custom Twig extensions, filters, and functions to verify that sandbox-aware APIs are invoked with complete context.
  • Searching for calls to SandboxExtension::checkPropertyAllowed() (or equivalent checks) that omit Source information or rely solely on boolean flags.
  • Implementing security-focused test cases where untrusted templates attempt to read prohibited properties, validating that sandbox rules are enforced.
  • Integrating automated review tools or CI policies that flag changes in sandbox-related code paths and template-access surfaces.

Sources

SourceLink
github.comgithub.com/twigphp/Twig/commit/09c6706407ed7b1cb2d7d1408004f811e47e0424
github.comgithub.com/twigphp/Twig/releases/tag/v3.27.0
github.comgithub.com/twigphp/Twig/security/advisories/GHSA-h8vq-8gpg-mhcg

Frequently asked

questions

Exploitability depends on whether untrusted or semi-trusted users can create or edit Twig templates. In tightly controlled deployments where only trusted developers author templates, the practical risk is reduced.

An attacker needs the ability to influence Twig templates, typically through a CMS template editor, multi-tenant customization features, or any mechanism where user-supplied templates are executed under sandbox mode.

Ensure all sandbox interactions pass complete context to policy checks, including the current Source, and verify that template helpers and filters cannot bypass policy logic. As a general pattern, sandbox enforcement should be centralized and consistently applied to every property and method access.

Treat sandboxing and access control as first-class design concerns: define clear data exposure boundaries, use least-privilege models for template-visible objects, and enforce automated checks in CI to verify that all extension points (filters, functions, tags) honor sandbox policies with full context.

Find out what's already
exploitable in your codebase.