File tree Expand file tree Collapse file tree
javascript/ql/src/semmle/javascript Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ class JsonStringifyCall extends DataFlow::CallNode {
2525 callee = DataFlow:: moduleMember ( "util" , "inspect" ) or
2626 callee = DataFlow:: moduleImport ( [ "pretty-format" , "object-inspect" ] )
2727 )
28+ or
29+ this = Templating:: getAPipeCall ( [ "json" , "dump" ] )
2830 }
2931
3032 /**
Original file line number Diff line number Diff line change @@ -531,4 +531,15 @@ module Templating {
531531 not file .getExtension ( ) = any ( TemplateSyntax s ) .getAFileExtension ( ) and
532532 result = getTemplateSyntaxInFolder ( file .getParentContainer ( ) )
533533 }
534+
535+ /** A step through the `safe` pipe, which bypasses HTML escaping. */
536+ private class SafePipeStep extends TaintTracking:: SharedTaintStep {
537+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
538+ exists ( DataFlow:: CallNode call |
539+ call = getAPipeCall ( "safe" ) and
540+ pred = call .getArgument ( 0 ) and
541+ succ = call
542+ )
543+ }
544+ }
534545}
Original file line number Diff line number Diff line change @@ -381,6 +381,16 @@ module DomBasedXss {
381381 }
382382 }
383383
384+ /**
385+ * A value being piped into the `safe` pipe in a template file,
386+ * disabling subsequent HTML escaping.
387+ */
388+ class SafePipe extends DomBasedXss:: Sink {
389+ SafePipe ( ) {
390+ this = Templating:: getAPipeCall ( "safe" ) .getArgument ( 0 )
391+ }
392+ }
393+
384394 /**
385395 * A property read from a safe property is considered a sanitizer.
386396 */
You can’t perform that action at this time.
0 commit comments