распаковка до версии 4.2.2 содержит неправильную проверку содержания пути, которая позволяет обход каталогов и произвольную запись в файл. Функция SafeMakeDir (строка 29 index.js) и проверка пути извлечения (строка 106 index.js) используют String.indexOf() для проверки того, что разрешенный путь находится в выходном каталоге: realDestinationDir.indexOf(realOutputPath) !== 0. Эта проверка ошибочна, поскольку она не обеспечивает соблюдение границы разделителя пути.
Например, "/tmp/app_config".indexOf("/tmp/app") возвращает 0, что приводит к неправильному прохождению проверки, даже если /tmp/app_config находится за пределами /tmp/app. В сочетании с созданием непроверенной символической ссылки в том же пакете злоумышленник может записать произвольные файлы в каталоги, соседние с целью извлечения. Это обход исправления CVE-2020-12265.
Для правильной проверки необходимо добавить разделитель пути: realParentPath.indexOf(realOutputPath + path.sep) !== 0.
Показать оригинальное описание (EN)
decompress before 4.2.2 contains an improper path containment check that enables directory traversal and arbitrary file write. The safeMakeDir function (index.js line 29) and the extraction path validation (index.js line 106) use String.indexOf() to verify the resolved path is within the output directory: realDestinationDir.indexOf(realOutputPath) !== 0. This check is flawed because it does not enforce a path separator boundary. For example, "/tmp/app_config".indexOf("/tmp/app") returns 0, incorrectly passing the check even though /tmp/app_config is outside /tmp/app. Combined with the unvalidated symlink creation in the same package, an attacker can write arbitrary files to directories adjacent to the extraction target. This is a bypass of the fix for CVE-2020-12265. The correct check requires appending a path separator: realParentPath.indexOf(realOutputPath + path.sep) !== 0.
Характеристики атаки
Последствия
Строка CVSS v3.1
Тип уязвимости (CWE)
Уязвимые продукты 1
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Decompress_Project Decompress
cpe:2.3:a:decompress_project:decompress:*:*:*:*:*:node.js:*:*
|
— |
<= 4.2.1
|