a Sensio Labs Product

The flexible, fast, and secure
template language for PHP

Security Release: Twig 1.12.3 released

I’ve just released Twig 1.12.3 which contains a security vulnerability fix.

Description

Your application is affected if you are using Twig_Loader_Filesystem for loading Twig templates but only if you are using non-trusted template names (names provided by a end-user for instance).

When affected, it is possible to go up one directory for the paths configured in your loader.

For instance, if the filesystem loader is configured with /path/to/templates as a path to look for templates, you can force Twig to include a file stored in /path/to by prepending the path with /../ like in {% include "/../somefile_in_path_to" %}

Note that using anything else (like ../somefile, /../../somefile, or ../../somefile) won’t work and you will get a proper exception.

Affected Versions

All versions of Twig are affected.

How to Patch

If you cannot upgrade, you can apply the following patch:

https://github.com/fabpot/Twig/commit/3d19a2eed53570776af313593aaeb5ad62cf4980.diff

Credits

I want to thank Rick Prent who reported the issue and provided a fix for it.

Check your Project

As a quick remember, you can check your projects using Composer for vulnerability issues with the SensioLabs Security Checker.

This website is powered by PHP and Twig.