Editing body in Request Editor causes issues with CR/LF feeds
Describe the bug
When editing the Content-Type header of a section within the multipart/form-data of a request in the Request Editor the CR of the CR/LF line terminator is removed. Specifically, this happens when the existing Content-Type value is highlighted and overtyped. It does not seem occur when the text is inserted prior to the existing value and then the existing value deleted.
Steps to reproduce the behavior
For example, this occurs when following the Portswigger lab at Web shell upload via Content-Type restriction bypass (https://portswigger.net/web-security/file-upload/lab-file-upload-web-shell-upload-via-content-type-restriction-bypass). Open a previous upload POST request in the Request Editor. Check it works by sending it and note the response. Then edit a section of the multipart data below, the user highlights the "application/x-php" text and overtype it with a different type and then resend the request. The request is sent but the server declares there is a missing parameter rather than the original response. Re-editing the request back to the original Content-Type by highlighting the new Content-Type and overtyping with "application/x-php" and resending also results in this error rather than the original response, even though the request now appears identical to the original.
------WebKitFormBoundaryo14bscS1BjqKlwdo Content-Disposition: form-data; name="avatar"; filename="Web shell upload via Content-Type restriction bypass - exploit.php" Content-Type: application/x-php
By adding an extra character after the edited Content-Type value and then switching to Hex view and changing this extra character to "0d" and sending the request causes everything to work as expected.
Expected behavior
When highlighting\editing text in the Request Editor the existing CR\LF line terminators should not be affected.
Software versions
Only tested on 2.13.0
Screenshots
No response
Errors from the zap.log file
No response
Additional context
No response
Would you like to help fix this issue?
- Yes
Source: zaproxy/zaproxy