From 1cd08e2f8d52b9cc9a537f0e8ab731d61b393208 Mon Sep 17 00:00:00 2001 From: Stepan Fedotov Date: Sat, 3 Oct 2020 19:55:35 +0300 Subject: [PATCH] Fix XSS in server owner selection (#2441) Co-authored-by: Stepan Fedotov Co-authored-by: Sergej --- CHANGELOG.md | 4 ++++ .../themes/pterodactyl/js/admin/new-server.js | 18 ++++++++++++------ .../admin/servers/view/details.blade.php | 18 ++++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5d7d93d1..8958e82be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ This file is a running track of new features and fixes to each version of the pa This project follows [Semantic Versioning](http://semver.org) guidelines. +## v0.7.19 (Derelict Dermodactylus) +### Fixed +* **[Security]** Fixes XSS in the admin area's server owner selection. + ## v0.7.18 (Derelict Dermodactylus) ### Fixed * **[Security]** Re-addressed missed endpoint that would not properly limit a user account to 5 API keys. diff --git a/public/themes/pterodactyl/js/admin/new-server.js b/public/themes/pterodactyl/js/admin/new-server.js index 97f05487b..b94e804d7 100644 --- a/public/themes/pterodactyl/js/admin/new-server.js +++ b/public/themes/pterodactyl/js/admin/new-server.js @@ -37,6 +37,12 @@ $(document).ready(function() { placeholder: 'Select Additional Allocations', }); + function escapeHtml(str) { + var div = document.createElement('div'); + div.appendChild(document.createTextNode(str)); + return div.innerHTML; + } + $('#pUserId').select2({ ajax: { url: Router.route('admin.users.json'), @@ -56,23 +62,23 @@ $(document).ready(function() { escapeMarkup: function (markup) { return markup; }, minimumInputLength: 2, templateResult: function (data) { - if (data.loading) return data.text; + if (data.loading) return escapeHtml(data.text); return '
\ - User Image \ + User Image \ \ - ' + data.name_first + ' ' + data.name_last +' \ + ' + escapeHtml(data.name_first) + ' ' + escapeHtml(data.name_last) +' \ \ - ' + data.email + ' - ' + data.username + ' \ + ' + escapeHtml(data.email) + ' - ' + escapeHtml(data.username) + ' \
'; }, templateSelection: function (data) { return '
\ \ - User Image \ + User Image \ \ \ - ' + data.name_first + ' ' + data.name_last + ' (' + data.email + ') \ + ' + escapeHtml(data.name_first) + ' ' + escapeHtml(data.name_last) + ' (' + escapeHtml(data.email) + ') \ \
'; } diff --git a/resources/themes/pterodactyl/admin/servers/view/details.blade.php b/resources/themes/pterodactyl/admin/servers/view/details.blade.php index a84a9144c..5eb8d2055 100644 --- a/resources/themes/pterodactyl/admin/servers/view/details.blade.php +++ b/resources/themes/pterodactyl/admin/servers/view/details.blade.php @@ -83,6 +83,12 @@ @section('footer-scripts') @parent