Skip to content

Commit fd10947

Browse files
committed
use small steps in TypeBackTracker correctly
1 parent 2aaedac commit fd10947

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

javascript/ql/lib/semmle/javascript/dataflow/TypeTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class TypeBackTracker extends TTypeBackTracker {
312312
* result = < some API call >.getArgument(< n >)
313313
* or
314314
* exists (DataFlow::TypeBackTracker t2 |
315-
* t = t2.smallstep(result, myType(t2))
315+
* t2 = t.smallstep(result, myType(t2))
316316
* )
317317
* }
318318
*

javascript/ql/lib/semmle/javascript/security/dataflow/UnsafeHtmlConstructionCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module UnsafeHtmlConstruction {
8080
t.start() and
8181
result = sink
8282
or
83-
exists(DataFlow::TypeBackTracker t2 | t = t2.smallstep(result, isUsedInXssSink(t2, sink)))
83+
exists(DataFlow::TypeBackTracker t2 | t2 = t.smallstep(result, isUsedInXssSink(t2, sink)))
8484
or
8585
exists(DataFlow::TypeBackTracker t2 |
8686
t.continue() = t2 and

javascript/ql/src/Security/CWE-094/ImproperCodeSanitization.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private DataFlow::Node endsInCodeInjectionSink(DataFlow::TypeBackTracker t) {
5050
not result instanceof StringOps::ConcatenationRoot // the heuristic CodeInjection sink looks for string-concats, we are not interrested in those here.
5151
)
5252
or
53-
exists(DataFlow::TypeBackTracker t2 | t = t2.smallstep(result, endsInCodeInjectionSink(t2)))
53+
exists(DataFlow::TypeBackTracker t2 | t2 = t.smallstep(result, endsInCodeInjectionSink(t2)))
5454
}
5555

5656
/**

javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/UnsafeHtmlConstruction.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ nodes
5050
| main.js:79:34:79:36 | val |
5151
| main.js:81:35:81:37 | val |
5252
| main.js:81:35:81:37 | val |
53+
| main.js:89:21:89:21 | x |
54+
| main.js:90:23:90:23 | x |
55+
| main.js:90:23:90:23 | x |
56+
| main.js:93:43:93:43 | x |
57+
| main.js:93:43:93:43 | x |
58+
| main.js:94:31:94:31 | x |
5359
| typed.ts:1:39:1:39 | s |
5460
| typed.ts:1:39:1:39 | s |
5561
| typed.ts:2:29:2:29 | s |
@@ -115,6 +121,11 @@ edges
115121
| main.js:79:34:79:36 | val | main.js:81:35:81:37 | val |
116122
| main.js:79:34:79:36 | val | main.js:81:35:81:37 | val |
117123
| main.js:79:34:79:36 | val | main.js:81:35:81:37 | val |
124+
| main.js:89:21:89:21 | x | main.js:90:23:90:23 | x |
125+
| main.js:89:21:89:21 | x | main.js:90:23:90:23 | x |
126+
| main.js:93:43:93:43 | x | main.js:94:31:94:31 | x |
127+
| main.js:93:43:93:43 | x | main.js:94:31:94:31 | x |
128+
| main.js:94:31:94:31 | x | main.js:89:21:89:21 | x |
118129
| typed.ts:1:39:1:39 | s | typed.ts:2:29:2:29 | s |
119130
| typed.ts:1:39:1:39 | s | typed.ts:2:29:2:29 | s |
120131
| typed.ts:1:39:1:39 | s | typed.ts:2:29:2:29 | s |
@@ -141,5 +152,6 @@ edges
141152
| main.js:62:19:62:31 | settings.name | main.js:56:28:56:34 | options | main.js:62:19:62:31 | settings.name | $@ based on $@ might later cause $@. | main.js:62:19:62:31 | settings.name | HTML construction | main.js:56:28:56:34 | options | library input | main.js:62:11:62:40 | "<b>" + ... "</b>" | cross-site scripting |
142153
| main.js:67:63:67:69 | attrVal | main.js:66:35:66:41 | attrVal | main.js:67:63:67:69 | attrVal | $@ based on $@ might later cause $@. | main.js:67:63:67:69 | attrVal | HTML construction | main.js:66:35:66:41 | attrVal | library input | main.js:67:47:67:78 | "<img a ... "\\"/>" | cross-site scripting |
143154
| main.js:81:35:81:37 | val | main.js:79:34:79:36 | val | main.js:81:35:81:37 | val | $@ based on $@ might later cause $@. | main.js:81:35:81:37 | val | HTML construction | main.js:79:34:79:36 | val | library input | main.js:81:24:81:49 | "<span> ... /span>" | cross-site scripting |
155+
| main.js:90:23:90:23 | x | main.js:93:43:93:43 | x | main.js:90:23:90:23 | x | $@ based on $@ might later cause $@. | main.js:90:23:90:23 | x | HTML construction | main.js:93:43:93:43 | x | library input | main.js:94:20:94:32 | createHTML(x) | cross-site scripting |
144156
| typed.ts:2:29:2:29 | s | typed.ts:1:39:1:39 | s | typed.ts:2:29:2:29 | s | $@ based on $@ might later cause $@. | typed.ts:2:29:2:29 | s | HTML construction | typed.ts:1:39:1:39 | s | library input | typed.ts:3:31:3:34 | html | cross-site scripting |
145157
| typed.ts:8:40:8:40 | s | typed.ts:6:43:6:43 | s | typed.ts:8:40:8:40 | s | $@ based on $@ might later cause $@. | typed.ts:8:40:8:40 | s | HTML construction | typed.ts:6:43:6:43 | s | library input | typed.ts:8:29:8:52 | "<span> ... /span>" | cross-site scripting |

javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,11 @@ module.exports.types = function (val) {
8585
$("#foo").html("<span>" + val + "</span>"); // OK
8686
}
8787
}
88+
89+
function createHTML(x) {
90+
return "<span>" + x + "</span>"; // NOT OK
91+
}
92+
93+
module.exports.usesCreateHTML = function (x) {
94+
$("#foo").html(createHTML(x));
95+
}

0 commit comments

Comments
 (0)