VDB
Sign up
HIGH8.5

GHSA-6j75-5wfj-gh66

Twig has a possible sandbox bypass

Quick fix

GHSA-6j75-5wfj-gh66 — twig/twig: upgrade to the fixed version with the command below.

composer require twig/twig:^1.44.8

Details

### Description

Under some circumstances, the sandbox security checks are not run which allows user-contributed templates to bypass the sandbox restrictions.

The security issue happens when all these conditions are met:

* The sandbox is disabled globally; * The sandbox is enabled via a sandboxed `include()` function which references a template name (like `included.twig`) and not a `Template` or `TemplateWrapper` instance; * The included template has been loaded before the `include()` call but in a non-sandbox context (possible as the sandbox has been globally disabled).

### Resolution

The patch ensures that the sandbox security checks are always run at runtime.

### Credits

We would like to thank Fabien Potencier for reporting and fixing the issue.

Are you affected?

Enter the version of the package you're using.

Affected packages

Packagist/twig/twig
Introduced in: 1.0.0Fixed in: 1.44.8
Fixcomposer require twig/twig:^1.44.8
Packagist/twig/twig
Introduced in: 2.0.0Fixed in: 2.16.1
Fixcomposer require twig/twig:^2.16.1
Packagist/twig/twig
Introduced in: 3.12.0Fixed in: 3.14.0
Fixcomposer require twig/twig:^3.14.0
Packagist/twig/twig
Introduced in: 3.0.0Fixed in: 3.11.1
Fixcomposer require twig/twig:^3.11.1

References