Subject: [quicwg/base-drafts] QPACK security considerations (#3575)

From: afrind <[email-masked]>
Date: Mon, 13 Apr 2020 15:00:11 -0700

Behold

Fixes: 1737
You can view, comment on, or merge this pull request online at:

  https://github.com/quicwg/base-drafts/pull/3575

-- Commit Summary --

  * QPACK security considerations

-- File Changes --

    M draft-ietf-quic-qpack.md (236)

-- Patch Links --

https://github.com/quicwg/base-drafts/pull/3575.patch
https://github.com/quicwg/base-drafts/pull/3575.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575

---

From: Martin Thomson <[email-masked]>
Date: Mon, 13 Apr 2020 18:16:46 -0700

@martinthomson approved this pull request.

This looks good.  But then I'm not impartial in this.

An informative reference to HPACK might be wise.  Otherwise people might get an unexplained sense of déjà vu.

> +
+The compression context used to encode header fields can be probed by an
+attacker who can both define header fields to be encoded and transmitted and
+observe the length of those fields once they are encoded. When an attacker can
+do both, they can adaptively modify requests in order to confirm guesses about
+the dynamic table state. If a guess is compressed into a shorter length, the
+attacker can observe the encoded length and infer that the guess was correct.
+
+This is possible even over the Transport Layer Security Protocol (TLS, see
+{{?RFC5246}}), because while TLS provides confidentiality protection for
+content, it only provides a limited amount of protection for the length of that
+content.
+
+Note:
+
+Padding schemes only provide limited protection against an attacker with these

```suggestion
: Padding schemes only provide limited protection against an attacker with these
```

> +
+Users of HTTP that require confidentiality for header fields can use values with
+entropy sufficient to make guessing infeasible. However, this is impractical as
+a general solution because it forces all users of HTTP to take steps to mitigate
+attacks. It would impose new constraints on how HTTP is used.
+
+Rather than impose constraints on users of HTTP, an implementation of QPACK can
+instead constrain how compression is applied in order to limit the potential for
+dynamic table probing.
+
+An ideal solution segregates access to the dynamic table based on the entity
+that is constructing header fields. Header field values that are added to the
+table are attributed to an entity, and only the entity that created a particular
+value can extract that value.
+
+To improve compression performance of tqhis option, certain entries might be tagged as being public. For example, a web browser might make the values of the Accept-Encoding header field available in all requests.

```suggestion
To improve compression performance of this option, certain entries might be
tagged as being public. For example, a web browser might make the values of the
Accept-Encoding header field available in all requests.
```

> +An ideal solution segregates access to the dynamic table based on the entity
+that is constructing header fields. Header field values that are added to the
+table are attributed to an entity, and only the entity that created a particular
+value can extract that value.
+
+To improve compression performance of tqhis option, certain entries might be tagged as being public. For example, a web browser might make the values of the Accept-Encoding header field available in all requests.
+
+An encoder without good knowledge of the provenance of header fields might
+instead introduce a penalty for a header field with many different values, such
+that a large number of attempts to guess a header field value results in the
+header field no more being compared to the dynamic table entries in future
+messages, effectively preventing further guesses.
+
+Note:
+
+Simply removing entries corresponding to the header field from the dynamic table

```suggestion
: Simply removing entries corresponding to the header field from the dynamic table
```

> +that a large number of attempts to guess a header field value results in the
+header field no more being compared to the dynamic table entries in future
+messages, effectively preventing further guesses.

```suggestion
that a large number of attempts to guess a header field value results in the
header field not being compared to the dynamic table entries in future
messages, effectively preventing further guesses.
```

I had a little trouble with "no more".

> +field value. Marking a header field as not using the dynamic table any more
+might occur for shorter values more quickly or with higher probability than for
+longer values.

```suggestion
field value. Disabling access to the dynamic table for a header field might
occur for shorter values more quickly or with higher probability than for longer
values.
```

> +values with low entropy.
+
+An encoder might also choose not to index values for header fields that are
+considered to be highly valuable or sensitive to recovery, such as the Cookie or
+Authorization header fields.
+
+On the contrary, an encoder might prefer indexing values for header fields that
+have little or no value if they were exposed. For instance, a User-Agent header
+field does not commonly vary between requests and is sent to any server. In that
+case, confirmation that a particular User-Agent value has been used provides
+little value.
+
+Note that these criteria for deciding to use a never indexed literal
+representation will evolve over time as new attacks are discovered.
+
+##. Static Huffman Encoding

```suggestion
## Static Huffman Encoding
```

> +On the contrary, an encoder might prefer indexing values for header fields that
+have little or no value if they were exposed. For instance, a User-Agent header
+field does not commonly vary between requests and is sent to any server. In that
+case, confirmation that a particular User-Agent value has been used provides
+little value.
+
+Note that these criteria for deciding to use a never indexed literal
+representation will evolve over time as new attacks are discovered.
+
+##. Static Huffman Encoding
+
+There is no currently known attack against a static Huffman encoding. A study
+has shown that using a static Huffman encoding table created an information
+leakage, however this same study concluded that an attacker could not take
+advantage of this information leakage to recover any meaningful amount of
+information (see [PETAL]).

Want to point out that QPACK uses the same Huffman table as HPACK?

> +designed to limit both the peak and state amounts of memory allocated by an
+endpoint.

```suggestion
designed to limit both the peak and stable amounts of memory allocated by an
endpoint.
```

> +has shown that using a static Huffman encoding table created an information
+leakage, however this same study concluded that an attacker could not take
+advantage of this information leakage to recover any meaningful amount of
+information (see [PETAL]).
+
+## Memory Consumption
+
+An attacker can try to cause an endpoint to exhaust its memory. QPACK is
+designed to limit both the peak and state amounts of memory allocated by an
+endpoint.
+
+The amount of memory used by the compressor is limited by the protocol using
+QPACK through the definition of the maximum size of the dynamic table, and the
+maximum number of blocking streams. In HTTP/3, these values are controlled by
+the decoder through the setting parameter QPACK_MAX_TABLE_CAPACITY and
+QPACK_BLOCKED_STREAMS, respectively (see Section

```suggestion
QPACK_BLOCKED_STREAMS, respectively (see
```

> +maximum number of blocking streams. In HTTP/3, these values are controlled by
+the decoder through the setting parameter QPACK_MAX_TABLE_CAPACITY and
+QPACK_BLOCKED_STREAMS, respectively (see Section
+{{maximum-dynamic-table-capacity}} and {{blocked-streams}}). The limit on the
+size of the dynamic table takes into account both the size of the data stored in
+the dynamic table, plus a small allowance for overhead.  The limit on the number
+of blocked streams is only a proxy for the maximum amount of memory required by
+the decoder.  The actual maximum amount of memory will depend on how much memory
+the decoder uses to track each blocked stream.
+
+A decoder can limit the amount of state memory used for the dynamic table by
+setting an appropriate value for the maximum size of the dynamic table. In
+HTTP/3, this is realized by setting an appropriate value for the
+QPACK_MAX_TABLE_CAPACITY parameter. An encoder can limit the amount of state
+memory it uses by signaling lower dynamic table size than the decoder allows
+(see {{eviction}}).  A decoder can limit the amount of state memory used for

```suggestion
(see {{eviction}}).

A decoder can limit the amount of state memory used for
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#pullrequestreview-392536154

---

From: Lucas Pardue <[email-masked]>
Date: Tue, 14 Apr 2020 15:31:27 -0700

@LPardue approved this pull request.

lgtm modulo some nits

> +confirm guesses a character at a time, reducing an exponential-time attack into
+a linear-time attack.
+
+## Applicability to QPACK and HTTP
+
+QPACK mitigates but does not completely prevent attacks modeled on CRIME [CRIME]
+by forcing a guess to match an entire header field value, rather than individual
+characters. An attacker can only learn whether a guess is correct or not, so is
+reduced to a brute force guess for the header field values.
+
+The viability of recovering specific header field values therefore depends on
+the entropy of values. As a result, values with high entropy are unlikely to be
+recovered successfully. However, values with low entropy remain vulnerable.
+
+Attacks of this nature are possible any time that two mutually distrustful
+entities control requests or responses that are placed onto a single HTTP/2

```suggestion
entities control requests or responses that are placed onto a single HTTP/3
```

nit: the doc is inconsistent about QPACK_MAX_TABLE_CAPACITY  vs SETTINGS_QPACK_MAX_TABLE_CAPACITY. I don't know what the answer is

```suggestion
memory it uses by signaling a lower dynamic table size than the decoder allows
```

+size of the dynamic table takes into account both the size of the data stored in
+the dynamic table, plus a small allowance for overhead.  The limit on the number
+of blocked streams is only a proxy for the maximum amount of memory required by
+the decoder.  The actual maximum amount of memory will depend on how much memory
+the decoder uses to track each blocked stream.
+
+A decoder can limit the amount of state memory used for the dynamic table by
+setting an appropriate value for the maximum size of the dynamic table. In
+HTTP/3, this is realized by setting an appropriate value for the
+QPACK_MAX_TABLE_CAPACITY parameter. An encoder can limit the amount of state
+memory it uses by signaling lower dynamic table size than the decoder allows
+(see {{eviction}}).  A decoder can limit the amount of state memory used for
+blocked streams by setting an appropriate value for the maximum number of
+blocked streams.  In HTTP/3, this is realized by setting an appropriate value
+for the QPACK_BLOCKED_STREAMS parameter.  An encoder can limit the amount of

nit: QPACK_BLOCKED_STREAMS  vs. SETTINGS_QPACK_BLOCKED_STREAMS

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#pullrequestreview-393333547

---

From: afrind <[email-masked]>
Date: Tue, 14 Apr 2020 15:41:19 -0700

@afrind commented on this pull request.

It's mentioned in the string literal section: 

> When Huffman encoding is enabled, the Huffman
table from Appendix B of [RFC7541] is used without modification.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#discussion_r408477752

---

From: afrind <[email-masked]>
Date: Tue, 14 Apr 2020 15:43:00 -0700

+endpoint.

This error is in the HPACK RFC.  Is it worth an errata?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#discussion_r408478326

---

From: afrind <[email-masked]>
Date: Tue, 14 Apr 2020 15:46:20 -0700

The text seems to consistently use SETTINGS_ variants, but the table omits it.  I'll fix these to match the text, but SETTINGS_ seems redundant in the table.  I'll resolve the inconsistency in another PR.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#discussion_r408479540

---

From: Lucas Pardue <[email-masked]>
Date: Tue, 14 Apr 2020 15:47:37 -0700

@LPardue commented on this pull request.

wfm

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#discussion_r408480000

---

From: afrind <[email-masked]>
Date: Tue, 14 Apr 2020 15:48:06 -0700

@afrind pushed 2 commits.

aa8fed6e6ddc4114626550d1cf0bdd7b40a8c7dd  Fix lint
4c3256a0f07e838ae04aa16d2105f4f82869d0da  Feedback from Martin and Lucas

-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575/files/25f837ca39c34cf470762c3471cbb4ef61524e9c..4c3256a0f07e838ae04aa16d2105f4f82869d0da

---

From: Martin Thomson <[email-masked]>
Date: Tue, 14 Apr 2020 17:43:02 -0700

@martinthomson commented on this pull request.

+endpoint.

I'll let you manage that :)  You can be the author of an RFC erratum.  The glory!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#discussion_r408516069

---

From: Mike Bishop <[email-masked]>
Date: Wed, 15 Apr 2020 11:40:45 -0700

@MikeBishop commented on this pull request.

It's an (unstated) norm to omit SETTINGS_ in cases where it's already blatantly obvious that we're discussing a setting.  You'll find similar variance in 7540, 7541, and HTTP/3.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#discussion_r409054517

---

From: Mike Bishop <[email-masked]>
Date: Thu, 16 Apr 2020 13:27:21 -0700

@MikeBishop approved this pull request.

All looks good (and familiar); some minor nits.

> +used.  If HPACK (see Section 6.2.3 of [RFC7541]) is used for re-encoding, the
+never indexed literal representation MUST be used.

```suggestion
used.  If HPACK is used for re-encoding, the never indexed literal
representation (see Section 6.2.3 of [RFC7541]) MUST be used.
```

+Implementations can also choose to protect sensitive header fields by not
+compressing them and instead encoding their value as literals.
+
+Refusing to insert a header field into the dynamic table is only
+effective if doing so is avoided on all hops. The never indexed literal bit (see
+{{literal-name-reference}}) can be used to signal to intermediaries that a
+particular value was intentionally sent as a literal.
+
+An intermediary MUST NOT re-encode a value that uses a literal representation
+with the 'N' bit set with another representation that would index it. If QPACK
+is used for re-encoding, a literal representation with the 'N' bit set MUST be
+used.  If HPACK (see Section 6.2.3 of [RFC7541]) is used for re-encoding, the
+never indexed literal representation MUST be used.
+
+The choice to use a never indexed literal representation for a header field

```suggestion
The choice to mark that a header field should never be indexed
```

> +the decoder through the setting parameter SETTINGS_QPACK_MAX_TABLE_CAPACITY and
+SETTINGS_QPACK_BLOCKED_STREAMS, respectively (see

```suggestion
the decoder through the settings parameters SETTINGS_QPACK_MAX_TABLE_CAPACITY
and SETTINGS_QPACK_BLOCKED_STREAMS, respectively (see
```

+## Static Huffman Encoding
+
+There is no currently known attack against a static Huffman encoding. A study
+has shown that using a static Huffman encoding table created an information
+leakage, however this same study concluded that an attacker could not take
+advantage of this information leakage to recover any meaningful amount of
+information (see [PETAL]).
+
+## Memory Consumption
+
+An attacker can try to cause an endpoint to exhaust its memory. QPACK is
+designed to limit both the peak and stable amounts of memory allocated by an
+endpoint.
+
+The amount of memory used by the compressor is limited by the protocol using

```suggestion
The amount of memory used by the encoder is limited by the protocol using
```

> +SETTINGS_QPACK_MAX_TABLE_CAPACITY parameter. An encoder can limit the amount of
+state memory it uses by signaling a lower dynamic table size than the decoder
+allows (see {{eviction}}).
+
+A decoder can limit the amount of state memory used for blocked streams by
+setting an appropriate value for the maximum number of blocked streams.  In
+HTTP/3, this is realized by setting an appropriate value for the
+QPACK_BLOCKED_STREAMS parameter.  An encoder can limit the amount of state
+memory by only using as many blocked streams as it wishes to support; no
+signaling to the decoder is requred.
+
+The amount of temporary memory consumed by an encoder or decoder can be limited
+by processing header fields sequentially. A decoder implementation does not need
+to retain a complete list of header fields while decoding a header block. An
+encoder implementation does not need to retain a complete list of header fields
+if while encoding a header block if it is using a single-pass encoder.  Note

```suggestion
while encoding a header block if it is using a single-pass algorithm.  Note
```

> @@ -1155,6 +1369,19 @@ to an excess of unsent data might include limiting the ability of the peer to
 open new streams, reading only from the encoder stream, or closing the
 connection.
 
+
+## Implementation Limits
+
+An implementation of QPACK needs to ensure that large values for integers, long
+encoding for integers, or long string literals do not create security
+weaknesses.
+
+An implementation has to set a limit for the values it accepts for integers, as
+well as for the encoded length (see {{prefixed-integers}}). In the same way, it
+has to set a limit to the length it accepts for string literals (see
+{{string-literals}}).

I believe we have a minimum size which MUST be supported; should that be mentioned here?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#pullrequestreview-394965096

---

From: Bence Béky <[email-masked]>
Date: Wed, 22 Apr 2020 06:40:53 -0700

@bencebeky approved this pull request.

+
+## Memory Consumption
+

"both" does not flow well with "plus".  Either s/", plus"/" and"/, or remove "both".

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#pullrequestreview-398195207

---

From: Lucas Pardue <[email-masked]>
Date: Tue, 28 Apr 2020 09:14:51 -0700

@afrind I think this is inches of getting landed

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3575#issuecomment-620706590