mirror of
				https://github.com/SimpleMobileTools/Simple-File-Manager.git
				synced 2025-06-05 22:09:15 +02:00 
			
		
		
		
	add zip path traversal vulnerability check for zip decompression
This commit is contained in:
		| @@ -78,7 +78,7 @@ android { | |||||||
| } | } | ||||||
|  |  | ||||||
| dependencies { | dependencies { | ||||||
|     implementation 'com.github.fatihergin:Simple-Commons:fe7a01274a' // TODO: do not replace it with SimpleMobileTools |     implementation 'com.github.SimpleMobileTools:Simple-Commons:d1629c7f1a' | ||||||
|     implementation 'com.github.tibbi:AndroidPdfViewer:e6a533125b' |     implementation 'com.github.tibbi:AndroidPdfViewer:e6a533125b' | ||||||
|     implementation 'com.github.Stericson:RootTools:df729dcb13' |     implementation 'com.github.Stericson:RootTools:df729dcb13' | ||||||
|     implementation 'com.github.Stericson:RootShell:1.6' |     implementation 'com.github.Stericson:RootShell:1.6' | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ import net.lingala.zip4j.exception.ZipException.Type | |||||||
| import net.lingala.zip4j.io.inputstream.ZipInputStream | import net.lingala.zip4j.io.inputstream.ZipInputStream | ||||||
| import net.lingala.zip4j.model.LocalFileHeader | import net.lingala.zip4j.model.LocalFileHeader | ||||||
| import java.io.BufferedInputStream | import java.io.BufferedInputStream | ||||||
|  | import java.io.File | ||||||
|  |  | ||||||
| class DecompressActivity : SimpleActivity() { | class DecompressActivity : SimpleActivity() { | ||||||
|     companion object { |     companion object { | ||||||
| @@ -145,6 +146,11 @@ class DecompressActivity : SimpleActivity() { | |||||||
|                         continue |                         continue | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|  |                     val isVulnerableForZipPathTraversal = !File(newPath).canonicalPath.startsWith(parent) | ||||||
|  |                     if (isVulnerableForZipPathTraversal) { | ||||||
|  |                         continue | ||||||
|  |                     } | ||||||
|  |  | ||||||
|                     val fos = getFileOutputStreamSync(newPath, newPath.getMimeType()) |                     val fos = getFileOutputStreamSync(newPath, newPath.getMimeType()) | ||||||
|                     var count: Int |                     var count: Int | ||||||
|                     while (true) { |                     while (true) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user