From 32cbb1d53de8fd530c615905d7d3f47298bb18a7 Mon Sep 17 00:00:00 2001 From: balaakasam Date: Sat, 4 Jul 2026 08:42:00 -0400 Subject: [PATCH 1/2] fix: add Referrer-Policy header check and update description Signed-off-by: balaakasam --- passive/Mutliple Security Header Check.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/passive/Mutliple Security Header Check.js b/passive/Mutliple Security Header Check.js index 59a6dd35..57089258 100644 --- a/passive/Mutliple Security Header Check.js +++ b/passive/Mutliple Security Header Check.js @@ -11,7 +11,7 @@ name: Missing Security Headers description: > Some of the following security headers are missing from the HTTP response: Strict-Transport-Security, Content-Security-Policy, - X-XSS-Protection, X-Content-Type-Options, X-Frame-Options. + X-XSS-Protection, X-Content-Type-Options, X-Frame-Options, Referrer-Policy. solution: > Ensure that your web server, application server, load balancer, etc. is configured to set the missing security headers. @@ -125,6 +125,17 @@ function scan(helper, msg, src) { } } +// test Referrer-Policy + if (msg.getResponseHeader().getHeaders("Referrer-Policy") == null) { + helper + .newAlert() + .setName("Referrer-Policy Header Not Set (script)") + .setDescription("The Referrer-Policy header is not set. This header controls how much referrer information is included with requests, helping to protect user privacy and prevent information leakage.") + .setSolution("Ensure that your web server, application server, load balancer, etc. is configured to set the Referrer-Policy header. Recommended value: 'strict-origin-when-cross-origin'.") + .setMessage(msg) + .raise(); + } + function hasAnyHeader(header, headers) { for (var i in headers) { if (header.getHeader(headers[i])) { From 1db5bb50515fbdafbe4d3916b4d078986507fdab Mon Sep 17 00:00:00 2001 From: balaakasam Date: Sun, 12 Jul 2026 07:42:02 -0400 Subject: [PATCH 2/2] fix: refactor Referrer-Policy check to use array mechanism Signed-off-by: balaakasam --- passive/Mutliple Security Header Check.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/passive/Mutliple Security Header Check.js b/passive/Mutliple Security Header Check.js index 57089258..ae898023 100644 --- a/passive/Mutliple Security Header Check.js +++ b/passive/Mutliple Security Header Check.js @@ -26,12 +26,13 @@ helpLink: https://www.zaproxy.org/docs/desktop/addons/community-scripts/ } function scan(helper, msg, src) { - var alertTitle = [ +var alertTitle = [ "Strict-Transport-Security (HSTS) Header Not Set (script)", "Content-Security-Policy (script)", "Web Browser XSS Protection Not Enabled (script)", "X-Content-Type-Options Header Missing (script)", "X-Frame-Options Header Not Set (script)", + "Referrer-Policy Header Not Set (script)", "", ]; var alertDesc = [ @@ -40,6 +41,7 @@ function scan(helper, msg, src) { "Web Browser XSS Protection is not enabled, or is disabled by the configuration of the 'X-XSS-Protection' HTTP response header on the web server", "The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'. This allows older versions of Internet Explorer and Chrome to perform MIME-sniffing on the response body, potentially causing the response body to be interpreted and displayed as a content type other than the declared content type. Current (early 2014) and legacy versions of Firefox will use the declared content type (if one is set), rather than performing MIME-sniffing.", "X-Frame-Options header is not included in the HTTP response to protect against 'ClickJacking' attacks.", + "The Referrer-Policy header is not set. This header controls how much referrer information is included with requests, helping to protect user privacy and prevent information leakage.", "", ]; var alertSolution = [ @@ -48,6 +50,7 @@ function scan(helper, msg, src) { "Ensure that the web browser's XSS filter is enabled, by setting the X-XSS-Protection HTTP response header to '1'.", "Ensure that the application/web server sets the Content-Type header appropriately, and that it sets the X-Content-Type-Options header to 'nosniff' for all web pages. If possible, ensure that the end user uses a standards-compliant and modern web browser that does not perform MIME-sniffing at all, or that can be directed by the web application/web server to not perform MIME-sniffing.", "Most modern Web browsers support the X-Frame-Options HTTP header. Ensure it's set on all web pages returned by your site (if you expect the page to be framed only by pages on your server (e.g. it's part of a FRAMESET) then you'll want to use SAMEORIGIN, otherwise if you never expect the page to be framed, you should use DENY. ALLOW-FROM allows specific websites to frame the web page in supported web browsers).", + "Ensure that your web server, application server, load balancer, etc. is configured to set the Referrer-Policy header. Recommended value: 'strict-origin-when-cross-origin'.", "", ]; var responseHeader = msg.getResponseHeader().toString(); @@ -129,9 +132,9 @@ function scan(helper, msg, src) { if (msg.getResponseHeader().getHeaders("Referrer-Policy") == null) { helper .newAlert() - .setName("Referrer-Policy Header Not Set (script)") - .setDescription("The Referrer-Policy header is not set. This header controls how much referrer information is included with requests, helping to protect user privacy and prevent information leakage.") - .setSolution("Ensure that your web server, application server, load balancer, etc. is configured to set the Referrer-Policy header. Recommended value: 'strict-origin-when-cross-origin'.") + .setName(alertTitle[5]) + .setDescription(alertDesc[5]) + .setSolution(alertSolution[5]) .setMessage(msg) .raise(); }