Skip to content

transport: http2 server must validate header list size when early aborting stream #8766

@arjan-bal

Description

@arjan-bal

While sending headers and trailers in the normal flow, gRPC ensures that the headers length is less than the limit specified by the peer. If not, a RST_STREAM frame is sent instead.

success, err := t.controlBuf.executeAndPut(func() bool {
return t.checkForHeaderListSize(trailingHeader)
}, nil)
if !success {
if err != nil {
return err
}
t.closeStream(s, true, http2.ErrCodeInternal, false)
return ErrHeaderListSizeLimitViolation
}
// Send a RST_STREAM after the trailers if the client has not already half-closed.
rst := s.getState() == streamActive
t.finishStream(s, rst, http2.ErrCodeNo, trailingHeader, true)

success, err := t.controlBuf.executeAndPut(func() bool { return t.checkForHeaderListSize(hf) }, hf)
if !success {
if err != nil {
return err
}
t.closeStream(s, true, http2.ErrCodeInternal, false)
return ErrHeaderListSizeLimitViolation
}

A similar check should also be performed when the server decides to abort the stream after parsing the client headers here:

}
if err := l.writeHeader(eas.streamID, true, headerFields, nil); err != nil {
return err
}

We should also add a test to catch regressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: TransportIncludes HTTP/2 client/server and HTTP server handler transports and advanced transport features.Type: Bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions