Headline
CVE-2023-1428: [chttp2] Fix fuzzer found bug (#32507) · grpc/grpc@2485fa9
There exists an vulnerability causing an abort() to be called in gRPC. The following headers cause gRPC’s C++ implementation to abort() when called via http2:
te: x (x != trailers)
:scheme: x (x != http, https)
grpclb_client_stats: x (x == anything)
On top of sending one of those headers, a later header must be sent that gets the total header size past 8KB. We recommend upgrading past git commit 2485fa94bd8a723e5c977d55a3ce10b301b437f8 or v1.53 and above.
Expand Up
@@ -49,6 +49,16 @@
namespace grpc_core {
// Given a metadata key and a value, return the encoded size.
// Defaults to calling the key’s Encode() method and then calculating the size
// of that, but can be overridden for specific keys if there’s a better way of
// doing this.
// May return 0 if the size is unknown/unknowable.
template <typename Key>
size_t EncodedSizeOfKey(Key, const typename Key::ValueType& value) {
return Key::Encode(value).size();
}
// grpc-timeout metadata trait.
// ValueType is defined as Timestamp - an absolute timestamp (i.e. a
// deadline!), that is converted to a duration by transports before being
Expand Down Expand Up
@@ -90,6 +100,10 @@ struct TeMetadata {
static const char* DisplayMemento(MementoType te) { return DisplayValue(te); }
};
inline size_t EncodedSizeOfKey(TeMetadata, TeMetadata::ValueType x) {
return x == TeMetadata::kTrailers ? 8 : 0;
}
// content-type metadata trait.
struct ContentTypeMetadata {
static constexpr bool kRepeatable = false;
Expand Down Expand Up
@@ -140,6 +154,8 @@ struct HttpSchemeMetadata {
}
};
size_t EncodedSizeOfKey(HttpSchemeMetadata, HttpSchemeMetadata::ValueType x);
// method metadata trait.
struct HttpMethodMetadata {
static constexpr bool kRepeatable = false;
Expand Down Expand Up
@@ -362,6 +378,11 @@ struct GrpcLbClientStatsMetadata {
}
};
inline size_t EncodedSizeOfKey(GrpcLbClientStatsMetadata,
GrpcLbClientStatsMetadata::ValueType) {
return 0;
}
// lb-token metadata
struct LbTokenMetadata : public SimpleSliceBasedMetadata {
static constexpr bool kRepeatable = false;
Expand Down
Related news
gRPC contains a vulnerability that allows hpack table accounting errors could lead to unwanted disconnects between clients and servers in exceptional cases/ Three vectors were found that allow the following DOS attacks: - Unbounded memory buffering in the HPACK parser - Unbounded CPU consumption in the HPACK parser The unbounded CPU consumption is down to a copy that occurred per-input-block in the parser, and because that could be unbounded due to the memory copy bug we end up with an O(n^2) parsing loop, with n selected by the client. The unbounded memory buffering bugs: - The header size limit check was behind the string reading code, so we needed to first buffer up to a 4 gigabyte string before rejecting it as longer than 8 or 16kb. - HPACK varints have an encoding quirk whereby an infinite number of 0’s can be added at the start of an integer. gRPC’s hpack parser needed to read all of them before concluding a parse. - gRPC’s metadata overflow check was performed per frame, so ...
There exists an vulnerability causing an abort() to be called in gRPC. The following headers cause gRPC's C++ implementation to abort() when called via http2: te: x (x != trailers) :scheme: x (x != http, https) grpclb_client_stats: x (x == anything) On top of sending one of those headers, a later header must be sent that gets the total header size past 8KB. We recommend upgrading past git commit 2485fa94bd8a723e5c977d55a3ce10b301b437f8 or v1.53 and above.