Описание
Erroneous parsing of multipart form data
Summary
Erroneous parsing of multipart form data contained in an HTTP POST request could lead to legitimate data not being processed thus, violating data integrity.
Details
A bug was discovered in the parsing of multipart form data contents, affecting both file and input form data. If a multipart form data payload contains a valid prefix X
of the defined boundary B
such that 5Kib
< |X|
< |B|
< 8Kib
, the logic responsible for parsing and storing the multipart payload fails to correctly extract the contents between two boundaries. This results in a violation of data integrity. The issue lies in the partial match handling in the following function:
This is called by the following functions when the contents between two boundaries have to be extracted after parsing the MIME headers:
PoC
The below python
payload was used in a PHP-FPM environment coupled with a Nginx server. No particular configuration was used to couple the services. Two payloads triggering the bug are presented below:
The above payloads illustrate that a prefix of the boundary is considered as a valid boundary and the processing of what is after this prefix stops.
The PHP script which can be use to illustrate the bug by writing the contents of the form into a file is the following:
To confirm that the 100 "C"s from the second payload are not included in the resulting file:
Impact
The parsing bug violates data integrity. In the context where an attacker is capable of inserting a maliciously crafted payload at a desired location alongside other legitimate user payloads and is under control of other request parts such as the boundary, they can exclude portions of the legitimate data.
Пакеты
< 8.1.30
8.1.30
< 8.2.24
8.2.24
< 8.3.12
8.3.12
Связанные уязвимости
In PHP versions 8.1.* before 8.1.30, 8.2.* before 8.2.24, 8.3.* before 8.3.12, erroneous parsing of multipart form data contained in an HTTP POST request could lead to legitimate data not being processed. This could lead to malicious attacker able to control part of the submitted data being able to exclude portion of other data, potentially leading to erroneous application behavior.
In PHP versions 8.1.* before 8.1.30, 8.2.* before 8.2.24, 8.3.* before 8.3.12, erroneous parsing of multipart form data contained in an HTTP POST request could lead to legitimate data not being processed. This could lead to malicious attacker able to control part of the submitted data being able to exclude portion of other data, potentially leading to erroneous application behavior.
In PHP versions 8.1.* before 8.1.30, 8.2.* before 8.2.24, 8.3.* before 8.3.12, erroneous parsing of multipart form data contained in an HTTP POST request could lead to legitimate data not being processed. This could lead to malicious attacker able to control part of the submitted data being able to exclude portion of other data, potentially leading to erroneous application behavior.
In PHP versions8.1.* before 8.1.30, 8.2.* before 8.2.24, 8.3.* before ...