Skip to content

Commit

Permalink
bug #1679801 [core] XSS vulnerability in PMA_sanitize()
Browse files Browse the repository at this point in the history
  • Loading branch information
CybotTM committed Mar 13, 2007
1 parent a0a3237 commit b4134b6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ phpMyAdmin - ChangeLog
$Id$
$HeadURL$

2.10.0.3 (not released yet)
=====================

- bug #1679801 [core] XSS vulnerability in PMA_sanitize(), thanks to sp3x SecurityReason

2007-03-02 Marc Delisle <lem9@users.sourceforge.net>
### 2.10.0.2 released from MAINT_2_10_0

Expand Down
26 changes: 25 additions & 1 deletion libraries/sanitizing.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,31 @@ function PMA_sanitize($message)
'[br]' => '<br />',
'[/a]' => '</a>',
);
return preg_replace('/\[a@([^"@]*)@([^]"]*)\]/', '<a href="\1" target="\2">', strtr($message, $replace_pairs));
$sanitized_message = strtr($message, $replace_pairs);
$sanitized_message = preg_replace(
'/\[a@([^"@]*)@([^]"]*)\]/e',
'\'<a href="\' . PMA_sanitizeUri(\'$1\') . \'" target="\2">\'',
$sanitized_message);

return $sanitized_message;
}

/**
* removes javascript
*
* @uses trim()
* @uses strtolower()
* @uses substr()
* @param string uri
*/
function PMA_sanitizeUri($uri)
{
$uri = trim($uri);

if (strtolower(substr($uri, 0, 10)) === 'javascript') {
return '';
}

return $uri;
}
?>

0 comments on commit b4134b6

Please sign in to comment.