-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Federation authenticated media endpoints have invalid multipart response #3414
Comments
This comment was originally posted by @CobaltCause at matrix-org/dendrite#3414 (comment). Seems like this is actually a bug in Go's standard library. It actually used to include a leading CRLF but was changed ~13 years ago as a workaround for a bug in a different program: https://codereview.appspot.com/4635063#msg4. |
This comment was originally posted by @S7evinK at matrix-org/dendrite#3414 (comment). This might be a problem in Ruma, the Spec wants RFC 2046 for the boundary. (Yea, the MSC linked to RFC 1341, which may had different "rules" for boundaries) The multipart package, which Dendrite uses, implements RFC 2046. |
This comment was originally posted by @Benjamin-L at matrix-org/dendrite#3414 (comment). @S7evinK Good catch! RFC 2046 seems to have similar text stating that boundaries must be preceded by a CRLF though. On page 19:
I haven't read the whole thing in detail, it's definitely possible that I'm missing something. It would be at least somewhat surprising this was a bug sitting in the go standard library for 13 years without anybody else noticing it. |
This comment was originally posted by @f0x52 at matrix-org/dendrite#3414 (comment). Coincidentally I read Go's |
This comment was originally posted by @f0x52 at matrix-org/dendrite#3414 (comment). on page 22 of RFC2046 the multipart body is specified as:
Which seems to me like the leading CRLF is only required when a preamble is present, which is optional |
This comment was originally posted by @Benjamin-L at matrix-org/dendrite#3414 (comment). Oh fun. I agree with your reading that the BNF clearly states the first CRLF is not required unless there is a preamble. That seems to conflict with the earlier text in the RFC to me, but either way the next step is to change ruma to be more permissive. |
This issue was originally created by @Benjamin-L at matrix-org/dendrite#3414.
Background information
0.13.7+7a4ef24
go version
: unknownb4fecbc51719a33d09be1e76d55ae0eec11fb71a
(over federation API)Description
The multipart spec states that every encapsulation boundary in the body should be preceded by a CRLF. Instead, dendrite's response to the federation auth media download endpoint has the
--
of the first boundary starting directly at the beginning of the body, with no CRLF.Ruma expects a preceding CRLF here when parsing the response. As a result, homeserver implementations using ruma are unable to fetch media from dendrite servers over the authed media endpoints. This affects grapevine, and likely also affects conduwuit although I have not tested it.
relevant text from RFC 1341
Steps to reproduce
/_matrix/federation/v1/media/download/:mediaid
request to a dendrite serverThe text was updated successfully, but these errors were encountered: