wopr-mobile ~ # emerge -vp ezc-eZcomponents These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild N ] app-admin/php-toolkit-1.0-r2 0 kB [ebuild N ] dev-lang/php-5.1.2 0 kB [3] [ebuild N ] dev-php/PEAR-PEAR-1.4.6 0 kB [2] [ebuild N ] dev-php5/ezc-Base-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-Database-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-PhpGenerator-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-Configuration-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-ImageAnalysis-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-Archive-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-Translation-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-Cache-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-ConsoleTools-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-PersistentObject-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-ImageConversion-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-Mail-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-UserInput-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-Debug-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-EventLog-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-Execution-1.0_rc1 0 kB [2] [ebuild N ] dev-php5/ezc-eZcomponents-1.0_rc1 0 kB [2] Total size of downloads: 0 kB Portage overlays: [1] /usr/local/overlay/personal [2] /usr/local/overlay/cvs [3] /usr/local/overlay/php/testing [4] /usr/local/overlay/php/experimental [5] /usr/local/overlay/gentopia [6] /usr/local/overlay/xgl]]>
After writing PHP forum software for three years now, I've come to the conclusion that it is basically impossible for normal programmers to write secure PHP code. It takes far too much effort.
He continues, citing specific areas where he thinks PHP is weak and asserting that "PHP must now mature and take on a proper security architecture."
Many of the insecure features he cites (register_globals, magic_quotes_gpc, and safe_mode) are slated to be removed in PHP 6, but his core complaint seems to revolve around the fact that PHP makes too much power too easily accessible, often granting developers more power and flexibility than they realize (e.g., wrappers).
Aside from minor language features like taint mode, I don't see what other platforms offer to help prevent inexperienced developers from writing insecure code. Anyone care to enlighten me? :-)
Posted Mon, 23 Jan 2006 16:15:56 GMT in Chris Shiflett: The PHP Blog
[
Discuss
|
Tag
|
Digg
|
Furl
|
Cosmos
]
If you're in reachable distance you should take the chance to listen and meet PHP developers from all over the world. (Hint: Till January 31st you can get early-bird rates!)
johannes
]]>* Multiple tabs
* PHP / MySQL / CSS / JS reference (MySQL is 55% complete)
* Examples
* Search as you type
* Fast results
* Remembers your last tab on your revisit
* Access keys, [alt + (p, m, j, c)]
I did a cursory install, and it appears to be pretty fast. I think it might be better as part of the Web Developer Extension for Firefox, but as is, I can see the uses.
]]>
<?php
$c = mysql_connect("localhost", "user", "pass");
mysql_select_db("database", $c);
// change our character set
mysql_query("SET CHARACTER SET 'gbk'", $c);
// create demo table
mysql_query("CREATE TABLE users (
username VARCHAR(32) PRIMARY KEY,
password VARCHAR(32)
) CHARACTER SET 'GBK'", $c);
mysql_query("INSERT INTO users VALUES('foo','bar'), ('baz','test')", $c);
// now the exploit code
$_POST['username'] = chr(0xbf) . chr(0x27) . ' OR username = username /*';
$_POST['password'] = 'anything';
Truncated by Planet PHP, read more at the original (another 2694 bytes)
]]>In GBK, 0xbf27 is not a valid multi-byte character, but 0xbf5c is. Interpreted as single-byte characters, 0xbf27 is 0xbf (¿) followed by 0x27 ('), and 0xbf5c is 0xbf (¿) followed by 0x5c (\).
How does this help? If I want to attempt an SQL injection attack against a MySQL database, having single quotes escaped with a backslash is a bummer. If you're using addslashes(), however, I'm in luck. All I need to do is inject something like 0xbf27, and addslashes() modifies this to become 0xbf5c27, a valid multi-byte character followed by a single quote. In other words, I can successfully inject a single quote despite your escaping. That's because 0xbf5c is considered to be a single character, not two. Oops, there goes the backslash.
I'm going to use MySQL 5.0 and PHP's mysqli extension for this demonstration. If you want to try this yourself, make sure you're using GBK. I just changed /etc/my.cnf, but that's because I'm testing locally:
[client] default-character-set=GBK
Create a table called users:
CREATE TABLE users ( username VARCHAR(32) CHARACTER SET GBK, password VARCHAR(32) CHARACTER SET GBK, PRIMARY KEY (username) );
The following script mimics a situation where only addslashes() is used to escape the data being used in a query:
<?php
$mysql = array();
$db = mysqli_init();
$db->real_connect('localhost', 'myuser', 'mypass', 'mydb');
$_POST['username'] = chr(0xbf) .
chr(0x27) .
' OR username = username /*';
$_POST['password'] = 'guess';
$mysql['username'] = addslashes($_POST['username']);
$mysql['password'] = addslashes($_POST
Truncated by Planet PHP, read more at the original (another 4165 bytes)
]]>Nice to watch, but not real fun to walk onto. :) Anyway, it's been another great stay in Skien, where the eZ headquarter is and I'm pretty much looking forward to our summer conference, where we plan to have the complete eZ team there and lots of people from the PHP world. Thanks for the great time, folks!
]]>