File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
src/semmle/javascript/frameworks
test/library-tests/TaintTracking Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,22 @@ module NodeJSLib {
297297 override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
298298 pred = tainted and succ = this
299299 }
300+ }
301+
302+ /**
303+ * A model of taint propagation through `new Buffer` and `Buffer.from`.
304+ */
305+ private class BufferTaintStep extends TaintTracking:: AdditionalTaintStep , DataFlow:: InvokeNode {
306+ BufferTaintStep ( ) {
307+ this = DataFlow:: globalVarRef ( "Buffer" ) .getAnInstantiation ( )
308+ or
309+ this = DataFlow:: globalVarRef ( "Buffer" ) .getAMemberInvocation ( "from" )
310+ }
300311
312+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
313+ pred = getArgument ( 0 ) and
314+ succ = this
315+ }
301316 }
302317
303318 /**
Original file line number Diff line number Diff line change 2323| tst.js:2:13:2:20 | source() | tst.js:41:14:41:16 | ary |
2424| tst.js:2:13:2:20 | source() | tst.js:44:10:44:30 | innocen ... ) => x) |
2525| tst.js:2:13:2:20 | source() | tst.js:45:10:45:24 | x.map(x2 => x2) |
26+ | tst.js:2:13:2:20 | source() | tst.js:47:10:47:30 | Buffer. ... 'hex') |
27+ | tst.js:2:13:2:20 | source() | tst.js:48:10:48:22 | new Buffer(x) |
Original file line number Diff line number Diff line change @@ -44,4 +44,6 @@ function test() {
4444 sink ( innocent . map ( ( ) => x ) ) ; // NOT OK
4545 sink ( x . map ( x2 => x2 ) ) ; // NOT OK
4646
47+ sink ( Buffer . from ( x , 'hex' ) ) ; // NOT OK
48+ sink ( new Buffer ( x ) ) ; // NOT OK
4749}
You can’t perform that action at this time.
0 commit comments