forked from PortSwigger/bambdas
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
if (requestResponse.response() != null) { | ||
if(!requestResponse.response().hasHeader("Content-Security-Policy")) { | ||
return "No CSP"; | ||
} | ||
|
||
String csp = requestResponse.response().headerValue("Content-Security-Policy"); | ||
ArrayList<String> vulnerableDirectives = new ArrayList<>(); | ||
String[] directivesToCheck = new String[]{"unsafe-inline", "unsafe-eval"}; | ||
|
||
for(int i=0;i<directivesToCheck.length;i++) { | ||
if(csp.contains(directivesToCheck[i])) { | ||
vulnerableDirectives.add(directivesToCheck[i]); | ||
} | ||
} | ||
|
||
return String.join(", ", vulnerableDirectives); | ||
} else { | ||
return false; | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
StringBuilder cspNotes = new StringBuilder(); | ||
|
||
// Only show reqs in scope | ||
if (!requestResponse.request().isInScope()) { | ||
return false; | ||
} | ||
|
||
if(requestResponse.response() == null) { | ||
return false; | ||
} | ||
|
||
// Check if no CSP | ||
if(!requestResponse.response().hasHeader("Content-Security-Policy")) { | ||
cspNotes.append("No CSP in response").append("\n"); | ||
requestResponse.annotations().setNotes(cspNotes.toString()); | ||
return true; | ||
} | ||
|
||
// Check if bad directives in CSP | ||
String csp = requestResponse.response().headerValue("Content-Security-Policy"); | ||
ArrayList<String> vulnerableDirectives = new ArrayList<>(); | ||
String[] directivesToCheck = new String[]{"unsafe-inline", "unsafe-eval"}; | ||
|
||
for(int i=0;i<directivesToCheck.length;i++) { | ||
if(csp.contains(directivesToCheck[i])) { | ||
vulnerableDirectives.add(directivesToCheck[i]); | ||
} | ||
} | ||
|
||
String.join(", ", vulnerableDirectives); | ||
cspNotes.append(vulnerableDirectives).append("\n"); | ||
|
||
if (cspNotes.length() > 0) { | ||
requestResponse.annotations().setNotes(cspNotes.toString()); | ||
} | ||
return cspNotes.length() > 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
StringBuilder hstsNotes = new StringBuilder(); | ||
|
||
// Only show reqs in scope | ||
if (!requestResponse.request().isInScope()) { | ||
return false; | ||
} | ||
|
||
if(requestResponse.response() == null) { | ||
return false; | ||
} | ||
|
||
// Check if no HSTS | ||
if(!requestResponse.response().hasHeader("Strict-Transport-Security")) { | ||
hstsNotes.append("No HSTS in response").append("\n"); | ||
requestResponse.annotations().setNotes(hstsNotes.toString()); | ||
return true; | ||
} | ||
|
||
if (hstsNotes.length() > 0) { | ||
requestResponse.annotations().setNotes(hstsNotes.toString()); | ||
} | ||
return hstsNotes.length() > 0; |