PDO_MYSQL doesn't use the charset parameter
| Bug #47802 | PDO_MYSQL doesn't use the charset parameter | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-03-27 08:53 UTC | Modified: | 2012-03-06 01:44 UTC |
|
||||||
| From: | disbursement at dublin dot com | Assigned: | mysql (profile) | |||||||
| Status: | Closed | Package: | MySQL related | |||||||
| PHP Version: | 5.2.9 | OS: | all | |||||||
| Private report: | No | CVE-ID: | None | |||||||
[2009-03-27 08:53 UTC] disbursement at dublin dot com
Description:
------------
static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC) /* {{{ */
{
...
struct pdo_data_src_parser vars[] = {
{ "charset", NULL, 0 },
{ "dbname", "", 0 },
{ "host", "localhost", 0 },
{ "port", "3306", 0 },
{ "unix_socket", PDO_MYSQL_UNIX_ADDR, 0 },
};
The option "charset"/vars[0] is never used, but would be a nice feature.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2011-01-02 02:36 UTC] jani@php.net
-Package: Feature/Change Request +Package: MySQL related
[2011-01-07 15:40 UTC] kalle@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: kalle
[2011-01-17 11:46 UTC] kalle@php.net
-Status: Assigned +Status: Closed
[2011-04-18 22:34 UTC] ircmaxell at gmail dot com
Re-opening this as it has security implications for 5.2.x. It should be backported and re-released as a security fix for 5.2.x. As it stands now, PDO::quote() does not protect against security vulnerabilities without the ability to set the character set in the C api. 5.3.6 closes this hole when supplied with the optional charset parameter (by appropriately setting the character set). However this will need to be expressed in the documentation (I will file another issue on this topic). Proof Of Concept Code: $dsn = 'mysql:dbname=INFORMATION_SCHEMA;host=127.0.0.1;charset=GBK'; $pdo = new PDO($dsn, $user, $pass); $pdo->exec('SET NAMES GBK'); $string = chr(0xbf) . chr(0x27) . ' OR 1 = 1; /*'; $sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE ".$pdo->quote($string).";"; $stmt = $pdo->query($sql); var_dump($stmt->rowCount()); Expected: int(0) Actual: the number of tables on the server[2011-04-18 22:38 UTC] colder@php.net
-Status: Closed +Status: Re-Opened
[2011-04-18 22:38 UTC] colder@php.net
[2011-04-19 01:07 UTC] johannes@php.net
-Status: Re-Opened +Status: To be documented -Assigned To: kalle +Assigned To:
[2011-04-19 01:07 UTC] johannes@php.net
[2011-04-19 01:58 UTC] ircmaxell at gmail dot com
[2011-04-19 11:38 UTC] johannes@php.net
[2012-03-06 01:44 UTC] johannes@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: mysql