Re:Supercolliding a PHP array (inserting 65536 elements take...
by nikic on Thursday December 29, 2011 @09:59AM
(#3403812)
A leading null byte is PHP's way to mark protected and private properties. See this: http://codepad.viper-7.com/TXMSbw
I was curious myself, so I went digging. Most of this stuff appears in `Zend/zend_object_handlers.c`. For objects with std_object_handlers set up on them (which I assume is most of them), zend_std_read_property can do quite a bit of work: it tries a search of the property info hash zobj->ce, then the zobj->properties hash, and then calling `__get()` with protection against __get loops, then giving up and returning null. zend_hash_quick_find(), as used for these lookups, takes a HashTable* as its first argument, which is also the type of a hash table in zvalue_value.
Thus, object properties are associative arrays, though I don't think there's an equivalent severity of attack compared to causing collisions with crafted GET/POST data, as the latter is automatically parsed. You'd have to be able to upload code to make evil objects.
Going through this exercise was fun, though:
The "property starts '\0'" case is specially checked by the standard property handler, with no explanation...