JS: introduce Vue XSS sinks

This commit is contained in:
Esben Sparre Andreasen
2019-01-25 12:32:39 +01:00
parent a6cfee5f26
commit ea175b2a9f
4 changed files with 28 additions and 2 deletions

View File

@@ -3,7 +3,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.DomBasedXss
module Vue {
/**
@@ -372,5 +371,4 @@ module Vue {
* A `.vue` file.
*/
class VueFile extends File { VueFile() { getExtension() = "vue" } }
}

View File

@@ -188,4 +188,26 @@ module DomBasedXss {
override string getVulnerabilityKind() { result = "HTML injection" }
}
/**
* A write to the `template` option of a Vue instance, viewed as an XSS sink.
*/
class VueTemplateSink extends DomBasedXss::Sink {
VueTemplateSink() { this = any(Vue::Instance i).getTemplate() }
}
/**
* The tag name argument to the `createElement` parameter of the
* `render` method of a Vue instance, viewed as an XSS sink.
*/
class VueCreateElementSink extends DomBasedXss::Sink {
VueCreateElementSink() {
exists(Vue::Instance i, DataFlow::FunctionNode f |
f.flowsTo(i.getRender()) and
this = f.getParameter(0).getACall().getArgument(0)
)
}
}
}

View File

@@ -0,0 +1,2 @@
| tst.js:5:13:5:13 | a |
| tst.js:38:12:38:17 | danger |

View File

@@ -0,0 +1,4 @@
import javascript
import semmle.javascript.security.dataflow.DomBasedXss
select any(DomBasedXss::Sink s)