Symfony 4 was released on November 30th.
Update now to the best Symfony ever!

CVE-2017-16790: Ensure that submitted data are uploaded files

Affected versions

Symfony 2.7.0 to 2.7.37, 2.8.0 to 2.8.30, 3.2.0 to 3.2.13, and 3.3.0 to 3.3.12 versions of the Symfony Form component are affected by this security issue.

The issue has been fixed in Symfony 2.7.38, 2.8.31, 3.2.14, 3.3.13, 3.4-BETA5, and 4.0-BETA5.

Note that no fixes are provided for Symfony 3.0 and 3.1 as they are not maintained anymore.

Description

When a form is submitted by the user, the request handler classes of the Form component merge POST data (known as the $_POST array in plain PHP) and uploaded files data (known as the $_FILES array in plain PHP) into one array. This big array forms the data that are then bound to the form. At this stage there is no difference anymore between submitted POST data and uploaded files.

A user can send a crafted HTTP request where the value of a FileType is sent as normal POST data that could be interpreted as a locale file path on the server-side (for example, file:///etc/passwd). If the application did not perform any additional checks about the value submitted to the FileType, the contents of the given file on the server could have been exposed to the attacker.

Resolution

As part of the fix, a new isFileUpload() method was added to the RequestHandlerInterface. This method is called by the FileType to verify that the handled data is an uploaded file.

The patch for this issue is available here.

Credits

I would like to thank Ondrej Exner for reporting this security issue, Christian Flothmann for providing a fix, and the Symfony Core Team for reviewing the patch.

If you have found a security issue in Symfony, please send the details to security [at] symfony.com and don't disclose it publicly until we can provide a fix for it.

Comments

The patch link is incorrect, it sends me to "https://github.com/symfony/symfony/pull/24993%3E" instead of "https://github.com/symfony/symfony/pull/24993".
@Mitchell fixed! Thanks.
It would be important to also mention that this fix is a BC break for 2.7 and up because of the added method on the interface, as the commit also states: https://github.com/symfony/symfony/commit/f9e210cc7bbaa52adc2a6f695cc343854fa43df6

We for instance are making use of Sylius' ResourceBundle that implements the RequestHandlerInterface. Big plus for adding the method on the interface, but maybe there's a way to help the community with how to quickly solve this, or also somehow proactively notify them on security patches.
To clarify the vulnerability, the problem wasn't that the file contents could be exposed to the attacker. However based on the validation message from FileConstraint the attacker was able to determine whether the file exists on the server or not - potentially revealing what technologies are used on the server.
Login with SensioLabsConnect to post a comment