Skip to content

http: In alt-svc negotiation only allow supported HTTP versions #17037

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

Closed
wants to merge 1 commit into from

Conversation

nmeum
Copy link
Contributor

@nmeum nmeum commented Apr 12, 2025

Without this patch, the handling of the alt-svc header added via 279a477 (CC: @icing) in curl-8.13.0 attempts to connect to alternative services via different HTTP versions, even if the target HTTP version is not supported by curl (i.e., not enabled at compile-time). If I understand the code and RFC 7838 correctly, then we should only attempt to migrate to supported protocols. Therefore, allowed_apns should only contain such protocols, and we need to guard its modification with ifdefs for supported HTTP versions.

This was discovered in a downstream bug report in Alpine Linux where it was reported that a Matrix client (using libcurl) was defunct after the upgrade to curl-8.13.0. Further debugging revealed that this was due to the Matrix server sending a alt-svc: h3=":443"; HTTP header, causing curl to attempt migration to HTTP3 even though Alpine's curl version is compiled without HTTP3 support.

I am not sure if this is the best place in the code to address this or if the allowed bitmask shouldn't contain unsupported versions in the first place. However, since there are existing ifdefs in this function for source (not destination) ALP selection, it may be a good fit to address this here.

Applying this patch resolves the aforementioned downstream issue.

@testclutch
Copy link

Analysis of PR #17037 at d282060f:

Test 410 failed, which has NOT been flaky recently, so there could be a real issue in this PR.

Generated by Testclutch

Without this patch, the handling of the alt-svc header added via
279a477 in curl-8.13.0 attempts to
connect to alternative services via different HTTP versions, even if the
target HTTP version is not supported by curl (i.e., not enabled at
compile-time). If I understand the code and RFC 7838 correctly, then we
should only attempt to migrate to supported protocols. Therefore,
`allowed_apns` should only contain such protocols, and we need to guard
its modification with `ifdefs` for supported HTTP versions.

This was discovered in a downstream bug report in Alpine Linux [1] where
it was reported that a Matrix client (using libcurl) was defunct after
the upgrade to curl-8.13.0. Further debugging revealed that this was due
to the Matrix server sending a `alt-svc: h3=":443";` HTTP header,
causing curl to attempt migration to HTTP3 even though Alpine's curl
version is compiled without HTTP3 support.

I am not sure if this is the best place in the code to address this
or if the `allowed` bitmask shouldn't contain unsupported versions
in the first place. However, since there are existing `ifdefs` in
this function for source (not destination) ALP selection, it may
be a good fit to address this here.

[1]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/17062
@bagder bagder added the HTTP label Apr 15, 2025
Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes perfect sense to me!

@bagder bagder requested a review from icing April 15, 2025 15:42
Copy link
Contributor

@icing icing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix will work. As you said, the "allowed" mask should not contain values unsupported in the libcurl build. That needs fixing in http.c:189. Since this is a bit hairy, using this PR as a stopgap is fine,

@bagder bagder closed this in fbdb1e1 Apr 15, 2025
@bagder
Copy link
Member

bagder commented Apr 15, 2025

Thanks!

algitbot pushed a commit to alpinelinux/aports that referenced this pull request Apr 16, 2025
bell-sw pushed a commit to bell-sw/alpaquita-aports that referenced this pull request Apr 17, 2025
[ commit c9a9f0c0dc24618d718f6b9c0233da278213c12a ]

See curl/curl#17037

Fixes #17062
nbaws pushed a commit to nbaws/curl that referenced this pull request Apr 26, 2025
Without this patch, the handling of the alt-svc header added via
279a477 in curl-8.13.0 attempts to
connect to alternative services via different HTTP versions, even if the
target HTTP version is not supported by curl (i.e., not enabled at
compile-time). If I understand the code and RFC 7838 correctly, then we
should only attempt to migrate to supported protocols. Therefore,
`allowed_apns` should only contain such protocols, and we need to guard
its modification with `ifdefs` for supported HTTP versions.

This was discovered in a downstream bug report in Alpine Linux [1] where
it was reported that a Matrix client (using libcurl) was defunct after
the upgrade to curl-8.13.0. Further debugging revealed that this was due
to the Matrix server sending a `alt-svc: h3=":443";` HTTP header,
causing curl to attempt migration to HTTP3 even though Alpine's curl
version is compiled without HTTP3 support.

I am not sure if this is the best place in the code to address this
or if the `allowed` bitmask shouldn't contain unsupported versions
in the first place. However, since there are existing `ifdefs` in
this function for source (not destination) ALP selection, it may
be a good fit to address this here.

[1]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/17062

Closes curl#17037
nbaws pushed a commit to nbaws/curl that referenced this pull request Apr 26, 2025
Without this patch, the handling of the alt-svc header added via
279a477 in curl-8.13.0 attempts to
connect to alternative services via different HTTP versions, even if the
target HTTP version is not supported by curl (i.e., not enabled at
compile-time). If I understand the code and RFC 7838 correctly, then we
should only attempt to migrate to supported protocols. Therefore,
`allowed_apns` should only contain such protocols, and we need to guard
its modification with `ifdefs` for supported HTTP versions.

This was discovered in a downstream bug report in Alpine Linux [1] where
it was reported that a Matrix client (using libcurl) was defunct after
the upgrade to curl-8.13.0. Further debugging revealed that this was due
to the Matrix server sending a `alt-svc: h3=":443";` HTTP header,
causing curl to attempt migration to HTTP3 even though Alpine's curl
version is compiled without HTTP3 support.

I am not sure if this is the best place in the code to address this
or if the `allowed` bitmask shouldn't contain unsupported versions
in the first place. However, since there are existing `ifdefs` in
this function for source (not destination) ALP selection, it may
be a good fit to address this here.

[1]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/17062

Closes curl#17037
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

4 participants