Каковы некоторые возможные причины «уязвимости обхода zip path, возникают только в Android 11?JAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Каковы некоторые возможные причины «уязвимости обхода zip path, возникают только в Android 11?

Сообщение Anonymous »

На основе https://support.google.com/faqs/answer/9294009 мы реализуем обнаружение «Уязвимость обхода Zip Path Traversal» в нашем коде.
SecurityException ("https://support.google.com/faqs/answer/9294009"); явно, когда мы сталкиваемся с "Zip Path Traversal уязвимость" . 11. < /p>

Код: Выделить всё

public static boolean extractZipFile(InputStream inputStream, String destDirectory, boolean overwrite) {
ZipInputStream zipInputStream = null;
boolean status = true;

try {
zipInputStream = new ZipInputStream(inputStream);
final byte[] data = new byte[1024];

while (true) {
ZipEntry zipEntry = null;
FileOutputStream outputStream = null;

try {
zipEntry = zipInputStream.getNextEntry();

if (zipEntry == null) {
break;
}

final File destination = new File(destDirectory, zipEntry.getName());
final String canonicalPath = destination.getCanonicalPath();
if (!canonicalPath.startsWith(destDirectory)) {
throw new SecurityException("https://support.google.com/faqs/answer/9294009");
}
Я всегда гарантирует, что destdirectory не нулевой, прежде чем вызовать extractzipfile

Код: Выделить всё

public static boolean extractZipFile(InputStream inputStream, boolean overwrite) {
String destDirectory = Utils.getUserDataDirectory();
if (destDirectory == null) {
return false;
}
return extractZipFile(inputStream, destDirectory, overwrite);
}

public static String getUserDataDirectory() {
if (externalFilesDir == null) {
File _externalFilesDir = JStockApplication.instance().getExternalFilesDir(null);
externalFilesDir = _externalFilesDir;
if (externalFilesDir == null) {
return null;
}
}

return toEndWithFileSeperator(externalFilesDir.toString()) + getApplicationVersionString() + File.separator;
}

private static String toEndWithFileSeperator(String string) {
if (string.endsWith(File.separator)) {
return string;
}
return string + File.separator;
}

public static String getApplicationVersionString() {
return "1.0.7";
}
< /code>
На основании позиционированного исходного кода, есть ли у вас есть причина, почему «уязвимость прохождения Zip Path происходит только в Android 11? Я использую эмулятор Android 11, но не могу воспроизвести проблему. src = "https://i.sstatic.net/lsptg.png"/> 
Мы используем следующий код для извлечения во время выполнения. 
private void initPreloadDatabase(boolean overWrite) {
AssetManager assetManager = getResources().getAssets();
InputStream inputStream = null;
try {
inputStream = assetManager.open("database" + File.separator + "database.zip");
} catch (IOException e) {
Log.e(TAG, "", e);
}
if (inputStream != null) {
org.yccheok.jstock.gui.Utils.extractZipFile(inputStream, overWrite);
}
}
Другой zip-файл загружается с
https://raw.githubusercontent.com/ycche ... stocks.zip

Подробнее здесь: https://stackoverflow.com/questions/695 ... happens-on
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»