Merge pull request from GHSA-mhr8-7rvg-8r43

* Prevent possible XSS attack vector on add_client
Update JS code to prevent possible XSS vector

Co-authored-by: Harold Kim <root@stypr.com>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>

* Fix both addClient and deleteClient to prevent XSS

Signed-off-by: Harold Kim <root@stypr.com>

Co-authored-by: Harold Kim <root@stypr.com>
This commit is contained in:
Adam Warner
2021-10-23 19:26:07 +01:00
committed by GitHub
parent e53f7e674e
commit 01191c7a1b
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -260,7 +260,7 @@ function initTable() {
}
function addClient() {
var ip = $("#select").val().trim();
var ip = utils.escapeHtml($("#select").val().trim());
var comment = utils.escapeHtml($("#new_comment").val());
utils.disableAll();
@@ -385,7 +385,7 @@ function editClient() {
function deleteClient() {
var tr = $(this).closest("tr");
var id = tr.attr("data-id");
var ip = tr.find("#ip_" + id).text();
var ip = utils.escapeHtml(tr.find("#ip_" + id).text());
var name = utils.escapeHtml(tr.find("#name_" + id).text());
if (name.length > 0) {
+2
View File
@@ -347,6 +347,8 @@ if ($_POST['action'] == 'get_groups') {
}
foreach ($ips as $ip) {
// Encode $ip variable to prevent XSS
$ip = htmlspecialchars($ip);
// Silently skip this entry when it is empty or not a string (e.g. NULL)
if(!is_string($ip) || strlen($ip) == 0) {
continue;