CVE-2017-16790: Ensure that submitted data are uploaded files
November 17, 2017 • Published by Fabien Potencier
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.
Manage your notification preferences to receive an email as soon as a Symfony security release is published.
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
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.