Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: do not decode multipart form parts containing Content-Transfer-Encoding headers #63855

Open
neild opened this issue Oct 31, 2023 · 4 comments
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done.

Comments

@neild
Copy link
Contributor

neild commented Oct 31, 2023

A multipart/form-data form consists of a series of parts, separated by a boundary. As originally specified in RFC 2388, each part may contain a Content-Transfer-Encoding header as defined in RFC 2045 Section 6.

RFC 7578, Section 4.7, which updates and obsoletes RFC 2388, deprecates the use of Content-Transfer-Encoding in contexts which support binary data, specifically including HTTP.

http.Request.ParseMultipartForm will parse form parts containing a Content-Transfer-Encoding header. To use an example from RFC 7578, ParseMultipartForm will parse this form part as containing the body "Joe owes €100.":

--AaB03x
content-disposition: form-data; name="field1"
content-type: text/plain;charset=UTF-8
content-transfer-encoding: quoted-printable

Joe owes =E2=82=AC100.
--AaB03x

This can act as a content smuggling vector, since other implementations generally do not decode quoted-printable form parts in HTTP multipart/form-data responses. As a hardening measure, we should consider not decoding encoded parts in ParseMultipartForm. RFC 7578 indicates that implementations that send such bodies are uncommon to nonexistent.

@neild neild self-assigned this Oct 31, 2023
@neild
Copy link
Contributor Author

neild commented Nov 1, 2023

Addendum:

Thanks to Qi Wang and Jianjun Chen for reporting this issue.

@gopherbot
Copy link

Change https://go.dev/cl/573195 mentions this issue: mime/multipart: add Reader.SetRejectContentTransferEncoding

@gopherbot
Copy link

Change https://go.dev/cl/573196 mentions this issue: net/http: reject multipart requests containing a "Content-Transfer-Encoding" header

@ianlancetaylor
Copy link
Contributor

See also #66434.

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants