@ -22,6 +22,7 @@ let sources = [
ret_type = " java.lang.Object " ;
params = [] ;
is_static = true ;
taint_kind = Sil . Tk_unknown ;
language = Config . Java ;
} ;
{
@ -30,6 +31,7 @@ let sources = [
ret_type = " java.lang.Object " ;
params = [] ;
is_static = true ;
taint_kind = Sil . Tk_unknown ;
language = Config . Java
} ;
(* actual specs *)
@ -39,6 +41,7 @@ let sources = [
ret_type = " java.lang.String " ;
params = [ " java.lang.String " ; " java.lang.String " ] ;
is_static = false ;
taint_kind = Sil . Tk_shared_preferences_data ;
language = Config . Java
} ;
] @ FbTaint . sources
@ -54,6 +57,7 @@ let sinks = [
ret_type = " void " ;
params = [ " java.lang.Object " ] ;
is_static = true ;
taint_kind = Sil . Tk_unknown ;
language = Config . Java
} , [ 0 ] ) ;
( {
@ -62,6 +66,7 @@ let sinks = [
ret_type = " void " ;
params = [ " java.lang.Object " ] ;
is_static = true ;
taint_kind = Sil . Tk_unknown ;
language = Config . Java
} , [ 0 ] ) ;
(* actual specs *)
@ -71,6 +76,7 @@ let sinks = [
ret_type = " int " ;
params = [ " java.lang.String " ; " java.lang.String " ] ;
is_static = true ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java
} , [ 0 ; 1 ] ) ;
( {
@ -79,6 +85,7 @@ let sinks = [
ret_type = " java.io.InputStream " ;
params = [ " android.net.Uri " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 1 ] ) ;
( {
@ -87,6 +94,7 @@ let sinks = [
ret_type = " java.io.OutputStream " ;
params = [ " android.net.Uri " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 0 ] ) ;
( {
@ -95,6 +103,7 @@ let sinks = [
ret_type = " java.io.OutputStream " ;
params = [ " android.net.Uri " ; " java.lang.String " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 0 ] ) ;
( {
@ -103,6 +112,7 @@ let sinks = [
ret_type = " android.content.res.AssetFileDescriptor " ;
params = [ " android.net.Uri " ; " java.lang.String " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 0 ] ) ;
( {
@ -111,6 +121,7 @@ let sinks = [
ret_type = " android.content.res.AssetFileDescriptor " ;
params = [ " android.net.Uri " ; " java.lang.String " ; " android.os.CancellationSignal " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 0 ] ) ;
( {
@ -119,6 +130,7 @@ let sinks = [
ret_type = " android.os.ParcelFileDescriptor " ;
params = [ " android.net.Uri " ; " java.lang.String " ; " android.os.CancellationSignal " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 0 ] ) ;
( {
@ -127,6 +139,7 @@ let sinks = [
ret_type = " android.os.ParcelFileDescriptor " ;
params = [ " android.net.Uri " ; " java.lang.String " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 0 ] ) ;
( {
@ -136,6 +149,7 @@ let sinks = [
params = [ " android.net.Uri " ; " java.lang.String " ; " android.os.Bundle " ;
" android.os.CancellationSignal " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 0 ] ) ;
( {
@ -144,6 +158,7 @@ let sinks = [
ret_type = " android.content.res.AssetFileDescriptor " ;
params = [ " android.net.Uri " ; " java.lang.String " ; " android.os.Bundle " ] ;
is_static = false ;
taint_kind = Sil . Tk_privacy_annotation ;
language = Config . Java ;
} , [ 0 ] ) ;
@ -154,7 +169,8 @@ let sinks = [
ret_type = " void " ;
params = [] ;
is_static = false ;
language = Config . Clang
taint_kind = Sil . Tk_unknown ;
language = Config . Clang ;
} , [ 1 ] ) ; (* it's instance method *)
] @ FbTaint . sinks
@ -166,7 +182,8 @@ let functions_with_tainted_params = [
ret_type = " BOOL " ;
params = [] ;
is_static = false ; (* it's instance method *)
language = Config . Clang
taint_kind = Sil . Tk_unknown ;
language = Config . Clang ;
} , [ 2 ] ) ;
(* actual specs *)
@ -180,7 +197,8 @@ let functions_with_tainted_params = [
ret_type = " BOOL " ;
params = [] ;
is_static = false ; (* it's instance method *)
language = Config . Clang
taint_kind = Sil . Tk_integrity_annotation ;
language = Config . Clang ;
} , [ 2 ] ) ;
] @ FbTaint . functions_with_tainted_params
@ -208,12 +226,19 @@ let method_str_to_pname method_str =
| Config . Java ->
java_method_to_procname method_str
let taint_spec_to_taint_info taint_spec =
let taint_source =
match taint_spec . language with
| Config . Clang -> objc_method_to_procname taint_spec
| Config . Java -> java_method_to_procname taint_spec in
{ Sil . taint_source ; taint_kind = taint_spec . taint_kind }
let sources =
IList . map method_str_to_pname sources
IList . map taint_spec_to_taint_info sources
let mk_pname_param_num methods =
IList . map
( fun ( mname , param_num ) -> method_str_to_pname mname , param_num )
( fun ( mname , param_num ) -> taint_spec_to_taint_info mname , param_num )
methods
let taint_sinks =
@ -226,16 +251,28 @@ let attrs_opt_get_annots = function
| Some attrs -> attrs . ProcAttributes . method_annotation
| None -> Sil . method_annotation_empty
(* TODO: return a taint kind *)
(* * returns true if [callee_pname] returns a tainted value *)
let returns_tainted callee_pname callee_attrs_opt =
IList . exists ( fun pname -> Procname . equal pname callee_pname ) sources | |
let ret_annot , _ = attrs_opt_get_annots callee_attrs_opt in
Annotations . ia_is_privacy_source ret_annot | |
Annotations . ia_is_integrity_source ret_annot
let procname_matches taint_info =
Procname . equal taint_info . Sil . taint_source callee_pname in
try
let taint_info = IList . find procname_matches sources in
Some taint_info . Sil . taint_kind
with Not_found ->
let ret_annot , _ = attrs_opt_get_annots callee_attrs_opt in
if Annotations . ia_is_integrity_source ret_annot
then Some Sil . Tk_integrity_annotation
else if Annotations . ia_is_privacy_source ret_annot
then Some Sil . Tk_privacy_annotation
else None
let find_callee methods callee_pname =
let find_callee taint_info s callee_pname =
try
snd ( IList . find ( fun ( pname , _ ) -> Procname . equal pname callee_pname ) methods )
IList . find
( fun ( taint_info , _ ) -> Procname . equal taint_info . Sil . taint_source callee_pname )
taint_infos
| > snd
with Not_found -> []
(* * returns list of zero-indexed argument numbers of [callee_pname] that may be tainted *)
@ -247,7 +284,7 @@ let accepts_sensitive_params callee_pname callee_attrs_opt =
IList . mapi ( fun param_num attr -> ( param_num + offset , attr ) ) param_annots
| > IList . filter
( fun ( _ , attr ) ->
Annotations . ia_is_ privacy_sink attr | | Annotations . ia_is_integrit y_sink attr )
Annotations . ia_is_ integrity_sink attr | | Annotations . ia_is_privac y_sink attr )
| > IList . map fst
| tainted_params -> tainted_params