| 제목 | WebKul QloApps 1.7.0 Absolute Path Traversal |
|---|
| 설명 | ### Two vulnerable RCE
#### I. Summary
- Product: QloApps
- Affected Version(s): <= x.x.x.x
- Vulnerable type: Remote Code Execution
- Severity: High
- CVSS 3.1: 7.2 (AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H)
> Affected components:
* controllers/admin/AdminModulesController.php
* controllers/admin/AdminThemesController.php
* classes/Tools.php (ZipExtract() helper)
> Test Environment: PHP 8.2.12, Apache 2.4.58 (XAMPP), MySQL, QloApps x.x.x.x
#### II. Description
QloApps ships two administrative "**archive import**" features (module installer and theme importer) that extract attacker-controlled ZIP/TAR archives into directories inside the web root. Both flows fail to validate the resolved destination path of each archive entry and fail to enforce an allow-list of file types before they are written/copied into executable web-accessible locations. An authenticated administrator can therefore write an arbitrary PHP file into the web root and obtain Remote Code Execution with the privileges of the web server.
The two independently exploitable bugs are detailed below:
##### Bug 1 — RCE via Module Upload (filename path traversal + unvalidated archive extraction)
**Files**: *controllers/admin/AdminModulesController.php, classes/Tools.php*
**Root cause 1**: Filename is concatenated into the destination path without sanitization:
```php!
// controllers/admin/AdminModulesController.php (line 614)
} elseif (!move_uploaded_file($_FILES['file']['tmp_name'], _PS_MODULE_DIR_.$_FILES['file']['name'])) {
```
`$_FILES['file']['name']` is concatenated directly into `_PS_MODULE_DIR_` without basename() and without a character allow-list.
An attacker fully controls this value and can embed `../` sequences to escape the /modules/ directory and write the file anywhere in the web root (e.g. `../../../shell.php`).
Validation only checks the suffix via `substr($name, -4)` against `.zip/.tar/.tgz/.tar.gz;` it does not constrain path components or characters.
**Root cause 2:** `ZipArchive::extractTo()` does not validate entry paths (Zip Slip)
```php!
// classes/Tools.php (line 2857)
public static function ZipExtract($from_file, $to_dir)
{
...
if ($zip->open($from_file) === true && $zip->extractTo($to_dir) && $zip->close()) {
return true;
}
}
```
`ZipArchive::extractTo()` writes each member using the name stored inside the archive, without rejecting entries containing ../, leading /, or Windows drive letters.
A ZIP containing an entry such as `../../shell.php` is extracted relative to `_PS_MODULE_DIR_`, escaping that directory into the web root.
**Root cause 3**: Incomplete directory cleanup after extraction
```php!
// AdminModulesController.php — extractArchive() (lines 432-441)
foreach ($zip_folders as $folder) {
if (!Module::getInstanceByName($folder)) {
$this->errors[] = '...not a valid module...';
$this->recursiveDeleteOnDisk(_PS_MODULE_DIR_.$folder); // removes only well-formed module dirs
}
}
```
After extraction only folders that `Module::getInstanceByName()` fails to recognize are deleted. A PHP payload written to a path outside the expected module layout (via the path traversal) is never removed and remains on disk.
**Video exploit and script**: [here](https://drive.google.com/drive/folders/1KbzmkZs7K9VZDua1T2Jngdzx8VDpMFKj)
##### Bug 2 — RCE via Theme Import (unrestricted PHP file copy)
**Files**: controllers/admin/AdminThemesController.php, classes/Tools.php, classes/Uploader.php
**Root cause 1**: All files inside the archive are copied verbatim into the web root:
```php
// controllers/admin/AdminThemesController.php (line 1586)
Tools::ZipExtract($theme_zip_file, $sandbox.Theme::UPLOADED_THEME_DIR_NAME.'/');
// installTheme() — lines 1637-1639
Tools::recurseCopy($sandbox.$theme_dir.'/themes/'.$theme->directory.'/', $target_dir.'/');
Tools::recurseCopy($sandbox.$theme_dir.'/doc/', $theme_doc_dir);
```
`recurseCopy()` copies every file under `themes/<dir>/` unchanged into the web-accessible `/themes/<dir>/`.
There is no extension allow-list and no check that forbids `.php` or `.htaccess`. An attacker who simply adds `themes/rce-theme/shell.php` into the ZIP will have that file copied verbatim to `/themes/rce-theme/shell.php`.
A minimal, well-formed `Config.xml` (validated only by `checkXmlFields()`) is enough to control the name/directory attributes and reach the copy step.
**Root cause 2**: No per-entry validation of archive contents
The importer never validates the list of files inside the archive before extraction/copy.
`checkXmlFields()` only validates the XML structure of `Config.xml`; it performs no checks on whether PHP files are permitted.
**Root cause 3**: The destination directory sits in the web root and can execute PHP
`/themes/<directory>/` is created under `_PS_ALL_THEMES_DIR_` (inside the web root).
Apache has write and execution rights there, so the copied PHP shell executes immediately.
**Video exploit and script**: [here](https://drive.google.com/drive/folders/1EtqXvg8l75iLjbUA9jYnsiuFUkpiHEks?usp=drive_link)
##### III. Impact
Successful exploitation may allow an attacker to:
- Upload arbitrary executable files.
- Execute arbitrary code on the server.
- Compromise application confidentiality, integrity, and availability.
- Access or modify sensitive application data.
- Potentially gain further control of the affected server depending on the execution context.
|
|---|
| 원천 | ⚠️ https://hackmd.io/@leediay/BJ9Qd-Tvfe |
|---|
| 사용자 | leediay153 (UID 100314) |
|---|
| 제출 | 2026. 10. 21. AM 05:43 (1 월 ago) |
|---|
| 모더레이션 | 2026. 11. 19. PM 10:43 (30 days later) |
|---|
| 상태 | 수락 |
|---|
| VulDB 항목 | 440881 [WebKul QloApps 까지 1.8.0 Archive Import AdminModulesController.php postProcessDownload/installTheme 디렉토리 순회] |
|---|
| 포인트들 | 20 |
|---|