Fixed: Prevent Host Header Injection (CVE-2019-12425)

(OFBIZ-11583)
This commit is contained in:
Jacques Le Roux
2020-04-04 19:32:02 +02:00
parent ba548f626e
commit e0f0d5271a
3 changed files with 26 additions and 0 deletions
@@ -86,6 +86,7 @@ public class RequestHandler {
private final URL controllerConfigURL;
private final boolean trackServerHit;
private final boolean trackVisit;
private final List hostHeadersAllowed;
private ControllerConfig ccfg;
public static RequestHandler getRequestHandler(ServletContext servletContext) {
@@ -111,6 +112,9 @@ public class RequestHandler {
this.trackServerHit = !"false".equalsIgnoreCase(context.getInitParameter("track-serverhit"));
this.trackVisit = !"false".equalsIgnoreCase(context.getInitParameter("track-visit"));
hostHeadersAllowed = UtilMisc.getHostHeadersAllowed();
}
public ConfigXMLReader.ControllerConfig getControllerConfig() {
@@ -209,6 +213,11 @@ public class RequestHandler {
public void doRequest(HttpServletRequest request, HttpServletResponse response, String chain,
GenericValue userLogin, Delegator delegator) throws RequestHandlerException, RequestHandlerExceptionAllowExternalRequests {
if (!hostHeadersAllowed.contains(request.getServerName())) {
Debug.logError("Domain " + request.getServerName() + " not accepted to prevent host header injection ", module);
throw new RequestHandlerException("Domain " + request.getServerName() + " not accepted to prevent host header injection ");
}
final boolean throwRequestHandlerExceptionOnMissingLocalRequest = EntityUtilProperties.propertyValueEqualsIgnoreCase(
"requestHandler", "throwRequestHandlerExceptionOnMissingLocalRequest", "Y", delegator);
long startTime = System.currentTimeMillis();