Skip to content

Commit 46f88e7

Browse files
committed
JS: Updates to DOM model
1 parent 48db2b9 commit 46f88e7

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

javascript/ql/lib/semmle/javascript/DOM.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ module DOM {
247247
]
248248
|
249249
(
250-
result = documentRef().getAMethodCall(collectionName) or
250+
result = domValueRef().getAMethodCall(collectionName) or
251251
result = DataFlow::globalVarRef(collectionName).getACall()
252252
)
253253
)
@@ -441,10 +441,12 @@ module DOM {
441441
DataFlow::SourceNode domValueRef() {
442442
result = domValueRef(DataFlow::TypeTracker::end())
443443
or
444-
result.hasUnderlyingType("Element")
444+
result.hasUnderlyingType(["Element", "HTMLCollection", "HTMLCollectionOf"])
445445
or
446446
result.hasUnderlyingType(any(string s | s.matches("HTML%Element")))
447447
or
448+
result = documentRef()
449+
or
448450
exists(DataFlow::ClassNode cls |
449451
cls.getASuperClassNode().getALocalSource() =
450452
DataFlow::globalVarRef(any(string s | s.matches("HTML%Element"))) and

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
| dates.js:57:31:57:101 | `Time i ... aint)}` | dates.js:54:36:54:55 | window.location.hash | dates.js:57:31:57:101 | `Time i ... aint)}` | Cross-site scripting vulnerability due to $@. | dates.js:54:36:54:55 | window.location.hash | user-provided value |
5454
| dates.js:59:31:59:87 | `Time i ... aint)}` | dates.js:54:36:54:55 | window.location.hash | dates.js:59:31:59:87 | `Time i ... aint)}` | Cross-site scripting vulnerability due to $@. | dates.js:54:36:54:55 | window.location.hash | user-provided value |
5555
| dates.js:61:31:61:88 | `Time i ... aint)}` | dates.js:54:36:54:55 | window.location.hash | dates.js:61:31:61:88 | `Time i ... aint)}` | Cross-site scripting vulnerability due to $@. | dates.js:54:36:54:55 | window.location.hash | user-provided value |
56+
| dom.js:4:20:4:30 | window.name | dom.js:4:20:4:30 | window.name | dom.js:4:20:4:30 | window.name | Cross-site scripting vulnerability due to $@. | dom.js:4:20:4:30 | window.name | user-provided value |
5657
| dragAndDrop.ts:15:25:15:28 | html | dragAndDrop.ts:8:18:8:50 | dataTra ... /html') | dragAndDrop.ts:15:25:15:28 | html | Cross-site scripting vulnerability due to $@. | dragAndDrop.ts:8:18:8:50 | dataTra ... /html') | user-provided value |
5758
| dragAndDrop.ts:24:23:24:57 | e.dataT ... /html') | dragAndDrop.ts:24:23:24:57 | e.dataT ... /html') | dragAndDrop.ts:24:23:24:57 | e.dataT ... /html') | Cross-site scripting vulnerability due to $@. | dragAndDrop.ts:24:23:24:57 | e.dataT ... /html') | user-provided value |
5859
| dragAndDrop.ts:29:19:29:53 | e.dataT ... /html') | dragAndDrop.ts:29:19:29:53 | e.dataT ... /html') | dragAndDrop.ts:29:19:29:53 | e.dataT ... /html') | Cross-site scripting vulnerability due to $@. | dragAndDrop.ts:29:19:29:53 | e.dataT ... /html') | user-provided value |
@@ -937,6 +938,7 @@ nodes
937938
| dates.js:61:31:61:88 | `Time i ... aint)}` | semmle.label | `Time i ... aint)}` |
938939
| dates.js:61:42:61:86 | dayjs.s ... (taint) | semmle.label | dayjs.s ... (taint) |
939940
| dates.js:61:81:61:85 | taint | semmle.label | taint |
941+
| dom.js:4:20:4:30 | window.name | semmle.label | window.name |
940942
| dragAndDrop.ts:8:11:8:50 | html | semmle.label | html |
941943
| dragAndDrop.ts:8:18:8:50 | dataTra ... /html') | semmle.label | dataTra ... /html') |
942944
| dragAndDrop.ts:15:25:15:28 | html | semmle.label | html |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ nodes
138138
| dates.js:61:31:61:88 | `Time i ... aint)}` | semmle.label | `Time i ... aint)}` |
139139
| dates.js:61:42:61:86 | dayjs.s ... (taint) | semmle.label | dayjs.s ... (taint) |
140140
| dates.js:61:81:61:85 | taint | semmle.label | taint |
141+
| dom.js:4:20:4:30 | window.name | semmle.label | window.name |
141142
| dragAndDrop.ts:8:11:8:50 | html | semmle.label | html |
142143
| dragAndDrop.ts:8:18:8:50 | dataTra ... /html') | semmle.label | dataTra ... /html') |
143144
| dragAndDrop.ts:15:25:15:28 | html | semmle.label | html |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function t1() {
22
const elm = document.getElementById("foo");
33
const e2 = elm.getElementsByTagName("bar")[0];
4-
e2.innerHTML = window.name; // $ MISSING: Alert
4+
e2.innerHTML = window.name; // $ Alert
55
}

0 commit comments

Comments
 (0)