@@ -19,6 +19,16 @@ abstract class SafeExternalApiFunction extends Function { }
19
19
/** DEPRECATED: Alias for SafeExternalApiFunction */
20
20
deprecated class SafeExternalAPIFunction = SafeExternalApiFunction ;
21
21
22
+ /**
23
+ * A `Function` with one or more arguments that are considered "safe" from a security perspective.
24
+ */
25
+ abstract class SafeExternalApiArgument extends Function {
26
+ /**
27
+ * Holds if `i` is a safe argument to this function.
28
+ */
29
+ abstract predicate isSafeArgument ( int i ) ;
30
+ }
31
+
22
32
private predicate isDefaultSafePackage ( Package package ) {
23
33
package .getPath ( ) in [ "time" , "unicode/utf8" , package ( "gopkg.in/go-playground/validator" , "" ) ]
24
34
}
@@ -44,6 +54,16 @@ private class DefaultSafeExternalApiFunction extends SafeExternalApiFunction {
44
54
}
45
55
}
46
56
57
+ private class DefaultSafeExternalApiFunctionArgument extends SafeExternalApiArgument {
58
+ int index ;
59
+
60
+ DefaultSafeExternalApiFunctionArgument ( ) {
61
+ this .( Method ) .hasQualifiedName ( "net/http" , "Header" , [ "Set" , "Del" ] ) and index = - 1
62
+ }
63
+
64
+ override predicate isSafeArgument ( int i ) { i = index }
65
+ }
66
+
47
67
/** Holds if `callNode` is a local function pointer. */
48
68
private predicate isProbableLocalFunctionPointer ( DataFlow:: CallNode callNode ) {
49
69
// Not a method call
@@ -77,7 +97,9 @@ class ExternalApiDataNode extends DataFlow::Node {
77
97
// Not already modeled as a taint step
78
98
not TaintTracking:: localTaintStep ( this , _) and
79
99
// Not a call to a known safe external API
80
- not call .getTarget ( ) instanceof SafeExternalApiFunction
100
+ not call .getTarget ( ) instanceof SafeExternalApiFunction and
101
+ // Not a known safe argument to an external API
102
+ not any ( SafeExternalApiArgument seaa ) .isSafeArgument ( i )
81
103
}
82
104
83
105
/** Gets the called API `Function`. */
0 commit comments