https://securitymb.github.io/xss/1/?xss=sink main.js

  1. url += `/xss/1/modules/${CONFIG.version}/${moduleName}.js`;
  2. const sc = document.createElement('script');
  3. sc.src = url;
  4. document.body.appendChild(sc);

无法检测URL是sink,如上所示:目前CodeQL可以识别如下所示的‘script’sc是SINK

const sc = document.createElement(‘script’); document.body.appendChild(sc);

javascript\ql\lib\semmle\javascript\security\dataflow\Xss.qll

  1. class DomSink extends Sink {
  2. DomSink() {
  3. // Call to a DOM function that inserts its argument into the DOM
  4. any(DomMethodCallExpr call).interpretsArgumentsAsHTML(this.asExpr())
  5. or
  6. // Assignment to a dangerous DOM property
  7. exists(DomPropWriteNode pw |
  8. pw.interpretsValueAsHTML() and
  9. this = DataFlow::valueNode(pw.getRhs())
  10. )
  11. or
  12. // `html` or `source.html` properties of React Native `WebView`
  13. exists(ReactNative::WebViewElement webView, DataFlow::SourceNode source |
  14. source = webView or
  15. source = webView.getAPropertyWrite("source").getRhs().getALocalSource()
  16. |
  17. this = source.getAPropertyWrite("html").getRhs()
  18. )
  19. }
  20. }

javascript\ql\lib\semmle\javascript\frameworks\Angular2.qll

  1. /** A value that is about to be promoted to a trusted HTML or CSS value. */
  2. private class AngularXssSink extends DomBasedXss::Sink {
  3. AngularXssSink() {
  4. this =
  5. domSanitizer()
  6. .getAMethodCall(["bypassSecurityTrustHtml", "bypassSecurityTrustStyle"])
  7. .getArgument(0)
  8. }
  9. }

javascript\ql\lib\semmle\javascript\frameworks\Cheerio.qll

  1. /**
  2. * XSS sink through `cheerio`.
  3. */
  4. class XssSink extends Xss::DomBasedXss::Sink {
  5. XssSink() {
  6. exists(string name | this = cheerioObjectRef().getAMethodCall(name).getAnArgument() |
  7. JQuery::isMethodArgumentInterpretedAsHtml(name)
  8. )
  9. }
  10. }

案例

https://hackerone.com/reports/602767