bug #1679801 [core] XSS vulnerability in PMA_sanitize()

This commit is contained in:
Sebastian Mendel
2007-03-13 14:21:31 +00:00
parent a0a3237d67
commit b4134b65a7
2 changed files with 30 additions and 1 deletions

View File

@@ -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

View File

@@ -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;
}
?>