diff --git a/doc/api/http2.md b/doc/api/http2.md index c24e43f12b0c6b..122d9deb517974 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -2461,6 +2461,17 @@ added: v8.4.0 Returns a [HTTP/2 Settings Object][] containing the deserialized settings from the given `Buffer` as generated by `http2.getPackedSettings()`. +### `http2.sensitiveHeaders` + + +* {symbol} + +This symbol can be set as a property on the HTTP/2 headers object with an array +value in order to provide a list of headers considered sensitive. +See [Sensitive headers][] for more details. + ### Headers object Headers are represented as own-properties on JavaScript objects. The property @@ -2509,6 +2520,33 @@ server.on('stream', (stream, headers) => { }); ``` + +#### Sensitive headers + +HTTP2 headers can be marked as sensitive, which means that the HTTP/2 +header compression algorithm will never index them. This can make sense for +header values with low entropy and that may be considered valuable to an +attacker, for example `Cookie` or `Authorization`. To achieve this, add +the header name to the `[http2.sensitiveHeaders]` property as an array: + +```js +const headers = { + ':status': '200', + 'content-type': 'text-plain', + 'cookie': 'some-cookie', + 'other-sensitive-header': 'very secret data', + [http2.sensitiveHeaders]: ['cookie', 'other-sensitive-header'] +}; + +stream.respond(headers); +``` + +For some headers, such as `Authorization` and short `Cookie` headers, +this flag is set automatically. + +This property is also set for received headers. It will contain the names of +all headers marked as sensitive, including ones marked that way automatically. + ### Settings object