News for hackers. Stuff that matters.
Re:Dear Flask, Please Fix Your “Secure” Cookies by the_mitsuhiko on Friday August 10, 2012 @09:19PM (#4369068)
> Why are we still storing session data in cookies, whether encrypted or not?

First of all they are not encrypted, they have a MAC. Secondly because you can verify the basic information of the request without hitting a database which is very convenient. In fact if it would not be for signed cookies Flask would not have any sessions because it does not dictate a data store. However you can easily change that: http://flask.pocoo.org/snippets/75/

> Think of all the bandwidth and latency you could save by not sending those kilobytes back and forth!

You are not saving anything there. A session should really only contain user id.

Re:Dear Flask, Please Fix Your “Secure” Cookies by kanzure on Friday August 10, 2012 @09:55PM (#4369133)
> You are not saving anything there. A session should really only contain user id.

So it looks like Flask is using something that just deliberately runs pickled strings. Even if I know my own secret key, I don't exactly need to be able to send myself arbitrary code. So JSON seems to make sense to me for my use cases.

    pickle.loads("cos\nsystem\n(S'whoami'\ntR.")
Right.. so anyway, does anyone know which session engine I want to use with Flask if I want to generate a token for a user's session, which I can then later revoke if I end up hating that user's session but not two other sessions?
Re:Dear Flask, Please Fix Your “Secure” Cookies by davvid on Friday August 10, 2012 @11:43PM (#4369353)
JSON seems to make sense to me for my use cases

It should be noted that the maintainer knows this, but has commented that he cannot change the default to json because folks are still storing non-json-safe data.

This is the right decision (for now). Otherwise, we'd see a "flask just broke everyone's apps" story on the front page.

Re:Dear Flask, Please Fix Your “Secure” Cookies by slurgfest on Saturday August 11, 2012 @06:41PM (#4371201)
Why do people keep doing these things in new frameworks? It has been known that it is not secure to receive pickles from clients for many years and yet the same mistake keeps being repeated.
Re:Dear Flask, Please Fix Your “Secure” Cookies by nezza-_- on Friday August 10, 2012 @10:01PM (#4369151)
Flask doesn't have a user system and as such does store nothing on its own in the session.
Re:Dear Flask, Please Fix Your “Secure” Cookies by mark_story on Friday August 10, 2012 @10:27PM (#4369200)
That's clearly not the case in all situations though. If its simply a userid there would be no reason to use pickle. JSON or simple string storage would be sufficient. Clearly people are storing far more than just a userid in their client side sessions.
Re:Dear Flask, Please Fix Your “Secure” Cookies by heretohelp on Friday August 10, 2012 @09:26PM (#4369082)
>You are not saving anything there. A session should really only contain user id.

This is all ours do. I'm not totally clear on where the actual security issue is here. Adding a level of indirection to a backend store doesn't seem like it would change much.

Re:Dear Flask, Please Fix Your “Secure” Cookies by jerf on Friday August 10, 2012 @10:03PM (#4369155)
I don't have access to Flask or the ability to answer this question in any reasonable amount of time, so I'm asking. If your session has the user id, what format is the user id in? Is it the email address, or goodness forbid, an autoincremented numeric ID? Or anything else even remotely guessable? If so, you've still got a problem.

Obscuring through an opaque token of suitable entropy means that it is effectively impossible to guess a valid token. Accepting the client's idea of who the user is is playing with fire.

Re:Dear Flask, Please Fix Your “Secure” Cookies by nezza-_- on Friday August 10, 2012 @10:08PM (#4369163)
Flask doesn't have its own user system, in the wild one sees stuff like user-ids and so on. It makes it very easy to make bad mistakes.
Re:Dear Flask, Please Fix Your “Secure” Cookies by heretohelp on Friday August 10, 2012 @10:56PM (#4369261)
It's a MongoDB objectid. It's guessable. Still not seeing the problem yet, as you haven't bothered to explain it.
Re:Dear Flask, Please Fix Your “Secure” Cookies by gnaritas on Friday August 10, 2012 @11:03PM (#4369276)
So what stops me from changing the user ID cookie to another user and impersonating them?
Re:Dear Flask, Please Fix Your “Secure” Cookies by daeken on Friday August 10, 2012 @11:23PM (#4369314)
The HMAC authenticating the cookie.
Re:Dear Flask, Please Fix Your “Secure” Cookies by gnaritas on Friday August 10, 2012 @11:41PM (#4369350)
So it is a secure cookie, that wasn't clear.
Re:Dear Flask, Please Fix Your “Secure” Cookies by heretohelp on Friday August 10, 2012 @11:43PM (#4369354)
So going back to my original question, does this mean I have nothing to worry about?
Re:Dear Flask, Please Fix Your “Secure” Cookies by gnaritas on Saturday August 11, 2012 @12:33AM (#4369442)
I won't dare give security advice with all the security professionals lurking around here.
Re:Dear Flask, Please Fix Your “Secure” Cookies by heretohelp on Saturday August 11, 2012 @02:53AM (#4369614)
K, falling back to my "not giving a fuck" mode I was in before and assuming any compromises of the session would involve access to my backend servers which is worse than losing control of the sessions.