File tree 4 files changed +91
-0
lines changed
regression/end_to_end/taint_array_from_elements
4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change
1
+ <project name =" taint_array_from_elements" basedir =" ." default =" jar" >
2
+
3
+ <property name =" root.dir" value =" ./" />
4
+ <property name =" src.dir" value =" ${ root.dir } /src" />
5
+ <property name =" classes.dir" value =" ${ root.dir } /build" />
6
+ <property name =" install.dir" value =" ${ root.dir } /dist" />
7
+
8
+ <target name =" jar" >
9
+ <antcall target =" compile" />
10
+ <mkdir dir =" ${ install.dir } " />
11
+ <jar destfile =" ${ install.dir } /taint_array_from_elements.jar" basedir =" ${ classes.dir } " />
12
+ </target >
13
+
14
+ <target name =" compile" >
15
+ <antcall target =" clean" />
16
+ <mkdir dir =" ${ classes.dir } " />
17
+ <javac srcdir =" ${ src.dir } " destdir =" ${ classes.dir } " includeantruntime =" false" debug =" on" >
18
+ </javac >
19
+ </target >
20
+
21
+ <target name =" clean" >
22
+ <delete dir =" ${ classes.dir } " />
23
+ <delete dir =" ${ install.dir } " />
24
+ </target >
25
+
26
+
27
+ </project >
28
+
29
+
Original file line number Diff line number Diff line change
1
+ {
2
+ "namespace" : " com.diffblue.security" ,
3
+ "rules" :
4
+ [
5
+ {
6
+ "comment" : " Obtaining tainted data." ,
7
+ "class" : " Main" ,
8
+ "method" : " makeTainted:(Ljava/lang/Object;)V" ,
9
+ "result" : {
10
+ "location" : " arg0" ,
11
+ "taint" : " Tainted data"
12
+ }
13
+ },
14
+ {
15
+ "comment" : " Writing potentially tainted array to a sink." ,
16
+ "class" : " Main" ,
17
+ "method" : " sink:([Ljava/lang/Object;)V" ,
18
+ "sinkTarget" : {
19
+ "location" : " arg0" ,
20
+ "vulnerability" : " Tainted array"
21
+ }
22
+ }
23
+ ]
24
+ }
25
+
26
+
Original file line number Diff line number Diff line change
1
+ public class Main {
2
+ private static void makeTainted (Object o ) {}
3
+ private static void sink (Object ... o ) {}
4
+ public static void main (boolean nondet ) {
5
+ Object bar = new Object ();
6
+ makeTainted (bar );
7
+ Object [] obj = { new Object (), bar };
8
+ sink (obj );
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ import regression .end_to_end .driver as pipeline_executor
2
+ import os
3
+ import subprocess
4
+ import pytest
5
+ import regression .utils as utils
6
+
7
+
8
+ @pytest .mark .xfail (strict = True )
9
+ def test_taint_array_from_elements ():
10
+ """
11
+ The test shows a weakness of specification of taint propagation, when
12
+ an array is assigned a tainted data to some its element and then the
13
+ whole array is delivered to a sink. The problem is that we are
14
+ currently unable to define a rule which would make the array tainted
15
+ when some its element is assigned a tainted data. The cause is that
16
+ array element update is an assignment statement and rules are related
17
+ to function calls.
18
+ """
19
+ with utils .working_dir (os .path .abspath (os .path .dirname (__file__ ))):
20
+ subprocess .call ("ant" )
21
+ traces = pipeline_executor .run_security_analyser_pipeline (
22
+ os .path .join ("dist" , "taint_array_from_elements.jar" ),
23
+ "rules.json" ,
24
+ os .path .realpath (os .path .dirname (__file__ )))
25
+ assert traces .count_traces () == 1
26
+ assert traces .trace_exists ("java::Main.postBytes:(LData;LOStream;)V" , 8 )
You can’t perform that action at this time.
0 commit comments