Skip to content

Commit 3a09fbb

Browse files
committed
content_encoding: return error on too many compression steps
The max allowed steps is arbitrarily set to 5. Bug: https://curl.se/docs/CVE-2022-32206.html CVE-2022-32206 Reported-by: Harry Sintonen Closes #9049
1 parent 6ecdf51 commit 3a09fbb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/content_encoding.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,12 +1028,16 @@ static const struct content_encoding *find_encoding(const char *name,
10281028
return NULL;
10291029
}
10301030

1031+
/* allow no more than 5 "chained" compression steps */
1032+
#define MAX_ENCODE_STACK 5
1033+
10311034
/* Set-up the unencoding stack from the Content-Encoding header value.
10321035
* See RFC 7231 section 3.1.2.2. */
10331036
CURLcode Curl_build_unencoding_stack(struct Curl_easy *data,
10341037
const char *enclist, int maybechunked)
10351038
{
10361039
struct SingleRequest *k = &data->req;
1040+
int counter = 0;
10371041

10381042
do {
10391043
const char *name;
@@ -1068,6 +1072,11 @@ CURLcode Curl_build_unencoding_stack(struct Curl_easy *data,
10681072
if(!encoding)
10691073
encoding = &error_encoding; /* Defer error at stack use. */
10701074

1075+
if(++counter >= MAX_ENCODE_STACK) {
1076+
failf(data, "Reject response due to %u content encodings",
1077+
counter);
1078+
return CURLE_BAD_CONTENT_ENCODING;
1079+
}
10711080
/* Stack the unencoding stage. */
10721081
writer = new_unencoding_writer(data, encoding, k->writer_stack);
10731082
if(!writer)

0 commit comments

Comments
 (0)