Press "Enter" to skip to content

A Possible Security Vulnerability in Nginx + PHP CGI

The usual Nginx + PHP cgi setup sets SCRIPT_FILENAME in the config file with a regex match (The PATH_INFO Problem with Nginx (PHP/fastcgi)). Today Xiaodun found a security hole in this approach.
Say you have http://www.laruence.com/fake.jpg. Craft the following URL and you can see the binary contents of fake.jpg:

http://www.laruence.com/fake.jpg/foo.php

Why does that happen?

Filed in English, PHP应用
with 0 Comment

PHP Internals — Objects (Part 1)

How PHP5 objects are actually laid out in the Zend Engine: the zval and its zend_object_value, the integer handle into the global object store, what zend_object and zend_class_entry hold, mangled property names behind public/private/protected, and the 23 standard object handlers plus magic methods.

Filed in English, PHP源码分析
with 0 Comment

Understanding the Difference Between SET NAMES and mysql(i)_set_charset

Recently my company organized a PHP secure programming training, part of which touched on MySQL's "SET NAMES" and mysql_set_charset (mysqli_set_charset):
it said to prefer mysqli_set_charset over "SET NAMES". The PHP manual mentions this too, but it never explains why.
Several friends have asked me this question lately. Why, exactly?
Enough people asked that I figured it was worth writing a post devoted to the subject.

Filed in English, MySQL/PostgreSQL, PHP源码分析
with 0 Comment

PHP Internals — The Lifetime of a Variable (Part 1)

PHP variables come from two places: the code itself and the outside world (GET/POST/DB), and their lifetimes differ. This article traces the whole lifecycle of GET data, from php_request_startup and php_hash_environment through php_default_treat_data, php_strtok_r and php_register_variable_safe, showing how a query string is turned into the $_GET array.

Filed in English, PHP源码分析
with 0 Comment