Commit 41ebd2a
committed
http: support relaxed header validation via insecureHTTPParser
Add support for relaxed HTTP header value validation when using
the `insecureHTTPParser` option. This extends the existing option
(which already relaxes inbound HTTP parsing) to also relax outbound
header value validation.
By default, header values are validated strictly per RFC 7230/9110,
rejecting control characters (0x00-0x1f except HTAB) and DEL (0x7f).
When `insecureHTTPParser: true` is set on a request/response, or
`--insecure-http-parser` flag is used globally, header values are
validated per Fetch spec rules, only rejecting NUL (0x00), CR (0x0d),
LF (0x0a), and characters > 0xff.
This allows Node.js to interoperate with servers/clients that use
control characters in header values while maintaining security by
always rejecting CR/LF (response splitting) and NUL characters.
Refs: #61582
Refs: https://fetch.spec.whatwg.org/#header-value1 parent f77a709 commit 41ebd2a
File tree
3 files changed
+116
-24
lines changed- lib
- test/parallel
3 files changed
+116
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
260 | 273 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
265 | 277 | | |
| 278 | + | |
266 | 279 | | |
267 | 280 | | |
268 | | - | |
269 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
270 | 284 | | |
271 | 285 | | |
272 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
161 | 179 | | |
162 | 180 | | |
163 | 181 | | |
| |||
642 | 660 | | |
643 | 661 | | |
644 | 662 | | |
645 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
646 | 670 | | |
647 | 671 | | |
648 | 672 | | |
| |||
700 | 724 | | |
701 | 725 | | |
702 | 726 | | |
703 | | - | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
704 | 734 | | |
705 | 735 | | |
706 | 736 | | |
| |||
996 | 1026 | | |
997 | 1027 | | |
998 | 1028 | | |
| 1029 | + | |
999 | 1030 | | |
1000 | 1031 | | |
1001 | 1032 | | |
1002 | 1033 | | |
1003 | 1034 | | |
1004 | | - | |
| 1035 | + | |
1005 | 1036 | | |
1006 | 1037 | | |
1007 | 1038 | | |
| |||
1012 | 1043 | | |
1013 | 1044 | | |
1014 | 1045 | | |
1015 | | - | |
| 1046 | + | |
1016 | 1047 | | |
1017 | 1048 | | |
1018 | 1049 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | | - | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
| 73 | + | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
71 | | - | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | | - | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
87 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 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 | + | |
88 | 135 | | |
0 commit comments