Skip to content

Commit 969166a

Browse files
authored
fix(nifi): Conditionally disable Host Port Validation in NiFi 2.4.0 (#1125)
* conditionally disable host port validation in NiFi 2.4.0 * add changelog entry
1 parent 0ebe644 commit 969166a

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ All notable changes to this project will be documented in this file.
6161
- vector: Bump to `0.46.1` ([#1098]).
6262
- spark: update dependencies for 3.5.5 ([#1094])
6363
- nifi: include NAR SBOMs ([#1119])
64+
- nifi: update patch allowing to bypass host header validation starting with NiFi 2.4.0 ([#1125]).
6465
- BREAKING: kcat: Stop building kcat image ([#1124]).
6566

6667
### Fixed
@@ -140,6 +141,7 @@ All notable changes to this project will be documented in this file.
140141
[#1119]: https://github.com/stackabletech/docker-images/pull/1119
141142
[#1121]: https://github.com/stackabletech/docker-images/pull/1121
142143
[#1124]: https://github.com/stackabletech/docker-images/pull/1124
144+
[#1125]: https://github.com/stackabletech/docker-images/pull/1125
143145

144146
## [25.3.0] - 2025-03-21
145147

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From 5eb0363521dbb30e3e47ec8a604f5a5c678bf4fb Mon Sep 17 00:00:00 2001
2+
From: Benedikt Labrenz <[email protected]>
3+
Date: Thu, 22 May 2025 14:47:24 +0200
4+
Subject: disable host port validation if list of allowed hosts only contains
5+
'*'
6+
7+
---
8+
.../connector/FrameworkServerConnectorFactory.java | 13 +++++++++++--
9+
1 file changed, 11 insertions(+), 2 deletions(-)
10+
11+
diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/connector/FrameworkServerConnectorFactory.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/connector/FrameworkServerConnectorFactory.java
12+
index ec1bee66fb..b58c886f4f 100644
13+
--- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/connector/FrameworkServerConnectorFactory.java
14+
+++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/connector/FrameworkServerConnectorFactory.java
15+
@@ -54,6 +54,8 @@ public class FrameworkServerConnectorFactory extends StandardServerConnectorFact
16+
17+
private final String excludeCipherSuites;
18+
19+
+ private final boolean disableHostPortValidator;
20+
+
21+
private final Set<Integer> validPorts;
22+
23+
private SslContextFactory.Server sslContextFactory;
24+
@@ -72,6 +74,11 @@ public class FrameworkServerConnectorFactory extends StandardServerConnectorFact
25+
headerSize = DataUnit.parseDataSize(properties.getWebMaxHeaderSize(), DataUnit.B).intValue();
26+
validPorts = getValidPorts(properties);
27+
28+
+ // Check if the property for allowed hosts has only the wildcard entry and
29+
+ // if so store this in disableHostPortValidator for later use
30+
+ List<String> configuredHostNames = properties.getAllowedHostsAsList();
31+
+ disableHostPortValidator = configuredHostNames.size() == 1 && configuredHostNames.contains("*");
32+
+
33+
if (properties.isHTTPSConfigured()) {
34+
if (properties.isClientAuthRequiredForRestApi()) {
35+
setNeedClientAuth(true);
36+
@@ -102,8 +109,10 @@ public class FrameworkServerConnectorFactory extends StandardServerConnectorFact
37+
// Add HostHeaderCustomizer to set Host Header for HTTP/2 and HostHeaderHandler
38+
httpConfiguration.addCustomizer(new HostHeaderCustomizer());
39+
40+
- final HostPortValidatorCustomizer hostPortValidatorCustomizer = new HostPortValidatorCustomizer(validPorts);
41+
- httpConfiguration.addCustomizer(hostPortValidatorCustomizer);
42+
+ if (!disableHostPortValidator) {
43+
+ final HostPortValidatorCustomizer hostPortValidatorCustomizer = new HostPortValidatorCustomizer(validPorts);
44+
+ httpConfiguration.addCustomizer(hostPortValidatorCustomizer);
45+
+ }
46+
47+
return httpConfiguration;
48+
}

0 commit comments

Comments
 (0)