Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470) As reported by OWASP ZAP: A cookie has been set without the SameSite attribute, which means that the cookie can be sent as a result of a 'cross-site' request. The SameSite attribute is an effective counter measure to cross-site request forgery, cross-site script inclusion, and timing attacks. The solution was not obvious in OFBiz for 2 reasons: 1. There is no HttpServletResponse::setHeader. So we need to use a filter (SameSiteFilter) and even that is not enough because of 2: 2. To prevent session fixation we force Tomcat to generates a new jsessionId, ultimately put in cookie, in LoginWorker::login. So we need to add a call to SameSiteFilter::addSameSiteCookieAttribute in UtilHttp::setResponseBrowserDefaultSecurityHeaders.
This commit is contained in:
@@ -66,6 +66,7 @@ import org.apache.http.ssl.SSLContexts;
|
||||
import org.apache.ofbiz.entity.Delegator;
|
||||
import org.apache.ofbiz.entity.util.EntityUtilProperties;
|
||||
import org.apache.ofbiz.webapp.control.ConfigXMLReader;
|
||||
import org.apache.ofbiz.webapp.control.SameSiteFilter;
|
||||
import org.apache.ofbiz.webapp.event.FileUploadProgressListener;
|
||||
import org.apache.ofbiz.widget.renderer.VisualTheme;
|
||||
import org.apache.oro.text.regex.MalformedPatternException;
|
||||
@@ -1152,6 +1153,8 @@ public final class UtilHttp {
|
||||
|
||||
resp.setHeader("Content-Security-Policy-Report-Only", "default-src 'self'");
|
||||
|
||||
SameSiteFilter.addSameSiteCookieAttribute(resp);
|
||||
|
||||
// TODO in custom project. Public-Key-Pins-Report-Only is interesting but can't be used OOTB because of demos (the letsencrypt certificate is renewed every 3 months)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user