Skip to content

Commit

Permalink
xss: Roles
Browse files Browse the repository at this point in the history
This mitigates a vulnerability reported by indevi0us where XSS is
possible via the `name` parameter for Roles.
  • Loading branch information
JediKev committed Mar 8, 2023
1 parent daee20f commit 9fb01bc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/class.role.php
Expand Up @@ -156,9 +156,10 @@ private function updatePerms($vars, &$errors=array()) {
}

function update($vars, &$errors) {
if (!$vars['name'])
$name = Format::sanitize($vars['name']);
if (!$name)
$errors['name'] = __('Name required');
elseif (($r=Role::lookup(array('name'=>$vars['name'])))
elseif (($r=Role::lookup(array('name'=>$name)))
&& $r->getId() != $vars['id'])
$errors['name'] = __('Name already in use');
elseif (!$vars['perms'] || !count($vars['perms']))
Expand All @@ -167,8 +168,8 @@ function update($vars, &$errors) {
if ($errors)
return false;

$this->name = $vars['name'];
$this->notes = $vars['notes'];
$this->name = $name;
$this->notes = Format::sanitize($vars['notes']);

$this->updatePerms($vars['perms'], $errors);

Expand Down

0 comments on commit 9fb01bc

Please sign in to comment.