Python: Better handling of sensitive functions

This solution was the best I could come up with, but it _is_ a bit
brittle since you need to remember to add this additional taint step
to any configuration that relies on sensitive data sources... I don't
see an easy way around this though :|
This commit is contained in:
Rasmus Wriedt Larsen
2021-06-10 15:07:03 +02:00
parent f167143a84
commit ea0c1d7db3
4 changed files with 60 additions and 6 deletions

View File

@@ -40,6 +40,10 @@ class SensitiveUseConfiguration extends TaintTracking::Configuration {
override predicate isSink(DataFlow::Node node) {
node = API::builtin("print").getACall().getArg(_)
}
override predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
sensitiveDataExtraStepForCalls(node1, node2)
}
}
// import DataFlow::PathGraph
// from SensitiveUseConfiguration cfg, DataFlow::PathNode source, DataFlow::PathNode sink

View File

@@ -29,17 +29,17 @@ x = unkown_func_not_even_imported_get_password() # $ SensitiveDataSource=passwor
print(x) # $ SensitiveUse=password
f = get_passwd
x = f() # $ MISSING: SensitiveDataSource=password
print(x) # $ MISSING: SensitiveUse=password
x = f()
print(x) # $ SensitiveUse=password
import not_found
f = not_found.get_passwd # $ SensitiveDataSource=password
x = f() # $ MISSING: SensitiveDataSource=password
print(x) # $ MISSING: SensitiveUse=password
x = f()
print(x) # $ SensitiveUse=password
def my_func(non_sensitive_name):
x = non_sensitive_name() # $ MISSING: SensitiveDataSource=password
print(x) # $ MISSING: SensitiveUse=password
x = non_sensitive_name()
print(x) # $ SensitiveUse=password
f = not_found.get_passwd # $ SensitiveDataSource=password
my_func(f)