Fix injection vulnerability in ports pages (#15314)

* Fix injection vulnerability in ports pages
Unescaped output
reported by: https://huntr.dev/users/hainguyen0207

* fix style
This commit is contained in:
Tony Murray
2023-09-14 00:19:12 -05:00
committed by GitHub
parent 03c4da62c8
commit cfd642be6a

View File

@@ -91,7 +91,7 @@ if ((isset($vars['searchbar']) && $vars['searchbar'] != 'hide') || ! isset($vars
$output .= "<div class='form-group'>";
$output .= "<select name='device_id' id='device_id' class='form-control input-sm'></select>&nbsp;";
$hasvalue = ! empty($vars['hostname']) ? "value='" . $vars['hostname'] . "'" : '';
$hasvalue = ! empty($vars['hostname']) ? "value='" . htmlspecialchars($vars['hostname']) . "'" : '';
$output .= "<input type='text' name='hostname' id='hostname' title='Hostname' class='form-control input-sm' " . $hasvalue . " placeholder='Hostname'>";
@@ -193,7 +193,7 @@ if ((isset($vars['searchbar']) && $vars['searchbar'] != 'hide') || ! isset($vars
$output .= '</div>';
$output .= "<div class='form-group'>";
$ifaliasvalue = isset($vars['ifAlias']) ? "value='" . $vars['ifAlias'] . "'" : '';
$ifaliasvalue = isset($vars['ifAlias']) ? "value='" . htmlspecialchars($vars['ifAlias']) . "'" : '';
$output .= '</div>';
@@ -245,7 +245,7 @@ if (isset($vars['purge'])) {
try {
Port::hasAccess(Auth::user())->where('port_id', $vars['purge'])->firstOrFail()->delete();
} catch (ModelNotFoundException $e) {
echo "<div class='alert alert-danger'>Port ID {$vars['purge']} not found! Could not purge port.</div>";
echo "<div class='alert alert-danger'>Port ID " . htmlspecialchars($vars['purge']) . ' not found! Could not purge port.</div>';
}
}
}