Unsafe $_SERVER['QUERY_STRING'] usage in admin.php #939

Open
opened 2026-10-05 00:24:41 +02:00 by adam · 0 comments
Owner

In admin.php @ line 102 we see the following code.

// +-----------------------------------------------------------------------+
// | Variables init                                                        |
// +-----------------------------------------------------------------------+

$change_theme_url = PHPWG_ROOT_PATH.'admin.php?';
$test_get = $_GET;
unset($test_get['page']);
unset($test_get['section']);
unset($test_get['tag']);
if (count($test_get) == 0 and !empty($_SERVER['QUERY_STRING']))
{
  $change_theme_url.= str_replace('&', '&', $_SERVER['QUERY_STRING']).'&';
}
$change_theme_url.= 'change_theme=1';

If we send Piwigo a url like:

admin.php?="><script>alert(1);</script>

The condition at line 111 will be met and the $change_theme_url variable will then contain an unsanitized query string resulting in XSS wherever $change_theme_url is used.

In admin.php @ line 102 we see the following code. ```php // +-----------------------------------------------------------------------+ // | Variables init | // +-----------------------------------------------------------------------+ $change_theme_url = PHPWG_ROOT_PATH.'admin.php?'; $test_get = $_GET; unset($test_get['page']); unset($test_get['section']); unset($test_get['tag']); if (count($test_get) == 0 and !empty($_SERVER['QUERY_STRING'])) { $change_theme_url.= str_replace('&', '&amp;', $_SERVER['QUERY_STRING']).'&amp;'; } $change_theme_url.= 'change_theme=1'; ``` If we send Piwigo a url like: admin.php?="><script>alert(1);</script> The condition at line 111 will be met and the $change_theme_url variable will then contain an unsanitized query string resulting in XSS wherever $change_theme_url is used. <!-- github-sync-id:493560651 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#939