File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
lib/semmle/javascript/frameworks
test/query-tests/Security/CWE-022/TaintedPath Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,23 @@ module TaintStep {
5252 /**
5353 * Holds if there's a step from `pred` to `succ` due to templating data being
5454 * passed from a templating call to a registered helper via a parameter.
55+ *
56+ * To establish the step, we look at the template passed to `compile`, and will
57+ * only track steps from templates to helpers they actually reference.
58+ *
59+ * ```javascript
60+ * function loudHelper(text) {
61+ * // ^^^^ succ
62+ * return text.toUpperCase();
63+ * }
64+ *
65+ * hb.registerHelper("loud", loudHelper);
66+ *
67+ * const template = hb.compile("Hello, {{loud name}}!");
68+ *
69+ * template({name: "user"});
70+ * // ^^^^^^ pred
71+ * ```
5572 */
5673 private predicate isHandlebarsArgStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
5774 exists ( string helperName |
Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ const app = express();
77const data = { } ;
88
99function init ( ) {
10+ hb . registerHelper ( "catFile" , catFile ) ;
1011 data . compiledFileAccess = hb . compile ( "contents of file {{path}} are: {{catFile path}}" )
1112 data . compiledBenign = hb . compile ( "hello, {{name}}" ) ;
1213 data . compiledUnknown = hb . compile ( fs . readFileSync ( "greeting.template" ) ) ;
13- hb . registerHelper ( "catFile" , catFile ) ;
1414}
1515
1616init ( ) ;
You can’t perform that action at this time.
0 commit comments