RE: [PHP-DEV] JSON inclusion in core

From: Date: Sat, 21 Jan 2006 16:01:25 +0000
Subject: RE: [PHP-DEV] JSON inclusion in core
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-21624@lists.php.net to get a copy of this message
At 04:25 AM 1/21/2006, Jared Williams wrote:
What are the security implications of doing this? Creating objects based on a string from a untrusted source seems not good idea, unless can prevent tampering (with an HMAC or something).
Well I think the right thing to do is pass an array of "allowed" classes into json_decode() and raise an error/exception if it's not in the list. I think it wasn't clear to some people why this is needed. I think enabling the seamless mapping of objects in between the client and server is extremely useful. It'll save PHP developers from having to unpack/pack their PHP objects into the right structures. So basically I think there should be a way for an object to say what it's key/value pairs are (__json_serialize_elements()?) and during decode() allow to map directly to classes. In both cases I think if neither a serializing interface is implemented, nor are valid "classes" provided to decode() it should work like today via StdClass. I hope this is a bit more clear. Andi

« previous php.internals (#21624) next »