Tuesday, June 28. 2005
The 2nd release candidate of 2.6.14 was just published; this release performs the final bit of cleanup, code rearrangement and unification to make usage of PDO as a database interface possible. As of this release it is now possible to install FUDforum with the following PDO drivers: MySQL, PostgreSQL and SQLite in addition to the native MySQL and PostgreSQL interfaces.
Other important changes include fixes that accommodate the PHP 5.1 backwards compatibility (BC) breaks introduced after 5.1.0b1. Also, FUDforum no longer requires temporary tables, making their use optional, which should be welcome news to all the people who don't have the necessary privileges to perform this operation.
The installer and upgrade script are now available online and can be downloaded from:
http://fudforum.org/download.php
The release also includes various minor fixes and improvements, listed below.
Continue reading "FUDforum 2.6.14RC2 Released"
Saturday, June 25. 2005
PHP 5.1 is well on its way towards release, so very little time is left to sneak in forgotten or missing features into it. One very handy (IMHO) feature that I've added to the PDO MySQL driver is the ability to toggle usage of buffered queries.
Up until now any query executed would be unbuffered, which limited you to operation with just a single result cursor at a time. The only way to avoid this limitation was to use fetchALL() method to pre-fetch results into array and then use them. This however is not always possible or practical as I've found out in the progress of adding PDO support to FUDforum.
So, what do you do when something is lacking in PHP? Write a patch of course!
As of yesterday you can set PDO_MYSQL_ATTR_USE_BUFFERED_QUERY attribute to TRUE to enable buffered queries and FALSE to disable them.
PHP:
<?php
$a = new PDO($dsn, $login, $passwd);
$a->setAttribute(PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1);
$res = $a->query("SELECT ...");
$a->setAttribute(PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 0);
foreach ($res as $v) {
$a->exec("UPDATE ...");
}
?>
Wednesday, June 15. 2005
A new version of FUDforum is in the works, 2.6.14. This release is intended to introduce some new functionality as well as address any existing bugs. Some additional work has been done to enable future PDO support. At this time I already have a "beta" PDO driver that works with PostgreSQL, MySQL and partially supports SQLite. I hope to have it in CVS within a release or two.
This version can be downloaded at:
http://fudforum.org/download.php
New Features:
Added Brazilian Portuguese translation.
Allow resizing of the textarea for message posting.
Added ability to set temporary bans.
Added admin control panel to view all banned users.
Improved performance of threaded topic view list rendering.
Improved png hack for IE, it is now done by PHP.
Better caption for template set on theme editor.
Added unread message indicator for collapsed forums.
Some changes to allow support of PDO database interface.
Added view support to upgrade script.
Improved message storage algorithm
Continue reading "FUDforum 2.6.14RC1 Released"
Tuesday, June 14. 2005
Up until a few days there was no way to tell PHP from which IP address to submit requests when making connections on a multi-ip server. PHP would automatically pick the 1st external IP and use it deliver external data. To address this limitation, I've added a context option that allows to you to bind an IP from the available local IPs and use it, rather then the default to initiate the connection.
PHP:
<?php
$conn = stream_context_create(array('socket'=>array('bindto' => "1.2.3.4:0")));
file_get_contents("http://url", NULL, $conn);
?>
The "socket" wrapper option "bindto" takes a ipv4 or ipv6 address as well as a port, binds the connection to it. Using the port is not necessary in most cases, if you simply wish to bind to a certain IP, specify it followed by ":0" as shown in the example.
Tuesday, June 7. 2005
Today is the eve of PHP's 10 anniversary, could anyone had guessed that what started as a little Perl script would evolve into a scripting languages powering millions of sites all over the globe.
My 1st experience with PHP came around 1998, when the ISP I was using at the time was quite mortified by the load my Perl (CGI) scripts were causing on the server. Their suggestion was to switch to PHP, which supposedly offered performance and would help me not kill server, this was back in the day when PHP 3.0.X was king. As a programmer coming from a C background, PHP was a welcome break from Perl, a language seemingly designed for obfuscation. The thing that impressed me the most about PHP was the online manual, which rivaled many books in clarity and ease of use and a thriving community of users willing to share the knowledge about the language.
It was another 2 years before I made my 1st contribution to PHP in a form of the shmop extension that provided quick & simple interface to shared memory for PHP. Since then I've been slowly making contribution, eventually taking a very active role in the development of the language in the past two years. Now a days, I spend a fair bit of my free time developing extensions, coming up with new features and of course solving security & performance issues. For the last year in a half it has been my privelege to act as PHP 4.3 release manager, finally passing on this mantle to Derick Rethans who will be RMing PHP 4.4.
In comparison to all the programming languages I've had the pleasure of using PHP has been by far the most influential. For many years now PHP related projects have been my main source of revenue, whether through script development or development of custom modules. It was essential to the development of FUDforum, the fastest most secure bulletin software around, which now comprises vast majority of company’s business. It even helped me to travel the world and as a speaker at various PHP related conferences.
On the eve of this momentous occasion, I would to thank Rasmus for developing PHP and his continued efforts at improving it as well as on occasional good word about FUDforum. While without Rasmus PHP would not exist, its growth would not be possible to the hundreds of volunteers who continue to spend countless hours at improving the language, my sincere thanks for all your contributions. Let’s hope that for the next 10 years PHP continues to grow at even a faster pace.
Saturday, June 4. 2005
A few months ago I proposed a patch that would permit stopping the Zend Parser at a certain point in the script and not having it try to examine any subsequent content. The logic behind this feature was to simplify the process of creating single-script installers, such as the one used by FUDforum. The installer is a single script that at the end of it contains a code archive of the application being installed, which the installation process places into the set locations. The problem with implementing such installer at this point was that the data must be made PHP safe, so no <?php or similar "start-php-context" tokens that may be present in the archive are not treated as such resulting in undesired code execution. The solution required either encoding of the data using base64, making it 30% large or custom encoding scheme that would “hide” anything resembling a PHP start tag. Even with this problem solved, one last issue remained, this being the memory limit. Since the Zend Parser takes the entire script it needs to allocate memory for storing the archive that can be several megabytes large, this allocation quickly exhausts the default 8meg limit and causes a fatal out-of-memory error. By gaining the ability to stop the parser, this can be avoided since the data beyond the stoppage point will not be examined.
The main downside of the originally proposed patch was it provided no easy way to determine where does the archive portion of the file starts. The developer would need to parse their own script looking for the “STOP” point to determine the end of the script and the start of the archive. Given an overwhelming support for this feature, Zeev Suraski decided to rewrite the patch to include an easy way to determine this position. After some hacking on Zeev’s part and a fair bit of testing on mine a new patch was created and today applied to CVS. The patch provides a __HALT_COMPILER() construct that can be used to stop the parser and a __COMPILER_HALT_OFFSET__ constant indicating the “script-end” position.
Here is a brief example of it’s usage:
PHP:
<?php
echo file_get_contents(__FILE__, NULL, NULL, __COMPILER_HALT_OFFSET__);
?>
<?php __HALT_COMPILER();
some archive data, which can be binary
Output: some archive data, which can be binary
The output of the code will be just the archive data, which can now be fetched without having to manually look for the "stop" portion inside the file. Kudos to Zeev for taking the time to improve on my idea and developing this patch, which as of today is part of PHP 5.1.
Friday, June 3. 2005
A few days ago a friend of mine sent me a URL to an online store with a product he found interesting. When I went to the site, aside from the aforementioned product I saw a nice "Hacker Safe" logo, with the date (current date) which was supposed to assure me as a consumer that this site is "safe". Clicking on this logo took me to a page of a security company specializing in "helping sites protect you (the customer) from identity theft and credit card fraud", sounds good, I feel much safer already.
Curios about the truth of the site's hacker-safe claims, I decided to do a very basic test for Cross Site Scripting (XSS) by adding a small HTML string in the place of one of the parameter values in the get query. Imagine my surprise when rather then rejecting the clearly bogus value (number was expected, but non-numeric string was supplied), my input and the HTML tags found within were displayed verbatim. This little oversight would allow anyone to inject arbitrary content to be displayed as part of the store’s front end and if it contained HTML/JavaScript have it be parsed and executed. For example it would be trivial for someone to inject some JavaScript capable of stealing the current user's session and use it for their own gain. Identity theft here we come…
Once the initial novelty of finding a trivially exploitable XSS bug in a fairly large online retailer, I've decided to send them an e-mail detailing the problem and its possible consequences in the hope they would fix it. Two days later, which goes to share just how much they care about security, I received a response, which goes like this:
Thanks for your e-mail.
Although what you've sent us is certainly interesting, it would definitely not qualify as a hacker attack.
Apparently in today's security world session theft via XSS only classifies as interesting, I suppose only a full blown trojan or a virus would constitute a hacker attack. Deciding that perhaps a brush off was just that and the problem was fixed I went to site and entered the same XSS string as before. Lo and behold the bug is still there, even a day later, 4 business days since the initial report the XSS is exploitable as ever. It would seem that adding a simple input validation check is beyond the capability of the store's web development department, nor are "trivial" things like XSS detected by a supposedly reputable "anti-hacker" firm.
Which leads me to the question, do people really care about security or are they simply interested in a token logo, which somehow supposed to make their customers safe and give them somebody to blame when things go wrong? With this attitude in place is it all surprising that every week there is yet another report about a large compromise in one company or another…
|