12
12
import TempDirUtils
13
13
import DataFlow:: PathGraph
14
14
15
- private class MethodFileSystemCreation extends Method {
16
- MethodFileSystemCreation ( ) {
15
+ private class MethodFileSystemFileCreation extends Method {
16
+ MethodFileSystemFileCreation ( ) {
17
17
getDeclaringType ( ) instanceof TypeFile and
18
18
(
19
19
hasName ( "mkdir" ) or
@@ -22,6 +22,33 @@ private class MethodFileSystemCreation extends Method {
22
22
}
23
23
}
24
24
25
+ private class MethodFilesSystemFileCreation extends Method {
26
+ MethodFilesSystemFileCreation ( ) {
27
+ getDeclaringType ( ) .hasQualifiedName ( "java.nio.file" , "Files" ) and
28
+ hasName ( "write" )
29
+ }
30
+ }
31
+
32
+ private abstract class FileCreationSink extends DataFlow:: Node { }
33
+
34
+ private class FileFileCreationSink extends FileCreationSink {
35
+ FileFileCreationSink ( ) {
36
+ exists ( MethodAccess ma |
37
+ ma .getMethod ( ) instanceof MethodFileSystemFileCreation and
38
+ ma .getQualifier ( ) = this .asExpr ( )
39
+ )
40
+ }
41
+ }
42
+
43
+ private class FilesFileCreationSink extends FileCreationSink {
44
+ FilesFileCreationSink ( ) {
45
+ exists ( MethodAccess ma |
46
+ ma .getMethod ( ) instanceof MethodFilesSystemFileCreation and
47
+ ma .getArgument ( 0 ) = this .asExpr ( )
48
+ )
49
+ }
50
+ }
51
+
25
52
private class TempDirSystemGetPropertyToCreateConfig extends TaintTracking:: Configuration {
26
53
TempDirSystemGetPropertyToCreateConfig ( ) { this = "TempDirSystemGetPropertyToCreateConfig" }
27
54
@@ -34,15 +61,12 @@ private class TempDirSystemGetPropertyToCreateConfig extends TaintTracking::Conf
34
61
}
35
62
36
63
override predicate isSink ( DataFlow:: Node sink ) {
37
- exists ( MethodAccess ma |
38
- ma .getMethod ( ) instanceof MethodFileSystemCreation and
39
- ma .getQualifier ( ) = sink .asExpr ( )
40
- )
64
+ sink instanceof FileCreationSink
41
65
}
42
66
}
43
67
44
68
from DataFlow:: PathNode source , DataFlow:: PathNode sink , TempDirSystemGetPropertyToCreateConfig conf
45
69
where conf .hasFlowPath ( source , sink )
46
70
select source .getNode ( ) , source , sink ,
47
- "Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users." , source . getNode ( ) ,
48
- "system temp directory"
71
+ "Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users." ,
72
+ source . getNode ( ) , "system temp directory"
0 commit comments