Skip to content

Commit 6fb534f

Browse files
committed
fix catastrophic join order in UnsafeJQueryPlugin
1 parent 9502869 commit 6fb534f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/UnsafeJQueryPluginCustomizations.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,25 @@ module UnsafeJQueryPlugin {
195195
*/
196196
predicate isLikelyIntentionalHtmlSink(DataFlow::Node sink) {
197197
exists(
198-
JQuery::JQueryPluginMethod plugin, DataFlow::PropWrite defaultDef, string default,
198+
JQuery::JQueryPluginMethod plugin, DataFlow::PropWrite defaultDef,
199199
DataFlow::PropRead finalRead
200200
|
201201
hasDefaultOption(plugin, defaultDef) and
202-
defaultDef.getPropertyName() = finalRead.getPropertyName() and
203-
defaultDef.getRhs().mayHaveStringValue(default) and
204-
default.regexpMatch("\\s*<.*") and
202+
defaultDef = getALikelyHTMLWrite(finalRead.getPropertyName()) and
205203
finalRead.flowsTo(sink) and
206204
sink.getTopLevel() = plugin.getTopLevel()
207205
)
208206
}
207+
208+
/**
209+
* Gets a property-write that writes a HTML-like constant string to `prop`.
210+
*/
211+
pragma[noinline]
212+
private DataFlow::PropWrite getALikelyHTMLWrite(string prop) {
213+
exists(string default |
214+
result.getRhs().mayHaveStringValue(default) and
215+
default.regexpMatch("\\s*<.*") and
216+
result.getPropertyName() = prop
217+
)
218+
}
209219
}

0 commit comments

Comments
 (0)