Enabling host header validation
Configure the com.ibm.elm.allowed_host_name flag to enable host header
validation. This validation helps protect the application from host header injection, cache
poisoning, and redirect-based attacks by allowing only trusted host names and ports in incoming HTTP
requests.
Before you begin
- Access to modify JVM options, environment variables, or startup scripts.
- The trusted host name (and optional port) to be validated.
Note: Host header validation is case-insensitive. Port validation is enforced only if specified
in the
com.ibm.elm.allowed_host_name flag. If the flag is not set, host header
validation is skipped.Procedure
Set the flag in one of the following ways:
- Set as a JVM Option.
- Open your jvm.options file or startup script.
- Add the following flag:
-Dcom.ibm.elm.allowed_host_name=your.host.name.com - To include a port, add the following flag:
-Dcom.ibm.elm.allowed_host_name=your.host.name.com:9443
- Set as an environment variable.
- On Linux/macOS:
- Open a terminal.
- Run the following command:
export com.ibm.elm.allowed_host_name=your.host.name.com
- On Windows:
- Open command prompt.
- Run the following command:
set com.ibm.elm.allowed_host_name=your.host.name.com
- On Linux/macOS:
- Modify
server.startup.bat(Windows only).- Open the
server.startup.batfile. - Add the following flag:
set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.elm.allowed_host_name=your.host.name.com - To include a port, add the following flag:
set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.elm.allowed_host_name=your.host.name.com:9443
- Open the
Results
Host header validation is enabled. Incoming HTTP requests are accepted only if the host header matches the configured value.