Skip to content
Putting technology to work.
Insights to guide decisions and action.

Search articles

11 Twig advisories: no fix for Twig 2.x used by EC-CUBE 4.2

Table of contents · 7 items

If your EC-CUBE site lets staff edit product free areas or page meta tags from the admin panel, whatever is written there is rendered as a Twig template. EC-CUBE uses a "sandbox" for this rendering and restricts the usable tags, filters and methods with allowlists. Twig shipped fixes, centered on issues that let templates bypass these sandbox allowlists, in 3.31.0 on November 23 and 3.31.1 on November 24, and published 11 advisories on the 24th.

However, EC-CUBE 4.2.x uses Twig 2.x. The last 2.x release was 2.16.1 in September 2024, and the description of the 2.x branch in the Twig repository says "Twig version 2 is not maintained anymore." No fixes have been released for it this time either. Of the nine advisories for Twig itself, five also affect 2.x, and the advisory database records the fixed version for 2.x as "none."

In this article, we use Twig's changelog, fix commits and advisories, along with the configuration in the EC-CUBE repository, to sort out what to do on each release line. For the join filter issue, one of the 11, we built a sandbox shaped like EC-CUBE's in a test environment and ran it on old and new Twig versions to confirm the behavior.

Where EC-CUBE uses the sandbox

In the EC-CUBE repository, 4.2.3-p2, 4.3.1-p1 and the in-development 4.4 all render values entered in the admin panel as templates in the following two places.

  • Product details (Product/detail.twig): {{ include(template_from_string(Product.freearea), sandboxed = true) }}
  • Frame for all pages (default_frame.twig): {{ include(template_from_string(Page.meta_tags), sandboxed = true) }}

The sandbox settings are in app/config/eccube/packages/twig_extensions.yaml. The sandbox is disabled globally (the second argument of SandboxExtension is false) and is enabled only in the two places above. It allows 16 tags, including embed, extends, for, if and set, and filters such as join, json_encode and merge. Only two methods are allowed: getRequest on AppVariable and getUri on Request. In 4.2.3-p2 and 4.3.1-p1, no properties are allowed at all (allowed_properties: []). The in-development 4.4 branch allows only three: name and main_list_image on Product, and shop_name on BaseInfo.

In other words, EC-CUBE's sandbox assumes that content written in a free area cannot read the contents of any object other than what is allowed. The join issue this time affects that assumption.

The 11 advisories of November 23 and 24, and Twig 2.x

According to Twig's changelog, of the fixes in 3.31.0 (November 23) and 3.31.1 (November 24), nine became advisories for the core (twig/twig) and one each for the twig/html-extra and twig/markdown-extra extensions. All 11 advisories were published on November 24 in Twig's GitHub repository and on the symfony.com blog. The severity in the table is the value from the GitHub advisory (the CVSS v4 score is in parentheses). The affected versions and the "2.x" column come from the records in the FriendsOfPHP advisory database (the source of the Packagist data that composer audit references).

AdvisoryIssue (summary of the advisory title)SeverityAffected 3.x versions2.x
CVE-2026-133768In the sandbox, join outputs properties of non-iterable objectsModerate (5.3)Below 3.31.1Affected, no fix
CVE-2026-133767A dynamic embed parent expression skips the allowlist and __toString() checksModerate (5.3)Below 3.31.1Affected, no fix
CVE-2026-133770A sandboxed template rewrites contents through the Markup constructorLow (2.1)Below 3.31.1Affected, no fix
CVE-2026-133764Input to custom tests skips the __toString() checkLow (2.3)Below 3.31.1Affected, no fix
CVE-2026-133771A variable with the same name as a macro import alias in another scope is not escapedLow (2.3)Below 3.31.0Affected, no fix
CVE-2026-133763, 133765 and 133766 (3 issues)is true, assignment and destructuring assignment, and spread arguments skip the __toString() checkModerate (5.3) / Moderate (5.3) / Low (2.3)3.21.0 / 3.23.0 / 3.28.0 or later, below 3.31.1None
CVE-2026-133772Branches of guard tags that are not selected skip the tag allowlistLow (2.3)3.15.0 or later, below 3.31.0None
CVE-2026-133769(html-extra)html_cva() values skip the property allowlistLow (2.3)3.12.0 or later, below 3.31.1None
CVE-2026-133773(markdown-extra)html_to_markdown keeps converters in memory without limitLow (2.3)Below 3.31.1Affected, no fix

The "2.x" column in the advisory data shows that the time for the 2.x line is empty (~), meaning there is no fixed release. The last commit on the 2.x branch of the Twig repository is also "Prepare the 2.16.1 release" on September 9, 2024, and as mentioned earlier, the branch is clearly marked as no longer maintained. As of November 30, no fix for 2.x has been released.

In the GitHub advisories as well, the six issues marked as affecting 2.x in the table (the five in Twig itself and one in markdown-extra) list the affected versions without a lower bound, such as "below 3.31.1" or "below 3.31.0," so 2.x is included. As of November 30, none of the 11 are listed in the GitHub Advisory Database (GitHub's vulnerability database). They do appear, via the FriendsOfPHP data, in the Packagist advisory data that composer audit references.

EC-CUBE does not install twig/html-extra or twig/markdown-extra (confirmed in the repository's composer.lock), so these two issues do not affect EC-CUBE's standard setup. CVE-2026-133771 is unrelated to the sandbox and depends on how templates that use macros are written.

EC-CUBE also allows the embed tag. According to the CVE-2026-133767 advisory, when the parent of embed was written as an expression other than a string or variable, the functions, filters and tests in that expression, as well as string conversion, bypassed the sandbox checks. This means functions and filters that were not allowed could also be called. Method calls and property reads are said to be out of scope because they are checked at runtime. This issue also affects 2.x, and there is no fixed release.

Checking the join issue in a test environment

For the join issue, the fix commit makes the cause clear. When join received a non-array value, it converted it to an array with (array) $value. In PHP, converting an object with (array) extracts the values of not only public properties but also protected and private ones. In 3.31.1, non-array values are now treated as a single element. The same code in Twig 2.16.1 still uses (array) $value.

So we built a sandbox shaped like EC-CUBE's (disabled globally, rendered with include(template_from_string(...), sandboxed = true), join among the allowed filters, no allowed properties) and tested it by passing in a fictitious object. On PHP 8.3.6, we compared Twig 2.15.4 (the version in EC-CUBE 4.2.3-p2's composer.lock), 2.16.1, 3.30.0 and 3.31.1.

twig 2.15.4 / PHP 8.3.6
  [allowed method] OK: "Sample"
  [property (not allowed)] SecurityNotAllowedPropertyError: Calling "sku" property on a "Product" object is not allowed ...
  [join on object] OK: "Sample,A-1,7,1200"
twig 3.30.0 / PHP 8.3.6
  [property (not allowed)] SecurityNotAllowedPropertyError: ...
  [join on object] OK: "Sample,A-1,7,1200"
twig 3.31.1 / PHP 8.3.6
  [property (not allowed)] SecurityNotAllowedPropertyError: ...
  [join on object] RuntimeError: ... ("Object of class Product could not be converted to string") ...

Results of rendering {{ Product|join(",") }} in a sandbox shaped like EC-CUBE's, by Twig version. In Twig 2.15.4, 2.16.1 and 3.30.0, the values of disallowed properties (including protected and private ones) were output. In 3.31.1, rendering stopped with an error. When join was removed from the allowed filters, even 2.15.4 stopped with an error saying the filter is not allowed

Reading a property directly, as in Product.sku, is blocked by the allowlist in every version. But when written as Product|join(","), 2.15.4 through 3.30.0 output the values of all disallowed properties (2.16.1 gave the same result). This included the protected 7 and the private 1200. In 3.31.1, rendering stops with an error and no values are output.

What we checked is the behavior of Twig on its own. What can actually be read from a free area on a real EC-CUBE screen depends on the contents of the objects passed to the template. We have not checked this by running EC-CUBE itself.

What to do for each EC-CUBE release line (editorial suggestion)

According to the repository's composer.json and composer.lock, the Twig version for each release line is as follows.

  • 4.3.x (4.3.1-p1): "twig/twig": "^3.8", and composer.lock is 3.8.0. This is within the constraint, so you can upgrade to 3.31.1 with composer update twig/twig. Twig 3.31.1 requires PHP 8.1 or later, and 4.3.x is also "php": "^8.1". Because the gap from 3.8.0 to 3.31.1 is large, check the admin panel and storefront display in staging before applying it to production
  • 4.2.x (4.2.3-p2): "twig/twig": "^2.15", and composer.lock is 2.15.4. It cannot be upgraded to Twig 3.x, and there is no fixed release for 2.x. The fundamental fix is migrating to 4.3.x
  • 4.4.x (in development): "twig/twig": "^3.21", and composer.lock is 3.30.0. On November 29, an automated dependency update PR (Dependabot, #7316) to upgrade Twig to 3.31.1 was opened, but as of November 30 it has not been merged

The composer.lock versions are the versions pinned in the repository. On live sites, the version differs if someone ran composer update during development or maintenance. Check the site's actual version on the server.

As of November 30, the vulnerability list on the official EC-CUBE website does not include the Twig issues (the latest entry is the MFA issue from March 4, 2026). As of November 30, the repository also has no releases or commits that upgrade Twig for 4.2.x or 4.3.x.

While staying on 4.2.x and waiting to migrate, we confirmed in a test environment that, for the join issue alone among the five in Twig itself, removing join from the allowlist stops it (Twig 2.15.4 raises a Filter "join" is not allowed error). In EC-CUBE, this means overriding the eccube.twig_sandbox.allowed_filters parameter. However, if any products or pages use join in their free areas or meta tags, those parts will no longer be displayed. EC-CUBE's IgnoreTwigSandboxErrorExtension (4.2.3-p2 and 4.3.1-p1) shows sandbox permission errors on screen only when APP_ENV is dev; otherwise it writes a warning to the log and displays nothing (this is based on reading the code; we have not confirmed the behavior in EC-CUBE). For the remaining four issues (embed, Markup, custom tests and macro aliases), we have not confirmed whether adjusting the allowlist stops them.

The other measure is to limit who can enter content. These issues start from templates written inside the sandbox. Review the accounts with permission to edit products or manage pages, and check that no external operations staff accounts or shared accounts are left behind.

Symfony's November 25 fixes, which affect EC-CUBE, are covered in our article on Symfony's November fixes. EC-CUBE 4.2.x uses Symfony 5.4 and 4.3.x uses 6.4; checking either together with this Twig update reduces the number of update rounds.

For Craft CMS

Craft CMS also uses the Twig sandbox. The Craft CMS changelog says that 5.12.3 (November 24) upgraded Twig to 3.31.1 and fixed the Markup issue as a "low-severity" vulnerability. For 4.x, the composer.json on the repository's 4.x branch pins twig/twig to ~3.19.0, and as of November 30 the changelog has no entry for a Twig update.

Steps to check

  1. Check the Twig version. Run the following in the site directory. If it is 2.x or earlier than 3.31.1, the site is affected
composer show twig/twig | grep -E '^versions'
composer audit --locked   # Packagistの勧告のデータに載った件が出る
grep -n "VERSION =" src/Eccube/Common/Constant.php   # EC-CUBEの版
  1. Check the sandbox allowlist. In app/config/eccube/packages/twig_extensions.yaml (or the settings that override it), see whether join and embed are allowed
  2. List the syntax used in free areas and meta tags. Before narrowing the allowlist, check whether any content in dtb_product.free_area and dtb_page.meta_tags in the database uses join or embed
  3. Update 4.3.x, and plan a migration for 4.2.x. For 4.3.x, try composer update twig/twig in staging. For 4.2.x, get by for now by reviewing the allowlist and permissions, and decide when to migrate to 4.3.x

For a comparison of whether to keep EC-CUBE as your e-commerce platform or move to another one, see our comparison of options for building an e-commerce site.

Scope of verification

On November 27, 2026, we reviewed the twigphp/Twig repository (tags v3.31.1, v3.31.0 and v2.16.1, and the 2.x branch), including the CHANGELOG, the diffs and tests of the fix commits, and doc/filters/join.rst; the advisory files for twig/twig, twig/html-extra and twig/markdown-extra in FriendsOfPHP/security-advisories; the Packagist advisory API and publication timestamps; the EC-CUBE/ec-cube repository (tags 4.3.1-p1 and 4.2.3-p2, and the 4.4 branch), including composer.json, composer.lock, twig_extensions.yaml and templates; and the 5.x and 4.x CHANGELOGs of craftcms/cms (document research). On November 30, we rechecked the 11 advisories in the twigphp/Twig repository (publication dates and severity), whether they are listed in the GitHub Advisory Database, the advisory pages on symfony.com, the README of the 2.x branch, the vulnerability list on the official EC-CUBE website and the latest state of its repository, and the latest versions on Packagist. For the join issue, we built a sandbox shaped like EC-CUBE's and tested it with PHP 8.3.6 and Twig 2.15.4, 2.16.1, 3.30.0 and 3.31.1 (hands-on testing with fictitious data). We have not confirmed the behavior in EC-CUBE itself or reproduced the other 10 issues.

For maintenance of e-commerce sites built with EC-CUBE or how to approach version upgrades, contact us through Development, AI and automation consultation. Because the steps vary with each site's setup, we take consultations individually.

References

Share this articleXFacebook
Kakeru Suzuki

Fascinated by the possibilities of technology, has had a deep interest in programming and digital art since student days

Turn this article's theme into your company's next step

Starting from what you want to achieve with your website.

We organize user goals, required features, and ongoing maintenance structures to determine the first steps in development and improvement.

  • Website objectives
  • Features and usability
  • Post-launch operations
Consult on web development and improvements

You can consult with us from the initial conceptual stage. Details from this article will be carried over to the inquiry form.

Receive the latest articles via email · Read the web production guide
Free download

Complete Guide to Web Production: Costs, Vendor Selection & Traffic Acquisition [2026 Edition]

We have compiled cost benchmarks, vendor selection criteria, and traffic acquisition strategies into a PDF.

The PDF and newsletter emails are currently in Japanese.

You will also be subscribed to our newsletter. You can unsubscribe at any time.