Python: Add prefix sanitizer on URL redirect query

This doesn't cover 100% of what we want to, but matches what we used to.
This commit is contained in:
Rasmus Wriedt Larsen
2021-01-19 16:08:10 +01:00
parent d8bfa3565f
commit 37aa9b9d06
3 changed files with 11 additions and 10 deletions

View File

@@ -22,6 +22,15 @@ class UrlRedirectConfiguration extends TaintTracking::Configuration {
sink = any(HTTP::Server::HttpRedirectResponse e).getRedirectLocation()
}
override predicate isSanitizer(DataFlow::Node node) {
// Url redirection is a problem only if the user controls the prefix of the URL.
// This is a copy of the taint-sanitizer from the old points-to query, which doesn't
// cover formatting.
exists(BinaryExprNode string_concat | string_concat.getOp() instanceof Add |
string_concat.getRight() = node.asCfgNode()
)
}
override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) {
guard instanceof StringConstCompare
}