# CVE-2026-48805: Twig sandbox bypass in deprecated internal wrappers

Source: https://junglewise.ai/threats/cve-2026-48805-twig-sandbox-bypass-in-deprecated-internal-wrappers  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-14. Updated: 2026-07-14  
License: CC BY 4.0 with a link back

CVE-2026-48805 · Severity: low · CVSS 0 · Published 2026-07-14

Twig, a popular template engine for PHP, contains a security flaw in its sandbox mode. The sandbox is designed to safely run untrusted code, but certain outdated internal functions fail to check if they are running in this restricted environment. This could allow an attacker with the ability to provide templates to bypass security restrictions and execute unauthorized functions, potentially compromising the application's integrity.

Technologies: [twig/twig (Packagist)](https://junglewise.ai/threats/technologies/twig-twig). Vendors: [Packagist](https://junglewise.ai/threats/vendors/packagist).

## Quick answers

**Is CVE-2026-48805 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-48805 being exploited in the wild.

**How severe is CVE-2026-48805?** Low severity, with a CVSS score of 0, published 14 July 2026.

**Which products and versions are affected?** twig/twig (Packagist) <= 3.26.0, ECOSYSTEM:introduced=0,fixed=3.27.0.

**Is there a fix for CVE-2026-48805?** Yes. twig/twig (Packagist): upgrade to 3.27.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-48805 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-48805?** Check whether you run twig/twig (Packagist) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- twig/twig (Packagist): upgrade to 3.27.0 or later

  ```sh
  composer require twig/twig:^3.27.0
  ```


## Technical details

A vulnerability exists in Twig's deprecated internal wrappers within src/Resources/core.php. Following hardening changes in version 3.26.0, the signatures for CoreExtension::checkArrow(), arraySome(), and arrayEvery() were updated to require a boolean $isSandboxed flag. However, the legacy wrapper functions (twig_array_some, twig_array_every, and twig_check_arrow_in_sandbox) were not updated to forward this state. Consequently, these functions default to a non-sandboxed state, allowing attackers to bypass callable restrictions (such as the requirement that callables be Closures) and execute string-based callables like 'strcmp'. Additionally, twig_check_arrow_in_sandbox triggers a TypeError on PHP 8+ due to type mismatch. The issue is resolved in version 3.27.0 by ensuring these wrappers correctly resolve and forward the sandbox state.

## Affected products

- twigphp Twig < 3.27.0

## Identifiers

- CVE-2026-48805
- GHSA-p42q-9prx-q5wq

## Timeline

- 2026-05-27: patched: Version 3.27.0 released
- 2026-05-27: advisory: GitHub Security Advisory published
- 2026-07-14: disclosed: CVE published to NVD

## References

- [https://github.com/twigphp/Twig/commit/e235cae3a1d1e23edc24df4d675f18108c6b167b](https://github.com/twigphp/Twig/commit/e235cae3a1d1e23edc24df4d675f18108c6b167b)
- [https://github.com/twigphp/Twig/releases/tag/v3.27.0](https://github.com/twigphp/Twig/releases/tag/v3.27.0)
- [https://github.com/twigphp/Twig/security/advisories/GHSA-p42q-9prx-q5wq](https://github.com/twigphp/Twig/security/advisories/GHSA-p42q-9prx-q5wq)

## Related threats

- [Twig sandbox allow-list bypass via template cache reuse](https://junglewise.ai/threats/cve-2026-49981-twig-sandbox-allow-list-bypass-via-template-cache-reuse)
- [Twig sandbox bypass in column filter via SourcePolicyInterface](https://junglewise.ai/threats/cve-2026-48808-twig-sandbox-bypass-in-column-filter-via-sourcepolicyinterface)
- [Twig sandbox policy bypass via Traversable objects in filters and operators](https://junglewise.ai/threats/cve-2026-48807-twig-sandbox-policy-bypass-via-traversable-objects-in-filters-and)
- [Twig sandbox policy bypass via dynamic mapping keys](https://junglewise.ai/threats/cve-2026-48806-twig-sandbox-policy-bypass-via-dynamic-mapping-keys)
- [Twig sandbox policy bypass via unguarded string coercion](https://junglewise.ai/threats/cve-2026-47732-twig-sandbox-policy-bypass-via-unguarded-string-coercion)
