-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
mime: bypassing multi-boundary check via Parameter Value Continuations #47602
Comments
cc @neild |
Is there some RFC or other authoritative source indicating that the current implementation is incorrect? RFC 2231 uses |
Yea, the following Content-Type is normal, and should be supported.
But how about the following Content-Type ? Which URL should be treated as the right one?
RFC 2231 doesn't indicate that which one is right, but Go will always get the second URL. |
Ah, I get you. The problem is that we aren't detecting duplicate parameter names when one is specified as an RFC 2231 continuation. (Sorry, I misread your initial example and misunderstood the issue.) |
We have two test cases for These test cases come from: RFC 5987 Section 4.2 states:
The test results from the greenbytes.de test cases indicate that most browsers pick the RFC 2231 encoded value. I think the current behavior is consistent with common practice in interpreting duplicated parameters. |
Yea, I totally agree with you. It's a trade-off between compatibility and security. This issue is more like a proposal instead of a bug. |
I got similar issue but with real-world email header, sample:
There's a proposal but closed without a fix: #28618 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/JLYLXf40j8y
What did you expect to see?
net/http
has a secure-by-default implement formultipart/form-data
that doesn't allow multi boundaries.go/src/mime/mediatype.go
Lines 188 to 191 in 507cc34
E.g., It will stop parsing the form with header
Content-Type: multipart/form-data;boundary="boundary";boundary="another-boundary"
.What did you see instead?
Due to the support of RFC 2231, we can bypass this security check with header
Content-Type: multipart/form-data;boundary="boundary";boundary*0="another";boundary*1="-boundary"
This incorrect implementation could be used for bypassing some security mechanisms, such as Web Application Firewall.
The text was updated successfully, but these errors were encountered: