mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Simplify PathAssignmentBarrier
This commit is contained in:
@@ -75,25 +75,18 @@ module OpenUrlRedirect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bindingset[var, w]
|
|
||||||
pragma[inline_late]
|
|
||||||
private predicate useIsDominated(SsaWithFields var, Write w, DataFlow::ReadNode sanitizedRead) {
|
|
||||||
w.dominatesNode(sanitizedRead.asInstruction()) and
|
|
||||||
sanitizedRead = var.getAUse()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An access to a variable that is preceded by an assignment to its `Path` field.
|
* An assignment of a safe value to the field `Path`, considered as a barrier for sanitizing
|
||||||
|
* untrusted URLs.
|
||||||
*
|
*
|
||||||
* This is overapproximate; this will currently remove flow through all `Url.Path` assignments
|
* This is overapproximate; this will currently remove flow through all `Url.Path` assignments
|
||||||
* which contain a substring that could sanitize data.
|
* which contain a substring that could sanitize data.
|
||||||
*/
|
*/
|
||||||
class PathAssignmentBarrier extends Barrier, Read {
|
class PathAssignmentBarrier extends Barrier {
|
||||||
PathAssignmentBarrier() {
|
PathAssignmentBarrier() {
|
||||||
exists(Write w, SsaWithFields var |
|
exists(Write w, DataFlow::Node rhs |
|
||||||
hasHostnameSanitizingSubstring(w.getRhs()) and
|
hasHostnameSanitizingSubstring(rhs) and
|
||||||
w.writesFieldPreUpdate(var.getAUse(), any(Field f | f.getName() = "Path"), _) and
|
w.writesFieldPreUpdate(this, any(Field f | f.getName() = "Path"), rhs)
|
||||||
useIsDominated(var, w, this)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user