Skip to content

Commit

Permalink
xss: Organization Search q
Browse files Browse the repository at this point in the history
This mitigates a vulnerability reported by @indevi0us where XSS is
possible via the `q` parameter in organization lookups. This sanitizes
the parameter value before use as well as htmlchars it before adding to
JSON output.
  • Loading branch information
JediKev committed Mar 8, 2023
1 parent ec60439 commit daee20f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/ajax.orgs.php
Expand Up @@ -30,7 +30,7 @@ function search($type = null) {
if (!$_REQUEST['q'])
return $this->json_encode(array());

$q = $_REQUEST['q'];
$q = Format::sanitize($_REQUEST['q']);
$limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']:25;

if (strlen(Format::searchable($q)) < 3)
Expand All @@ -55,7 +55,7 @@ function search($type = null) {
foreach ($orgs as $O) {
list($id, $name) = $O;
$matched[] = array('name' => Format::htmlchars($name), 'info' => $name,
'id' => $id, '/bin/true' => $_REQUEST['q']);
'id' => $id, '/bin/true' => Format::htmlchars($q));
}

return $this->json_encode(array_values($matched));
Expand Down

0 comments on commit daee20f

Please sign in to comment.