Skip to content

Commit

Permalink
Bugfix: Security fix
Browse files Browse the repository at this point in the history
    - XSS (reflected) in 'find subnets';

Reported by Celso Bezerra <celso.bezerra@tempest.com.br>
  • Loading branch information
GaryAllan committed Jan 17, 2022
1 parent 4b764b9 commit 6c1f728
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/admin/subnets/find_free_section_subnets.php
Expand Up @@ -20,6 +20,9 @@
# verify that user is logged in
$User->check_user_session();

# validate csrf cookie
$User->Crypto->csrf_cookie ("validate", "find_free_section_subnets", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";

# verify that user has permissions to add subnet
if($Sections->check_permission ($User->user, $_POST['sectionid']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section')."!", true, true); }

Expand Down Expand Up @@ -92,7 +95,7 @@
<td>
<div class="input-group">
<input type="text" class="form-control input-sm input-w-auto" name="results" value='50'>
<input type="hidden" name="sectionid" value='<?php print $_POST['sectionid']; ?>'>
<input type="hidden" name="sectionid" value='<?php print escape_input($_POST['sectionid']); ?>'>
</div>

</td>
Expand Down
5 changes: 4 additions & 1 deletion app/subnets/subnets-menu.php
Expand Up @@ -9,6 +9,9 @@
# verify that user is logged in
$User->check_user_session();

# create csrf token
$csrf_ffss = $User->Crypto->csrf_cookie ("create-if-not-exists", "find_free_section_subnets");

# ID must be numeric
if(!is_numeric($_GET['section'])) { $Result->show("danger",_('Invalid ID'), true); }

Expand Down Expand Up @@ -133,7 +136,7 @@
print " <span>";
print " <div class='btn-group'>";
print " <button id='add_subnet' class='btn btn-xs btn-default btn-success' rel='tooltip' data-container='body' data-placement='top' title='"._('Add new subnet to')." $section[name]' data-subnetId='' data-sectionId='$section[id]' data-action='add'><i class='fa fa-sm fa-plus'></i></button>";
print " <button class='btn btn-xs btn-default btn-success open_popup' data-script='app/admin/subnets/find_free_section_subnets.php' data-class='700' rel='tooltip' data-container='body' data-placement='top' title='"._('Search for free subnets in section ')." $section[name]' data-sectionId='$section[id]'><i class='fa fa-sm fa-search'></i></button>";
print " <button class='btn btn-xs btn-default btn-success open_popup' data-script='app/admin/subnets/find_free_section_subnets.php' data-csrf_cookie='$csrf_ffss' data-class='700' rel='tooltip' data-container='body' data-placement='top' title='"._('Search for free subnets in section ')." $section[name]' data-sectionId='$section[id]'><i class='fa fa-sm fa-search'></i></button>";
# snmp
if($User->settings->enableSNMP==1) {
$csrf = $User->Crypto->csrf_cookie ("create", "scan");
Expand Down
5 changes: 4 additions & 1 deletion functions/classes/class.Sections.php
Expand Up @@ -537,6 +537,9 @@ public function get_group_section_permissions ($gid, $name = true) {
public function print_section_subnets_table($User, $sectionId, $showSupernetOnly = false) {
$html = array();

# create csrf token
$csrf_ffss = $User->Crypto->csrf_cookie ("create-if-not-exists", "find_free_section_subnets");

# set custom fields
$Tools = new Tools ($this->Database);
$custom = $Tools->fetch_custom_fields ("subnets");
Expand All @@ -556,7 +559,7 @@ public function print_section_subnets_table($User, $sectionId, $showSupernetOnly
if ($permission>1) {
$html[] = "<div class='btn-group'>";
$html[] = '<button class="btn btn-sm btn-default btn-success editSubnet" data-action="add" data-sectionid="'.$sectionId.'" data-subnetId="" rel="tooltip" data-placement="left" title="'._('Add new subnet to section').'"><i class="fa fa-plus"></i> '._('Add subnet').'</button>';
$html[] = "<button class='btn btn-sm btn-default btn-success open_popup' data-script='app/admin/subnets/find_free_section_subnets.php' data-class='700' rel='tooltip' data-container='body' data-placement='top' title='"._('Search for free subnets in section ')."' data-sectionId='$sectionId'><i class='fa fa-sm fa-search'></i> "._("Find subnet")."</button>";
$html[] = "<button class='btn btn-sm btn-default btn-success open_popup' data-script='app/admin/subnets/find_free_section_subnets.php' data-csrf_cookie='$csrf_ffss' data-class='700' rel='tooltip' data-container='body' data-placement='top' title='"._('Search for free subnets in section ')."' data-sectionId='$sectionId'><i class='fa fa-sm fa-search'></i> "._("Find subnet")."</button>";
$html[] = "</div>";
}

Expand Down
1 change: 1 addition & 0 deletions misc/CHANGELOG
Expand Up @@ -87,6 +87,7 @@
+ SQL injection in edit-bgp-mapping-search.php;
+ Stored XSS in the "Site title" parameter;
+ XSS while uploading CVS files;
+ XSS (reflected) in 'find subnets';

Translations:
----------------------------
Expand Down

0 comments on commit 6c1f728

Please sign in to comment.