@@ -36,43 +36,4 @@ module CommandInjection {
3636 override predicate isSanitizer ( DataFlow:: Node node ) { node instanceof Sanitizer }
3737 }
3838
39- /**
40- * Auxiliary data flow configuration for tracking string literals that look like they
41- * may refer to an operating system shell, and array literals that may end up being
42- * interpreted as argument lists for system commands.
43- */
44- class ArgumentListTracking extends DataFlow:: Configuration {
45- ArgumentListTracking ( ) { this = "ArgumentListTracking" }
46-
47- override predicate isSource ( DataFlow:: Node nd ) {
48- nd instanceof DataFlow:: ArrayCreationNode
49- or
50- exists ( ConstantString shell | shellCmd ( shell , _) | nd = DataFlow:: valueNode ( shell ) )
51- }
52-
53- override predicate isSink ( DataFlow:: Node nd ) {
54- exists ( SystemCommandExecution sys |
55- nd = sys .getACommandArgument ( ) or
56- nd = sys .getArgumentList ( )
57- )
58- }
59- }
60-
61- /**
62- * Holds if `shell arg <cmd>` runs `<cmd>` as a shell command.
63- *
64- * That is, either `shell` is a Unix shell (`sh` or similar) and
65- * `arg` is `"-c"`, or `shell` is `cmd.exe` and `arg` is `"/c"`.
66- */
67- private predicate shellCmd ( ConstantString shell , string arg ) {
68- exists ( string s | s = shell .getStringValue ( ) |
69- ( s = "sh" or s = "bash" or s = "/bin/sh" or s = "/bin/bash" ) and
70- arg = "-c"
71- )
72- or
73- exists ( string s | s = shell .getStringValue ( ) .toLowerCase ( ) |
74- ( s = "cmd" or s = "cmd.exe" ) and
75- ( arg = "/c" or arg = "/C" )
76- )
77- }
7839}
0 commit comments