Skip to content

Commit

Permalink
Merge pull request #84 from ctflearner/DetectWeakXSSProtection
Browse files Browse the repository at this point in the history
Create DetectWeakXSSProtectionHeader.bambda
  • Loading branch information
PortSwiggerWiener authored Jan 9, 2025
2 parents 87bcb70 + 6d4d097 commit bdfc1f2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Filter/Proxy/HTTP/DetectWeakXSSProtectionHeader.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Bambda Script to Detect "Weak or Misconfigured X-XSS-Protection" Header in HTTP Response
* @author ctflearner
* This script checks if the HTTP response contains a weak or misconfigured "X-XSS-Protection" header.
* It identifies the following cases:
* 1. The header is set to "0", explicitly disabling XSS protection.
* 2. The header is set to "1" (minimal protection) or includes a "report=" directive,
* which may indicate insufficient or partial mitigation.
* The script ensures there is a response and scans the headers for these conditions.
**/


return requestResponse.hasResponse() &&
requestResponse.response().headers().stream()
.filter(header -> header.name().equalsIgnoreCase("X-XSS-Protection"))
.anyMatch(header -> {
String value = header.value().trim();
return value.equals("0") ||
value.equals("1") ||
value.toLowerCase(Locale.US).contains("report=");
});

0 comments on commit bdfc1f2

Please sign in to comment.