Skip to content

Instantly share code, notes, and snippets.

@lisp3r
Last active April 28, 2024 15:34
Show Gist options
  • Save lisp3r/2155acf30a05c9b057eb815e9aee6999 to your computer and use it in GitHub Desktop.
Save lisp3r/2155acf30a05c9b057eb815e9aee6999 to your computer and use it in GitHub Desktop.
Detecting Uncommon Headers in an API using Burp Bambda Filters
// Source: https://danaepp.com/detecting-uncommon-headers
String[] standardHeaders = {
"accept-patch",
"accept-ranges",
"access-control-allow-credentials",
"access-control-allow-headers",
"access-control-allow-methods",
"access-control-allow-origin",
"access-control-expose-headers",
"access-control-max-age",
"age",
"allow",
"alt-svc",
"cache-control",
"clear-site-data",
"connection",
"content-disposition",
"content-encoding",
"content-language",
"content-length",
"content-location",
"content-range",
"content-security-policy",
"content-transfer-encoding",
"content-type",
"cross-origin-embedder-policy",
"cross-origin-opener-policy",
"cross-origin-resource-policy",
"date",
"delta-base",
"etag",
"expect-ct",
"expires",
"feature-policy",
"host",
"im",
"keep-alive",
"last-modified",
"link",
"location",
"pragma",
"proxy-authenticate",
"public-key-pins",
"referrer-policy",
"retry-after",
"server",
"set-cookie",
"strict-transport-security",
"tk",
"trailer",
"transfer-encoding",
"upgrade",
"vary",
"via",
"warning",
"www-authenticate",
"x-content-type-options",
"x-frame-options",
"x-permitted-cross-domain-policies",
"x-xss-protection"
};
List headersList = Arrays.asList(standardHeaders);
var response = requestResponse.response();
if (response != null) {
var headers = response.headers();
List unexpectedHeaders = new ArrayList();
for(var header : headers) {
var headerName = header.name().toLowerCase();
if(!headersList.contains(headerName) && !unexpectedHeaders.contains(headerName)) {
unexpectedHeaders.add(headerName);
}
}
if( unexpectedHeaders.size() > 0 ) {
requestResponse.annotations().setHighlightColor( HighlightColor.GRAY );
requestResponse.annotations().setNotes(
"Non-standard Headers: " + String.join( ", ", unexpectedHeaders )
);
}
else {
requestResponse.annotations().setHighlightColor( HighlightColor.NONE );
requestResponse.annotations().setNotes("");
}
}
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment