Incorrect Authorization Affecting twig/twig package, versions <3.27.0


Severity

Recommended
0.0
low
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.42% (35th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Incorrect Authorization vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PHP-TWIGTWIG-17111518
  • published31 May 2026
  • disclosed27 May 2026
  • creditEl Kharoubi Iosif

Introduced: 27 May 2026

CVE-2026-48806  (opens in a new tab)
CWE-863  (opens in a new tab)

How to fix?

Upgrade twig/twig to version 3.27.0 or higher.

Overview

twig/twig is a flexible, fast, and secure template language for PHP.

Affected versions of this package are vulnerable to Incorrect Authorization via dynamic mapping key handling in ArrayExpression. An attacker can bypass the sandbox __toString() restrictions by using a stringable object as a dynamic mapping key, causing PHP to invoke __toString() during key coercion without calling SandboxExtension::ensureToStringAllowed(). This allows unauthorized access to data exposed through __toString() methods on objects reachable from the render context.

Note:

  1. Direct output of the same object remains blocked by the sandbox. The issue only occurs when the object is used as a dynamic mapping key.

  2. This vulnerability is a bypass of the fix for CVE-2026-47732.

CVSS Base Scores

version 4.0
version 3.1