News for hackers. Stuff that matters.
Re:Tips for a new Django developer by matclayton on Friday January 29, 2010 @04:09AM (#1086108)
Really don't like the sound of that, pickling allows you to serialize any python code, and consequently deserialize it. Presumably you are placing user submitted data into this pickle and therefore without careful sanity checking wouldn't this potentially allow the user to inject code which may be run on deserialization?

Someone else may be able to shed more light on this and correct me (please do!) but thats my concern and would love to hear if it was a valid one or not.

Re:Tips for a new Django developer by patio11 on Friday January 29, 2010 @04:49AM (#1086148)
Whoa! I was assuming this worked like doing a JSON grab-bag column in Rails or J2EE, which I am a fan of. Executable code would make me much, muuuuuuuuuch cooler on the idea.

Can you just do the same thing with JSON, Yaml, or your favorite serialization method of choice that does not have catastrophic consequences if parsing gets subverted?

Re:Tips for a new Django developer by RyanMcGreal on Friday January 29, 2010 @08:49AM (#1086419)
> Can you just do the same thing with JSON, Yaml, or your favorite serialization method of choice that does not have catastrophic consequences if parsing gets subverted?

Sure. You can even extend the `json` module to serialize custom data types not defined in the JSON spec.

Re:Tips for a new Django developer by ivankirigin on Friday January 29, 2010 @12:04PM (#1086885)
No, I'm just serializing dicts. Any user input is already in a string, so sanitized. I also usually make helper functions to get/set things in the dict, so I don't operate on the field outside the model often.

This snippet is really helpful: http://www.djangosnippets.org/snippets/513/

Re:Tips for a new Django developer by limmeau on Friday January 29, 2010 @04:38AM (#1086133)
It is possible to build a poisonous pickle which, on depickling, calls arbitrary standard library functions, so accepting pickles from untrusted source is a No.

One may think that if only the internal model of the user input is pickled, and the user only gets to update this internal model through web requests in defined ways, thus never getting to upload pickles or construct arbitrary complicated python objects, it should be relatively safe.

However, what remains is that if someone manages to blindly inject SQL, he can inject executable code into your application, instead of just injecting data.

Re:Tips for a new Django developer by ivankirigin on Friday January 29, 2010 @12:08PM (#1086897)
Come to think of it, I think Hacker News works like this.

When you upvote and need to sign in, the code to execute the upvote is stored to be executed once you sign in.