From 7dad8ab45b889a1fada2758d15bed734327519e3 Mon Sep 17 00:00:00 2001 From: Michele Romano <33063403+Mik317@users.noreply.github.com> Date: Tue, 30 Jun 2020 17:47:45 +0200 Subject: [PATCH 1/5] Update Service.php --- src/bb-modules/Support/Service.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bb-modules/Support/Service.php b/src/bb-modules/Support/Service.php index c2cebeafb..3a217e100 100644 --- a/src/bb-modules/Support/Service.php +++ b/src/bb-modules/Support/Service.php @@ -957,7 +957,9 @@ class Service implements \Box\InjectionAwareInterface } else { throw new \Box_Exception('Identity is not valid'); } - $msg->content = $content; + + /* Using *htmlspecialchars* makes possible sanitize the HTML characters and quotes in order to avoid XSS */ + $msg->content = htmlspecialchars($content, ENT_QUOTES | ENT_HTML5, 'UTF-8'); $msg->ip = $this->di['request']->getClientAddress(); $msg->created_at = date('Y-m-d H:i:s'); $msg->updated_at = date('Y-m-d H:i:s'); @@ -1487,4 +1489,4 @@ class Service implements \Box\InjectionAwareInterface return true; } -} \ No newline at end of file +} From fd0bf3ef52e6806493338948fa848ba9ecd764ba Mon Sep 17 00:00:00 2001 From: Michele Romano <33063403+Mik317@users.noreply.github.com> Date: Tue, 30 Jun 2020 22:17:25 +0200 Subject: [PATCH 2/5] Update Service.php --- src/bb-modules/Servicedomain/Service.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bb-modules/Servicedomain/Service.php b/src/bb-modules/Servicedomain/Service.php index 06acde637..8eff68f19 100644 --- a/src/bb-modules/Servicedomain/Service.php +++ b/src/bb-modules/Servicedomain/Service.php @@ -69,7 +69,8 @@ class Service implements \Box\InjectionAwareInterface } if (!$validator->isSldValid($data['owndomain_sld'])) { - throw new \Box_Exception('Domain name :domain is not valid', array(':domain' => $data['owndomain_sld'])); + $safe_dom = htmlspecialchars($data['owndomain_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); + throw new \Box_Exception('Domain name :domain is not valid', array(':domain' => $safe_dom)); } $required = array( @@ -85,7 +86,8 @@ class Service implements \Box\InjectionAwareInterface } if (!$validator->isSldValid($data['transfer_sld'])) { - throw new \Box_Exception('Domain name :domain is not valid', array(':domain' => $data['transfer_sld'])); + $safe_dom = htmlspecialchars($data['transfer_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); + throw new \Box_Exception('Domain name :domain is not valid', array(':domain' => $safe_dom)); } $required = array( @@ -1074,4 +1076,4 @@ class Service implements \Box\InjectionAwareInterface } -} \ No newline at end of file +} From 565e285730f20fb51ef9b11f8b865a1c195831b0 Mon Sep 17 00:00:00 2001 From: Michele Romano <33063403+Mik317@users.noreply.github.com> Date: Tue, 30 Jun 2020 22:25:34 +0200 Subject: [PATCH 3/5] Update Service.php --- src/bb-modules/Servicedomain/Service.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bb-modules/Servicedomain/Service.php b/src/bb-modules/Servicedomain/Service.php index 8eff68f19..b66032f97 100644 --- a/src/bb-modules/Servicedomain/Service.php +++ b/src/bb-modules/Servicedomain/Service.php @@ -117,7 +117,8 @@ class Service implements \Box\InjectionAwareInterface } if (!$validator->isSldValid($data['register_sld'])) { - throw new \Box_Exception('Domain name :domain is not valid', array(':domain' => $data['register_sld'])); + $safe_dom = htmlspecialchars($data['register_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); + throw new \Box_Exception('Domain name :domain is not valid', array(':domain' => $safe_dom)); } $required = array( @@ -561,7 +562,8 @@ class Service implements \Box\InjectionAwareInterface $validator = $this->di['validator']; if (!$validator->isSldValid($sld)) { - throw new \Box_Exception('Domain name :domain is not valid', array(':domain' => $sld)); + $safe_dom = htmlspecialchars($sld, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + throw new \Box_Exception('Domain name :domain is not valid', array(':domain' => $safe_dom)); } if (!$model->allow_register) { From 91b03399b9530529fa133a0c1443975a1d58cc01 Mon Sep 17 00:00:00 2001 From: Michele Romano <33063403+Mik317@users.noreply.github.com> Date: Tue, 30 Jun 2020 22:28:25 +0200 Subject: [PATCH 4/5] Update Service.php --- src/bb-modules/Support/Service.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bb-modules/Support/Service.php b/src/bb-modules/Support/Service.php index 3a217e100..4cb372e04 100644 --- a/src/bb-modules/Support/Service.php +++ b/src/bb-modules/Support/Service.php @@ -957,9 +957,7 @@ class Service implements \Box\InjectionAwareInterface } else { throw new \Box_Exception('Identity is not valid'); } - - /* Using *htmlspecialchars* makes possible sanitize the HTML characters and quotes in order to avoid XSS */ - $msg->content = htmlspecialchars($content, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + $msg->content = $content; $msg->ip = $this->di['request']->getClientAddress(); $msg->created_at = date('Y-m-d H:i:s'); $msg->updated_at = date('Y-m-d H:i:s'); From 7c1a0e0d3fc21527d04652491a93090de9e1f5a2 Mon Sep 17 00:00:00 2001 From: Michele Romano <33063403+Mik317@users.noreply.github.com> Date: Tue, 30 Jun 2020 22:41:09 +0200 Subject: [PATCH 5/5] Update Guest.php --- src/bb-modules/Servicedomain/Api/Guest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bb-modules/Servicedomain/Api/Guest.php b/src/bb-modules/Servicedomain/Api/Guest.php index 4fdc9f393..4e9bfef2c 100644 --- a/src/bb-modules/Servicedomain/Api/Guest.php +++ b/src/bb-modules/Servicedomain/Api/Guest.php @@ -94,7 +94,7 @@ class Guest extends \Api_Abstract ); $this->di['validator']->checkRequiredParamsForArray($required, $data); - $sld = $data['sld']; + $sld = htmlspecialchars($data['sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); $validator = $this->di['validator']; if (!$validator->isSldValid($sld)) { throw new \Box_Exception('Domain :domain is not valid', array(':domain' => $sld)); @@ -139,4 +139,4 @@ class Guest extends \Api_Abstract return TRUE; } -} \ No newline at end of file +}