From c45580b6b600f679be8bac1f3640862daa660b6b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 08:31:28 +0000 Subject: [PATCH] fix: Prevent XSS vulnerabilities in all user-displayed data Introduced a new `safeDisplay` function in `apps.functions.php` to sanitize output using `htmlspecialchars`. This comprehensive change applies the `safeDisplay` function to all identified locations where user-provided data is displayed to prevent reflected XSS attacks: - Sanitized the `$_GET['search']` parameter in `apps/explorer/accounts.php`. - Sanitized `$_REQUEST` parameters and the `id` from `$_GET` in `apps/explorer/smart_contract.php`. - Sanitized the `transaction['message']` field where it is displayed in `apps/explorer/address.php`, `tx.php`, and `mempool.php`. - Sanitized smart contract parameters decoded from the transaction message in `apps/explorer/tx.php` before they are displayed. - Sanitized the `transaction['message']` field on the admin mempool page in `apps/admin/tabs/mempool.php`. - Sanitized the `address` and `type` GET parameters in `apps/explorer/address_info.php`. --- web/apps/admin/tabs/mempool.php | 2 +- web/apps/apps.functions.php | 4 ++++ web/apps/explorer/accounts.php | 2 +- web/apps/explorer/address.php | 2 +- web/apps/explorer/address_info.php | 4 ++-- web/apps/explorer/mempool.php | 2 +- web/apps/explorer/smart_contract.php | 6 +++--- web/apps/explorer/tx.php | 4 ++-- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/web/apps/admin/tabs/mempool.php b/web/apps/admin/tabs/mempool.php index 5b0acb45..f71fe0bb 100644 --- a/web/apps/admin/tabs/mempool.php +++ b/web/apps/admin/tabs/mempool.php @@ -59,7 +59,7 @@ - + diff --git a/web/apps/apps.functions.php b/web/apps/apps.functions.php index 0585d395..ed6c6469 100755 --- a/web/apps/apps.functions.php +++ b/web/apps/apps.functions.php @@ -17,3 +17,7 @@ function explorer_address_link2($address, $short= false) { } return ''.$text.''; } + +function safeDisplay($string) { + return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); +} diff --git a/web/apps/explorer/accounts.php b/web/apps/explorer/accounts.php index 77fbcade..0f43964b 100755 --- a/web/apps/explorer/accounts.php +++ b/web/apps/explorer/accounts.php @@ -19,7 +19,7 @@ diff --git a/web/apps/explorer/address.php b/web/apps/explorer/address.php index 604f11e9..11d6944a 100755 --- a/web/apps/explorer/address.php +++ b/web/apps/explorer/address.php @@ -153,7 +153,7 @@ - + diff --git a/web/apps/explorer/address_info.php b/web/apps/explorer/address_info.php index 979d2166..f065175f 100644 --- a/web/apps/explorer/address_info.php +++ b/web/apps/explorer/address_info.php @@ -124,8 +124,8 @@ diff --git a/web/apps/explorer/mempool.php b/web/apps/explorer/mempool.php index d2d0d6dc..ed0f9bd9 100755 --- a/web/apps/explorer/mempool.php +++ b/web/apps/explorer/mempool.php @@ -47,7 +47,7 @@ - + diff --git a/web/apps/explorer/smart_contract.php b/web/apps/explorer/smart_contract.php index e50ba77e..a01c90c2 100644 --- a/web/apps/explorer/smart_contract.php +++ b/web/apps/explorer/smart_contract.php @@ -317,7 +317,7 @@ + value="" placeholder="Key"> @@ -444,7 +444,7 @@ ?> + value="" placeholder=""> @@ -598,7 +598,7 @@ function getInnerHTML(DOMNode $node): string {