JS: Block flow into window.location

This commit is contained in:
Asger F
2023-10-06 15:00:08 +02:00
parent 75c915b2a3
commit b5ad36686e
3 changed files with 14 additions and 6 deletions

View File

@@ -846,6 +846,14 @@ predicate clearsContent(Node n, ContentSet c) {
// We implement this rule by clearing any captured-content before storing into another captured-content.
VariableCaptureOutput::storeStep(getClosureNode(n), _, _) and
c = MkAnyCapturedContent()
or
// Block flow into the "window.location" property, as any assignment/mutation to this causes a page load and stops execution.
// The use of clearsContent here ensures we also block assignments like `window.location.href = ...`
exists(DataFlow::PropRef ref |
ref = DataFlow::globalObjectRef().getAPropertyReference("location") and
n = ref.getBase().getPostUpdateNode() and
c = ContentSet::property("location")
)
}
/**