diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml
index 7e0602b..e44cd5a 100644
--- a/.github/workflows/plugin-ci-workflow.yml
+++ b/.github/workflows/plugin-ci-workflow.yml
@@ -38,7 +38,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ['8.1', '8.2', '8.3', '8.4']
+ php: ['8.2', '8.3', '8.4']
os: [ubuntu-latest]
services:
@@ -82,7 +82,9 @@ jobs:
run: php -v
- name: Run apt-get update
- run: sudo apt-get update
+ run: |
+ sudo add-apt-repository -y ppa:ondrej/php
+ sudo apt-get update
- name: Install System Dependencies
run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping libapache2-mod-php${{ matrix.php }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 523779c..c0b69cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
--- develop ---
+* security: Sanitize and bind the filter search on the CA, proxy and credential pages
+* security: Require a CSRF token on the enable, disable and purge GET actions
+
--- 0.4 ---
* feature: Add cpu/memory statistics
diff --git a/servcheck_ca.php b/servcheck_ca.php
index 2313d94..43be866 100644
--- a/servcheck_ca.php
+++ b/servcheck_ca.php
@@ -219,8 +219,9 @@ function request_validation() {
'default' => '1'
],
'filter' => [
- 'filter' => FILTER_DEFAULT,
+ 'filter' => FILTER_CALLBACK,
'pageset' => true,
+ 'options' => ['options' => 'sanitize_search_string'],
'default' => ''
],
'sort_column' => [
@@ -256,7 +257,7 @@ function data_list() {
$sql_where = '';
if (get_request_var('filter') != '') {
- $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE "%' . get_request_var('filter');
+ $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE ' . db_qstr('%' . get_request_var('filter') . '%');
}
$sql_order = get_order_string();
diff --git a/servcheck_credential.php b/servcheck_credential.php
index aab0c66..e880ac1 100644
--- a/servcheck_credential.php
+++ b/servcheck_credential.php
@@ -687,8 +687,9 @@ function request_validation() {
'default' => '1'
],
'filter' => [
- 'filter' => FILTER_DEFAULT,
+ 'filter' => FILTER_CALLBACK,
'pageset' => true,
+ 'options' => ['options' => 'sanitize_search_string'],
'default' => ''
],
'sort_column' => [
@@ -724,7 +725,7 @@ function data_list() {
$sql_where = '';
if (get_request_var('filter') != '') {
- $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE "%' . get_request_var('filter') . '%"';
+ $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE ' . db_qstr('%' . get_request_var('filter') . '%');
}
$sql_order = get_order_string();
diff --git a/servcheck_proxy.php b/servcheck_proxy.php
index 13f0819..0722ff6 100644
--- a/servcheck_proxy.php
+++ b/servcheck_proxy.php
@@ -222,8 +222,9 @@ function request_validation() {
'default' => '1'
],
'filter' => [
- 'filter' => FILTER_DEFAULT,
+ 'filter' => FILTER_CALLBACK,
'pageset' => true,
+ 'options' => ['options' => 'sanitize_search_string'],
'default' => ''
],
'sort_column' => [
@@ -259,7 +260,7 @@ function data_list() {
$sql_where = '';
if (get_request_var('filter') != '') {
- $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE "%' . get_request_var('filter') . '%" OR hostname LIKE "%' . get_request_var('filter') . '%"';
+ $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ' OR hostname LIKE ' . db_qstr('%' . get_request_var('filter') . '%');
}
$sql_order = get_order_string();
diff --git a/servcheck_test.php b/servcheck_test.php
index 6ff202a..4730167 100644
--- a/servcheck_test.php
+++ b/servcheck_test.php
@@ -58,7 +58,7 @@
case 'enable':
$id = get_filter_request_var('id');
- if ($id > 0) {
+ if ($id > 0 && csrf_guard()->validate(get_nfilter_request_var('__csrf_magic'))) {
db_execute_prepared('UPDATE plugin_servcheck_test
SET enabled = "on"
WHERE id = ?', [$id]);
@@ -71,7 +71,7 @@
case 'disable':
$id = get_filter_request_var('id');
- if ($id > 0) {
+ if ($id > 0 && csrf_guard()->validate(get_nfilter_request_var('__csrf_magic'))) {
db_execute_prepared('UPDATE plugin_servcheck_test
SET enabled = ""
WHERE id = ?', [$id]);
@@ -84,7 +84,7 @@
case 'purge':
$id = get_filter_request_var('id');
- if ($id > 0) {
+ if ($id > 0 && csrf_guard()->validate(get_nfilter_request_var('__csrf_magic'))) {
purge_log_events($id);
}
@@ -1169,11 +1169,11 @@ function data_list() {
";
if ($row['enabled'] == '') {
- print "
+ print "
";
} else {
- print "
+ print "
";
}
@@ -1436,7 +1436,7 @@ function clearFilter() {
}
function purgeEvents() {
- strURL = '?action=purge&id=';
+ strURL = '?action=purge&id=&__csrf_magic=';
loadPageNoHeader(strURL);
}