NIFI-14209 Restructure Host Header Validation #9680
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
NIFI-14209 Restructures application HTTP
Host
header validation, removing theHostHeaderHandler
and adding theHostPortValidatorCustomizer
in the framework Jetty Server.The default behavior of the SecureRequestCustomizer in Jetty 12 requires TLS Server Name Indication checking, which enforces that the requested
Host
header or authority must match one of the DNS Subject Alternative Names on the server certificate. When the HTTP request does not include a valid matching DNS name in theHost
header, theSecureRequestCustomizer
returns an HTTP 400 Bad Request withInvalid SNI
as the reason. The check disallows the use of IP addresses and enforces DNS names matching the configured server certificate, which obviates much of the validation logic previously implemented in theHostHeaderHandler
.The TLS SNI check does not validate the requested port, which is an optional part of the
Host
header. Changes in this pull request introduce theHostPortValidatorCustomizer
with a configurable property for valid ports based on the existingnifi.web.proxy.host
property. The new class checks the requested port for secure HTTPS requests and returns an HTTP 421 Misdirected Request status for invalid port numbers.New test methods for the Jetty
StandardServerProvider
confirm the expected behavior of both TLS SNI checking and host port validation with requests containing customHost
headers.Additional changes include streamlining construction of the
RequestUriBuilder
using only theHttpServletRequest
, which contains the list of allowed context paths for request.Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000
NIFI-00000
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
LICENSE
andNOTICE
filesDocumentation