From 06259aa0c64c035218162c16a4e78dd6cab768b1 Mon Sep 17 00:00:00 2001
From: Oleksandr Mykhailenko
Date: Wed, 18 Jan 2023 23:20:20 +0200
Subject: [PATCH] De 933 check possible security issues for wordpress mailgun
plugin (#156)
* Changed `Tested Up` version of WP
* Changed `Tested Up` version of WP
* Fix bug with wp_mail filter. release new version
* Fix possible security issues. In progress
* Sanitizing and escaping vars. Possible security issues
Fix possible security issues. In progress
---
includes/admin.php | 6 +++---
includes/lists-page.php | 10 +++++-----
includes/mg-filter.php | 2 +-
includes/options-page.php | 24 ++++++++++++------------
includes/widget.php | 10 +++++-----
mailgun.php | 28 ++++++++++++++--------------
readme.md | 5 ++++-
readme.txt | 5 ++++-
8 files changed, 48 insertions(+), 42 deletions(-)
diff --git a/includes/admin.php b/includes/admin.php
index c0499f6..8519a91 100755
--- a/includes/admin.php
+++ b/includes/admin.php
@@ -67,7 +67,7 @@ public function __construct()
*/
public function init()
{
- $sitename = strtolower($_SERVER['SERVER_NAME']);
+ $sitename = sanitize_text_field(strtolower($_SERVER['SERVER_NAME']));
if (substr($sitename, 0, 4) === 'www.') {
$sitename = substr($sitename, 4);
}
@@ -166,7 +166,7 @@ public function admin_footer_js()
ajaxurl,
{
action: 'mailgun-test',
- _wpnonce: ''
+ _wpnonce: ''
}
)
.complete(function () {
@@ -386,7 +386,7 @@ public function ajax_send_test()
nocache_headers();
header('Content-Type: application/json');
- if (!current_user_can('manage_options') || !wp_verify_nonce($_GET['_wpnonce'])):
+ if (!current_user_can('manage_options') || !wp_verify_nonce(sanitize_text_field($_GET['_wpnonce']))):
die(
json_encode(array(
'message' => __('Unauthorized', 'mailgun'),
diff --git a/includes/lists-page.php b/includes/lists-page.php
index 1ca4dea..1719f79 100644
--- a/includes/lists-page.php
+++ b/includes/lists-page.php
@@ -46,7 +46,7 @@
-
+
@@ -54,7 +54,7 @@
-
+
@@ -73,10 +73,10 @@
- |
- |
+ |
+ |
- [mailgun id=""]
+ [mailgun id=""]
|
diff --git a/includes/mg-filter.php b/includes/mg-filter.php
index b9272ef..95e7ba4 100755
--- a/includes/mg-filter.php
+++ b/includes/mg-filter.php
@@ -152,7 +152,7 @@ function mg_detect_from_address($from_addr_header = null): string
if (function_exists('get_current_site')) {
$sitedomain = get_current_site()->domain;
} else {
- $sitedomain = strtolower($_SERVER['SERVER_NAME']);
+ $sitedomain = strtolower(sanitize_text_field($_SERVER['SERVER_NAME']));
if (substr($sitedomain, 0, 4) === 'www.') {
$sitedomain = substr($sitedomain, 4);
}
diff --git a/includes/options-page.php b/includes/options-page.php
index bdfe998..502b3fb 100755
--- a/includes/options-page.php
+++ b/includes/options-page.php
@@ -57,7 +57,7 @@
-
+
@@ -75,7 +75,7 @@
)
), esc_url($url), '_blank'
);
- echo $link;
+ echo wp_kses_data($link);
?>
@@ -92,7 +92,7 @@
)
), esc_url($url), '_blank'
);
- echo $link;
+ echo wp_kses_data($link);
?>
@@ -107,11 +107,11 @@
-
+
@@ -128,7 +128,7 @@
|
-
+
|
@@ -429,7 +429,7 @@ class="regular-text"
)
), esc_url($url)
);
- echo $link;
+ echo wp_kses_data($link);
?>
diff --git a/includes/widget.php b/includes/widget.php
index af56dfa..6d361ab 100644
--- a/includes/widget.php
+++ b/includes/widget.php
@@ -82,20 +82,20 @@ public function form($instance)
?>
get_lists();
?>
-