From 153ec1c8567798bd99155098ecc0a340e38f25bf Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Mon, 20 Jul 2026 19:41:39 +0530 Subject: [PATCH 1/3] Fixed: QloApps (XSS + Arbitrary File Upload RCE) issue Co-authored-by: Name --- .../template/helpers/list/list_header.tpl | 10 +++++----- controllers/admin/AdminOrdersController.php | 9 +++++---- .../classes/HotelBookingDocument.php | 18 ++++++++++++------ .../admin/AdminBookingDocumentController.php | 6 +++++- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/admin/themes/default/template/helpers/list/list_header.tpl b/admin/themes/default/template/helpers/list/list_header.tpl index 77922dae1..13983743f 100644 --- a/admin/themes/default/template/helpers/list/list_header.tpl +++ b/admin/themes/default/template/helpers/list/list_header.tpl @@ -300,8 +300,8 @@ {if $params.type == 'range'} {$field_name="`$list_id`Filter_{if isset($params.filter_key)}`$params.filter_key`{else}`$key`{/if}"}
- - + +
{elseif $params.type == 'bool'} {$field_name="`$list_id`Filter_{if isset($params.filter_key)}`$params.filter_key`{else}`$key`{/if}"} @@ -314,14 +314,14 @@
- +
- + @@ -398,7 +398,7 @@ {/if} {else} {$field_name="`$list_id`Filter_{if isset($params.filter_key)}`$params.filter_key`{else}`$key`{/if}"} - + {/if}
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index bcbe5868c..2bcca5a6d 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -3939,10 +3939,11 @@ class AdminOrdersControllerCore extends AdminController $this->errors[] = $this->l('Please select a file to upload.'); } elseif ($objHotelBookingDocument->fileInfo['size'] > Tools::getMaxUploadSize()) { $this->errors[] = $this->l('Uploaded file size is too large.'); - } elseif(!(ImageManager::isRealImage($objHotelBookingDocument->fileInfo['tmp_name']) - || $objHotelBookingDocument->fileInfo['mime'] == 'application/pdf') - ) { - $this->errors[] = $this->l('Please upload an image or a PDF file only. Allowed image formats: .gif, .jpg, .jpeg and .png'); + } else { + $objHotelBookingDocument->setFileType(); + if (!$objHotelBookingDocument->file_type) { + $this->errors[] = $this->l('Please upload an image or a PDF file only. Allowed image formats: .gif, .jpg, .jpeg and .png'); + } } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this order.'); diff --git a/modules/hotelreservationsystem/classes/HotelBookingDocument.php b/modules/hotelreservationsystem/classes/HotelBookingDocument.php index 6c223106f..3683d9884 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDocument.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDocument.php @@ -133,16 +133,14 @@ class HotelBookingDocument extends ObjectModel public function getDestinationFilePath() { - $fileExtension = pathinfo($this->fileInfo['rename'], PATHINFO_EXTENSION); - - return $this->documentFolder.$this->id.'.'.$fileExtension; + return $this->documentFolder.$this->id.'.'.$this->getFileExtension(); } public function setFileType() { if (ImageManager::isRealImage($this->fileInfo['tmp_name'])) { $this->file_type = self::FILE_TYPE_IMAGE; - } elseif ($this->fileInfo['mime'] == 'application/pdf') { + } elseif (substr((string) @file_get_contents($this->fileInfo['tmp_name'], false, null, 0, 5), 0, 5) === '%PDF-') { $this->file_type = self::FILE_TYPE_PDF; } else { $this->file_type = 0; @@ -151,8 +149,16 @@ class HotelBookingDocument extends ObjectModel public function setFileName() { - $fileExtension = pathinfo($this->fileInfo['rename'], PATHINFO_EXTENSION); - $this->file_name = $this->id.'.'.$fileExtension; + $this->file_name = $this->id.'.'.$this->getFileExtension(); + } + + /** + * Extension is derived from the validated file_type, never from the + * uploaded filename/mime header (both are attacker-controlled). + */ + public function getFileExtension() + { + return $this->file_type == self::FILE_TYPE_PDF ? 'pdf' : 'jpg'; } public function getContentType() diff --git a/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php b/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php index c3d92c748..b161a2a27 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php @@ -34,7 +34,11 @@ class AdminBookingDocumentController extends ModuleAdminController $contentLength = $objHotelBookingDocument->getContentLength(); $filePath = $objHotelBookingDocument->getPhysicalPath(); $downloadFileName = $objHotelBookingDocument->getDownloadFileName(); - $contentDisposition = Tools::getValue('is_preview') ? 'inline' : 'attachment'; + // Only images are safe to render inline; PDFs can carry embedded JavaScript + // that executes when opened inline, so they always force a download instead. + $contentDisposition = (Tools::getValue('is_preview') + && $objHotelBookingDocument->file_type == HotelBookingDocument::FILE_TYPE_IMAGE) + ? 'inline' : 'attachment'; if (Tools::file_exists_cache($filePath)) { if (ob_get_level() && ob_get_length() > 0) { From e0d88dd9483a471fc90be37cec7b1f9d4e44f5f6 Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Fri, 14 Aug 2026 12:19:51 +0530 Subject: [PATCH 2/3] removed harcoded jpg filetype sent --- .../classes/HotelBookingDocument.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDocument.php b/modules/hotelreservationsystem/classes/HotelBookingDocument.php index 3683d9884..e38de91dc 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDocument.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDocument.php @@ -153,12 +153,19 @@ class HotelBookingDocument extends ObjectModel } /** - * Extension is derived from the validated file_type, never from the - * uploaded filename/mime header (both are attacker-controlled). + * Extension is derived from the file's real, validated content + * (getimagesize()/PDF signature), never from the uploaded + * filename or mime header (both are attacker-controlled). */ public function getFileExtension() { - return $this->file_type == self::FILE_TYPE_PDF ? 'pdf' : 'jpg'; + if ($this->file_type == self::FILE_TYPE_PDF) { + return 'pdf'; + } + + $imageInfo = @getimagesize($this->fileInfo['tmp_name']); + + return $imageInfo ? image_type_to_extension($imageInfo[2], false) : 'jpg'; } public function getContentType() From e0854a8edf6b384f831a80ef4261cbb6fe1d9d91 Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Thu, 20 Aug 2026 20:18:39 +0530 Subject: [PATCH 3/3] Check pdf content --- .../classes/HotelBookingDocument.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDocument.php b/modules/hotelreservationsystem/classes/HotelBookingDocument.php index e38de91dc..3567440e7 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDocument.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDocument.php @@ -138,9 +138,14 @@ class HotelBookingDocument extends ObjectModel public function setFileType() { - if (ImageManager::isRealImage($this->fileInfo['tmp_name'])) { + $content = @file_get_contents($this->fileInfo['tmp_name']); + $activeContentPattern = '/\/(JavaScript|JS|OpenAction|AA|Launch|SubmitForm|ImportData)\b/i'; + + $this->imageInfo = @getimagesize($this->fileInfo['tmp_name']); + + if ($this->imageInfo && ImageManager::isRealImage($this->fileInfo['tmp_name'])) { $this->file_type = self::FILE_TYPE_IMAGE; - } elseif (substr((string) @file_get_contents($this->fileInfo['tmp_name'], false, null, 0, 5), 0, 5) === '%PDF-') { + } elseif ($content !== false && substr($content, 0, 5) === '%PDF-' && !preg_match($activeContentPattern, $content)) { $this->file_type = self::FILE_TYPE_PDF; } else { $this->file_type = 0; @@ -154,8 +159,9 @@ class HotelBookingDocument extends ObjectModel /** * Extension is derived from the file's real, validated content - * (getimagesize()/PDF signature), never from the uploaded - * filename or mime header (both are attacker-controlled). + * (getimagesize()/PDF signature), captured once in setFileType(), + * never from the uploaded filename or mime header (both are + * attacker-controlled). */ public function getFileExtension() { @@ -163,9 +169,7 @@ class HotelBookingDocument extends ObjectModel return 'pdf'; } - $imageInfo = @getimagesize($this->fileInfo['tmp_name']); - - return $imageInfo ? image_type_to_extension($imageInfo[2], false) : 'jpg'; + return image_type_to_extension($this->imageInfo[2], false); } public function getContentType()