GHSA-w998-qmw9-mf4m: XSS
Summary The mediapool sync page (sync.php) renders filenames from the /media filesystem directory directly into HTML without applying rexescape() (i.e., htmlspecialchars). Any file placed in the media directory whose filename contains HTML metacharacters will execute JavaScript in the browser of any backend user who views the sync page.
Details In redaxo/src/addons/mediapool/pages/sync.php, the variable $diffFiles is populated from actual filesystem filenames (files in /media/ not yet registered in the database). These filenames are then rendered without escaping:
File: redaxo/src/addons/mediapool/pages/sync.php:119-120 php foreach ($diffFiles as $file) { if (iswritable(rexpath::media($file))) { $e = []; $e['label'] = '<label>' . $file . '</label>'; // NO rexescape! $e['field'] = '<input type="checkbox" name="syncfiles[]" value="' . $file . '" />'; // NO rexescape! $writable[] = $e; } else { $notWritable[] = $file; } }
File: redaxo/src/addons/mediapool/pages/sync.php:170 php $fragment->setVar('body', '<ul><li>' . implode('</li><li>', $notWritable) . '</li></ul>', false); // $notWritable contains unescaped filenames
By contrast, all other filename displays in the codebase use rexescape($fname) (e.g., media.detail.php:236, media.list.php). The sync page is accessible to any backend user with the media[sync] permission (not exclusively admins).
PoC 1. Place a file named <img src=x onerror=alert(document.cookie)>.txt into the REDAXO /media/ directory (via backup restore or server access) without adding it to the media database. 2. Log in as any backend user with media[sync] permission. 3. Navigate to Mediapool → Sync. 4. The XSS payload executes immediately, stealing the admin session cookie.
Impact Stored XSS in the admin panel. An attacker who can place files in the media directory (via admin-level backup restore or server access) can achieve persistent XSS against all users who visit the sync page, including higher-privileged admins. This enables session hijacking, credential theft, and full CMS takeover.
Fix Apply rexescape() to all filename variables before inserting into HTML: php $e['label'] = '<label>' . rexescape($file) . '</label>'; $e['field'] = '<input type="checkbox" name="syncfiles[]" value="' . rexescape($file) . '" />'; // ... $fragment->setVar('body', '<ul><li>' . implode('</li><li>', arraymap('rexescape', $notWritable)) . '</li></ul>', false);
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/redaxo/sourceto a version that resolves this vulnerability.Fixed in 5.21.2 - Configuration
Apply rex_escape() to all filename variables, including $file and the filenames in $notWritable, before inserting them into HTML.
REDAXO mediapool sync page (redaxo/src/addons/mediapool/pages/sync.php) HTML escaping of filename variables = rex_escape()
Event History
Frequently Asked Questions
Who can be affected by this issue?
Backend users who view the mediapool sync page can be affected if the /media directory contains files that are not yet registered in the database and have HTML metacharacters in their filenames.
What does an attacker need to exploit it?
An attacker needs to place a file with a crafted filename in the /media directory. JavaScript executes when a backend user subsequently views the sync page.
How can I determine whether my instance is exposed?
Check for filesystem files in /media that are not registered in the database, particularly filenames containing HTML metacharacters. Those filenames are included in the sync page output.