http3: reject unknown pseudo headers (#3973)

This commit is contained in:
Marten Seemann 2023-07-18 22:42:26 -07:00 committed by GitHub
parent b6dbfc8c06
commit 5ae28928db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -60,6 +60,8 @@ func parseHeaders(headers []qpack.HeaderField, isRequest bool) (header, error) {
case ":status":
hdr.Status = h.Value
isResponsePseudoHeader = true
default:
return header{}, fmt.Errorf("unknown pseudo header: %s", h.Name)
}
if isRequest && isResponsePseudoHeader {
return header{}, fmt.Errorf("invalid request pseudo header: %s", h.Name)

View file

@ -44,6 +44,17 @@ var _ = Describe("Request", func() {
Expect(err).To(MatchError("header field is not lower-case: Content-Length"))
})
It("rejects unknown pseudo headers", func() {
headers := []qpack.HeaderField{
{Name: ":path", Value: "/foo"},
{Name: ":authority", Value: "quic.clemente.io"},
{Name: ":method", Value: "GET"},
{Name: ":foo", Value: "bar"},
}
_, err := requestFromHeaders(headers)
Expect(err).To(MatchError("unknown pseudo header: :foo"))
})
It("rejects invalid field names", func() {
headers := []qpack.HeaderField{
{Name: ":path", Value: "/foo"},