Optimistic HTTP upgrades need a rule for bytes sent before confirmation

Optimistic HTTP upgrades need a rule for bytes sent before confirmation

Optimistic HTTP upgrades need a rule for bytes sent before confirmation HTTP/1.1 can ask to change the protocol on an existing connection. A client that sends data before the server confirms the transition can create a parsing problem for intermediaries and for the application that eventually receives the bytes. RFC 9931 treats that timing as a security issue, especially when a third party controls the request data or the post-transition content. The new standard updates the HTTP/1.1 and UDP-proxying specifications. It discusses transitions such as WebSocket and connect-udp, where the client may begin a new protocol after an upgrade request. The document notes that when only the client and server are involved, each already has to handle arbitrary bytes from the other. The risk grows when a browser, proxy, origin, or third-party script contributes data and each party interprets a different boundary. The message boundary is the control A server should not accept post-transition bytes until it has emitted the required confirmation and established the new protocol state. A proxy that forwards bytes early may give an upstream service data that looks like a new request, a different frame, or part of a tunnel. One layer may parse a length field while another treats the same bytes as application content. The safest application policy is to wait for explicit confirmation unless a specification defines a safe optimistic behavior. For future upgrade tokens, RFC 9931 recommends restricting optimistic use to GET requests with no content when the method and body are otherwise irrelevant. Existing WebSocket and MASQUE implementations need their own tests for early data, fragmented headers, and a response that rejects the upgrade after bytes have arrived. Third-party content changes the risk An HTTP request can carry a path, headers, or body influenced by a different origin. A post-transition protocol can also carry messages chosen by a third party. The party that builds the outer request may have no way to know how the inner protocol will interpret every byte. This is a composition problem, not an argument for disabling all upgrades. Inventory every component that changes protocol: browser clients, API gateways, CDNs, reverse proxies, and service meshes. For each, record who sends first, who confirms, which parser owns the bytes, and where the connection is terminated. A proxy should reject conflicting Connection, Upgrade, or content-length signals and should not infer a successful transition from a route name. Add negative tests Send valid data before confirmation and verify that it is not delivered twice. Send a rejected upgrade followed by a complete HTTP request and confirm that the server does not interpret the request as tunnel payload. Test a large body, fragmented headers, HTTP/1.0 clients, and a third-party script that controls a URL parameter. The protocol transition is a security boundary because it changes the parser. The confirmation check belongs in the same place as the parser change. A documented timeout and close behavior is safer than an optimistic path that leaves two layers guessing. References [1] RFC 9931, Security Considerations for Optimistic Protocol Transitions in HTTP/1.1. https://www.rfc-editor.org/rfc/rfc9931.html [2] RFC 9112, HTTP/1.1. https://www.rfc-editor.org/rfc/rfc9112.html [3] RFC 9298, Proxying UDP in HTTP. https://www.rfc-editor.org/rfc/rfc9298.html

Original Source

Read the full article at Dev →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.