Skip to content

Commit e9ebba3

Browse files
committed
assume shell=False for subprocess calls, fixes FPs in e.g. youtube-dl
1 parent d228cf0 commit e9ebba3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

python/ql/lib/semmle/python/frameworks/Stdlib.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ private module StdlibPrivate {
12091209
this.get_shell_arg().getAValueReachingSink().asExpr().(ImmutableLiteral).booleanValue()
12101210
or
12111211
not this.get_shell_arg().getAValueReachingSink().asExpr() instanceof ImmutableLiteral and
1212-
result = [true, false]
1212+
result = false // defaults to `False`
12131213
}
12141214

12151215
/** Gets the API-node for the `executable` argument, if any. */

python/ql/test/query-tests/Security/CWE-078-UnsafeShellCommandConstruction/src/unsafe_shell_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ def subprocess_flag (name):
4141
def indirect(flag, x):
4242
subprocess.run("ping " + x, shell=flag) # $result=BAD
4343

44-
indirect(True, name)
44+
indirect(True, name)
45+
46+
subprocess.Popen("ping " + name, shell=unknownValue) # OK - shell assumed to be False

0 commit comments

Comments
 (0)