Commit 41a8b95
NIOHTTP2: forbid keep-alive and upgrade connection-specific headers (#552)
RFC 9113 § 8.2.2 enumerates five connection-specific header fields that
a conformant HTTP/2 endpoint must treat as malformed: Connection,
Proxy-Connection, Keep-Alive, Transfer-Encoding, and Upgrade.
HeaderFieldName .legalHeaderField(value:) only rejected three of them,
so keep-alive and upgrade passed validation and were translated verbatim
into HTTP/1.1 messages by the H2->H1 codecs. This is a conformance gap
and a defence-in-depth issue, since downstream HTTP/1.1 parsers may act
on those fields independently.
Modifications:
- Add keep-alive and upgrade to the forbidden connection-specific header
switch in legalHeaderField(value:).
- Update the surrounding comment to cite RFC 9113 § 8.2.2 and its
explicit enumeration in place of the obsoleted RFC 7540 § 8.1.2.2
reference.
- Add request- and response-block validation tests covering all five
connection-specific fields.
Result:
All five connection-specific header fields named by RFC 9113 § 8.2.2 are
rejected during header-block validation.
Resolves #549
Co-authored-by: George Barnett <gbarnett@apple.com>1 parent 2a044b9 commit 41a8b95
2 files changed
Lines changed: 46 additions & 4 deletions
File tree
- Sources/NIOHTTP2
- Tests/NIOHTTP2Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
277 | | - | |
278 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| |||
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
291 | | - | |
| 292 | + | |
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
| |||
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
110 | 151 | | |
111 | 152 | | |
112 | 153 | | |
| |||
0 commit comments