Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bambda that finds requests which reflect parameters in responses #52

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Proxy/HTTP/ReflectedParameters.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Finds responses which reflect parameter names and values.
*
* Useful to identify possible attack surface for XSS, SSTI, header injection,
* open redirects or similar.
*
* @author emanuelduss
**/

// Configure to your needs
int minimumParameterNameLength = 2;
int minimumParameterValueLength = 3;
boolean matchCaseSensitive = true;
Set<String> excludedStrings = Set.of("true", "false", "null");
Set<HttpParameterType> excludedParameterTypes = Set.of(HttpParameterType.COOKIE); // e.g. HttpParameterType.COOKIE

if (!requestResponse.hasResponse()){
return false;
}

HttpRequest request = requestResponse.request();
HttpResponse response = requestResponse.response();

// Check query, b/c parameters without values are not treated as parameters
String query = request.path().replace(request.pathWithoutQuery() + "?", "");
if (query.length() >= minimumParameterValueLength && !excludedStrings.contains(query)){
if (response.contains(query, matchCaseSensitive) || response.contains(utilities().urlUtils().decode(query), matchCaseSensitive)){
return true;
}
}

if (request.hasParameters()){
for (ParsedHttpParameter parameter : request.parameters()){
HttpParameterType parameterType = parameter.type();
if (excludedParameterTypes.contains(parameter.type())){
continue;
}

String parameterName = parameter.name();
if (parameterName.length() >= minimumParameterNameLength && ! excludedStrings.contains(parameterName) &&
(response.contains(parameterName, matchCaseSensitive) || response.contains(utilities().urlUtils().decode(parameterName), matchCaseSensitive))){
return true;
}

String parameterValue = parameter.value();
if (parameterValue.length() >= minimumParameterValueLength && ! excludedStrings.contains(parameterValue) &&
(response.contains(parameterValue, matchCaseSensitive) || response.contains(utilities().urlUtils().decode(parameterValue), matchCaseSensitive))){
return true;
}
}
}

return false;