1212import TempDirUtils
1313import DataFlow:: PathGraph
1414
15- private class MethodFileSystemCreation extends Method {
16- MethodFileSystemCreation ( ) {
15+ private class MethodFileSystemFileCreation extends Method {
16+ MethodFileSystemFileCreation ( ) {
1717 getDeclaringType ( ) instanceof TypeFile and
1818 (
1919 hasName ( "mkdir" ) or
@@ -22,6 +22,33 @@ private class MethodFileSystemCreation extends Method {
2222 }
2323}
2424
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+
2552private class TempDirSystemGetPropertyToCreateConfig extends TaintTracking:: Configuration {
2653 TempDirSystemGetPropertyToCreateConfig ( ) { this = "TempDirSystemGetPropertyToCreateConfig" }
2754
@@ -34,15 +61,12 @@ private class TempDirSystemGetPropertyToCreateConfig extends TaintTracking::Conf
3461 }
3562
3663 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
4165 }
4266}
4367
4468from DataFlow:: PathNode source , DataFlow:: PathNode sink , TempDirSystemGetPropertyToCreateConfig conf
4569where conf .hasFlowPath ( source , sink )
4670select 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