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

http3: reject header field that contain non-lowercase characters #3964

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions http3/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package http3

import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
Expand All @@ -15,6 +16,10 @@ func requestFromHeaders(headers []qpack.HeaderField) (*http.Request, error) {

httpHeaders := http.Header{}
for _, h := range headers {
// field names need to be lowercase, see section 4.2 of RFC 9114
if strings.ToLower(h.Name) != h.Name {
return nil, fmt.Errorf("header field is not lower-case: %s", h.Name)
}
switch h.Name {
case ":path":
path = h.Value
Expand Down
11 changes: 11 additions & 0 deletions http3/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ var _ = Describe("Request", func() {
Expect(req.RequestURI).To(Equal("/foo"))
})

It("rejects upper-case fields", func() {
headers := []qpack.HeaderField{
{Name: ":path", Value: "/foo"},
{Name: ":authority", Value: "quic.clemente.io"},
{Name: ":method", Value: "GET"},
{Name: "Content-Length", Value: "42"},
}
_, err := requestFromHeaders(headers)
Expect(err).To(MatchError("header field is not lower-case: Content-Length"))
})

It("parses path with leading double slashes", func() {
headers := []qpack.HeaderField{
{Name: ":path", Value: "//foo"},
Expand Down
Loading