Title: http: align header value validation with Fetch spec by RajeshKumar11 · Pull Request #61597 · nodejs/node · GitHub
Open Graph Title: http: align header value validation with Fetch spec by RajeshKumar11 · Pull Request #61597 · nodejs/node
X Title: http: align header value validation with Fetch spec by RajeshKumar11 · Pull Request #61597 · nodejs/node
Description: This PR adds support for relaxed HTTP header value validation via the existing insecureHTTPParser option. This addresses the use case where Node.js needs to interoperate with servers/clients that use control characters in header values (per Fetch spec). Behavior Default (Strict) - per RFC 7230/9110 Header values are validated strictly, rejecting: Control characters 0x00-0x1f (except HTAB 0x09) DEL 0x7f Characters > 0xff With insecureHTTPParser: true (Lenient) - per Fetch spec Header values are validated leniently, only rejecting: 0x00 (NUL) 0x0a (LF) 0x0d (CR) Characters > 0xff This allows control characters like 0x01-0x08, 0x0b-0x0c, 0x0e-0x1f, and 0x7f when the option is enabled. Usage // Client request with relaxed validation const req = http.request({ host: 'example.com', port: 80, insecureHTTPParser: true // Enables lenient header validation }); req.setHeader('X-Custom', 'value\x01with-control-char'); // Now allowed // Server with relaxed validation const server = http.createServer({ insecureHTTPParser: true }, (req, res) => { res.setHeader('X-Custom', 'value\x01with-control-char'); // Now allowed res.end(); }); // Or globally via CLI flag // node --insecure-http-parser app.js What stays strict (regardless of option) Per @pimterry's feedback: http.validateHeaderValue() - The public API remains strict Status message validation - Always strict per RFC Security Consideration This change is safe because: Response splitting requires CRLF injection - CR (0x0d) and LF (0x0a) are always rejected, even in lenient mode NUL is always rejected - 0x00 is rejected in both modes Opt-in only - Users must explicitly enable insecureHTTPParser to get lenient behavior Changes lib/_http_common.js: Added strict and lenient regex patterns, checkInvalidHeaderChar now accepts optional lenient parameter lib/_http_outgoing.js: Added _isLenientHeaderValidation() method, updated setHeader, appendHeader, addTrailers to use lenient validation when enabled test/parallel/test-http-invalidheaderfield2.js: Updated to test both strict and lenient modes Refs: #61582 Refs: https://fetch.spec.whatwg.org/#header-value
Open Graph Description: This PR adds support for relaxed HTTP header value validation via the existing insecureHTTPParser option. This addresses the use case where Node.js needs to interoperate with servers/clients that u...
X Description: This PR adds support for relaxed HTTP header value validation via the existing insecureHTTPParser option. This addresses the use case where Node.js needs to interoperate with servers/clients that u...
Opengraph URL: https://github.com/nodejs/node/pull/61597
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:bf36fd7d-b84b-7523-3760-414e51768ff9 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D08C:30AD7C:18C3E40:2293483:6A4CBBB3 |
| html-safe-nonce | 14e8abe35abd7ac8ce355961f59adf36679366a838e7fd640eebbf7540df9450 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDhDOjMwQUQ3QzoxOEMzRTQwOjIyOTM0ODM6NkE0Q0JCQjMiLCJ2aXNpdG9yX2lkIjoiNDE1MDg4Mzc4OTM4NjMzMzEwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4a911db6e25edbd8feca5f2680b56fe75df758913e5b89670d0dd33fc1040034 |
| hovercard-subject-tag | pull_request:3230184613 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/nodejs/node/pull/61597/files |
| twitter:image | https://avatars.githubusercontent.com/u/22585507?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/22585507?s=400&v=4 |
| og:image:alt | This PR adds support for relaxed HTTP header value validation via the existing insecureHTTPParser option. This addresses the use case where Node.js needs to interoperate with servers/clients that u... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ae90d426644ca15e89bacceb72e51f4e9dbf85f7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width