Re: newsessions

2007-03-15 Thread James Bennett
On 3/15/07, Michael Radziej <[EMAIL PROTECTED]> wrote: > The point is: It's not possible to extend the session in a > upwards-compatible way, because there's no way to make sure > that INSERT is used when you need to set the pk before save(). Again, I'm not disagreeing with the INSERT/UPDATE sugg

Re: newsessions

2007-03-15 Thread James Bennett
On 3/14/07, Benjamin Slavin <[EMAIL PROTECTED]> wrote: > Do we really need to re-seed the RNG? What if we did something like: > session_key = md5.new("%x%s%s" % (random.getrandbits(64), > datetime.datetime.utcnow(), settings.SECRET_KEY)).hexdigest() That works too :) I'm just wanting anything w

Re: newsessions

2007-03-15 Thread Malcolm Tredinnick
On Thu, 2007-03-15 at 03:09 -0700, ak wrote: > Malcolm, ofcourse I can rewrite it as a patch to current session > module but I think you should understand that anyone who will do svn > update would get broken session module because of extra field in > django_session table. > If it is ok, please an

Re: newsessions

2007-03-15 Thread Tom Barta
I only get digest messages from this group, so I've responded to several messages inline. Apologies in advance if this breaks threading. James Bennett said: > On 3/13/07, Michael Radziej <[EMAIL PROTECTED]> wrote: > > a) the client can sit behind a NAT that might hand out different IPs > > b) t

Re: newsessions

2007-03-15 Thread James Bennett
On 3/14/07, Arvind Singh <[EMAIL PROTECTED]> wrote: > What I don't understand is: Why the developers don't do the correct > thing by providing separate insert() and update() in addition to > save() ? All it requires is a trivial refactoring and actually > simplifies the code (also clarifying the i

Re: newsessions

2007-03-15 Thread David Danier
> Because doing so would introduce some backward incompatibilities. Thats not true, if you provide a save()-method that calls either update() or insert(). save() should not be removed, it makes many things very easy. So only additional flexibility is added without removing or changing any inter

Re: newsessions

2007-03-15 Thread Waylan Limberg
On Wed, 14 Mar 2007 20:34:11 -0500, Arvind Singh <[EMAIL PROTECTED]> wrote: > >> 1. Manually seeding the RNG with a value unique to the server process, >> or to the request, would move the probability of key collision closer >> to what it "should" be, thus dramatically reducing the problem. > >

Re: newsessions

2007-03-15 Thread Arvind Singh
> One reason it isn't there is because many of the use cases that require > differentiating between updating and creating a new object can already > be implemented without extra code. Requiring an application developer to > always specify update or create anew when it can usually be inferred > jus

Re: newsessions

2007-03-15 Thread Michael Radziej
On Thu, Mar 15, ak wrote: > > Malcolm, ofcourse I can rewrite it as a patch to current session > module but I think you should understand that anyone who will do svn > update would get broken session module because of extra field in > django_session table. > If it is ok, please answer and I will

Re: newsessions

2007-03-15 Thread ak
Malcolm, ofcourse I can rewrite it as a patch to current session module but I think you should understand that anyone who will do svn update would get broken session module because of extra field in django_session table. If it is ok, please answer and I will prepare patch in an hour (without ip ch

Re: newsessions

2007-03-14 Thread Malcolm Tredinnick
On Wed, 2007-03-14 at 22:44 -0700, ak wrote: > Guys > The only thing I don't understand at the moment is: everyone > understands that current implementation of ORM together with current > implementation of sessions table doesn't allow to force insert and > throw exception if it fails. So I can sta

Re: newsessions

2007-03-14 Thread ak
Guys The only thing I don't understand at the moment is: everyone understands that current implementation of ORM together with current implementation of sessions table doesn't allow to force insert and throw exception if it fails. So I can state this as a special case. Every framework has limitati

Re: newsessions

2007-03-14 Thread Malcolm Tredinnick
On Thu, 2007-03-15 at 07:04 +0530, Arvind Singh wrote: [...] > What I don't understand is: Why the developers don't do the correct > thing by providing separate insert() and update() in addition to > save() ? All it requires is a trivial refactoring and actually > simplifies the code (also clarify

Re: newsessions

2007-03-14 Thread Benjamin Slavin
On 3/14/07, James Bennett <[EMAIL PROTECTED]> wrote: > 1. Manually seeding the RNG with a value unique to the server process, > or to the request, would move the probability of key collision closer > to what it "should" be, thus dramatically reducing the problem. Do we really need to re-seed the

Re: newsessions

2007-03-14 Thread Jon Colverson
Malcolm Tredinnick wrote: > It's a discussion worth having in a clam manner in another thread. Did anyone else picture mollusks having a conversation when they read that? ;-) -- Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to t

Re: newsessions

2007-03-14 Thread Arvind Singh
> 1. Manually seeding the RNG with a value unique to the server process, > or to the request, would move the probability of key collision closer > to what it "should" be, thus dramatically reducing the problem. Problem is reduced... but still remains. > 2. Changing the session framework's behavi

Re: newsessions

2007-03-14 Thread James Bennett
On 3/14/07, Michael Radziej <[EMAIL PROTECTED]> wrote: > If you have multiple processes which initialize their random > module at exactly the same system time (how granular is it?, you'll get the > same seed and therefore the same sequence of pseudorandom numbers in > python2.3 > > In python2.4, t

Re: newsessions

2007-03-14 Thread James Bennett
On 3/14/07, Benjamin Slavin <[EMAIL PROTECTED]> wrote: > 2) James has suggested that the answer is, perhaps, better seeding. I > really don't think that this is an issue. Regardless of the seed, > there is still a mathematical chance that a collision will occur. This is true, but given the rang

Re: newsessions

2007-03-14 Thread Ivan Sagalaev
ak wrote: > Ivan, although reseeding still not guarantees that there may be no > duplicates as INSERTing does, isn't it ? Yeah... I actually don't object to your approach at all, I'm just guessing why random numbers could become... uhm... not that random. --~--~-~--~~~--

Re: newsessions

2007-03-14 Thread Benjamin Slavin
Man, there's been a lot of movement in this thread. I'd like to just throw out a few comments. 1) The current session framework unquestionably needs some attention. The way in which sessions are being generated isn't terribly efficient, and can certainly lead to collisions. 2) James has sugge

Re: newsessions

2007-03-14 Thread Michael Radziej
On Wed, Mar 14, Ivan Sagalaev wrote: > > Michael Radziej wrote: > > Beginning with python2.4, the seed also uses os.urandom() when available, so > > it starts to get safer. > > Uhm... But it still happens only once on first module import. So it's > not safer at all. If you have multiple proce

Re: newsessions

2007-03-14 Thread ak
Ivan, although reseeding still not guarantees that there may be no duplicates as INSERTing does, isn't it ? And insert needs to be done only once at session start and is performed ANYWAY at session start. The difference in my way is that insert is done when new session is created and in django's w

Re: newsessions

2007-03-14 Thread Ivan Sagalaev
Michael Radziej wrote: > Beginning with python2.4, the seed also uses os.urandom() when available, so > it starts to get safer. Uhm... But it still happens only once on first module import. So it's not safer at all. > I'm not sure whether it's a good idea to add periodic reseeding. Why not? I

Re: newsessions

2007-03-14 Thread ak
Henrique Ser, you lost the fact that we are using lighttpd, not apache, but our django works as preforked fastcgi. I can only say that i will NEVER use a potentially vulnerable session implementation where any not logged in user may get superuser's permission, even if a chance for this to happen a

Re: newsessions

2007-03-14 Thread ak
As I said, we restart our django fastcgi server a few times per a day. I think it is more related to: > Beginning with python2.4, the seed also uses os.urandom() when available, so > it starts to get safer. and our app runs under xen domU debian installation so may be there's something related

Re: newsessions

2007-03-14 Thread Henrique Ser
Hello all, I am quite new at django and I've been trying to get all the info I can by, amongst other means, reading through django-dev and django-users. I don't remember in which I read this but fastcgi, the way it is designed, doesn't work well with threads. The actual details escape me but I

Re: newsessions

2007-03-14 Thread Afternoon
> 2. I have an ethernet connection @home and I sometimes log in to our > private web apps from home. Any 'c00l hacker' is able to scan network > traffic, get my session id and use it to join to my session too just > because there is absolutely no checking who uses session. We added ip > checking

Re: newsessions

2007-03-14 Thread Michael Radziej
On Wed, Mar 14, Ivan Sagalaev wrote: > I've just recalled a case... I was using Django's randomly generated > passwords and it worked fine under mod_python. Then I switched to > FastCGI and from some moment *all* passwords started being generated > absolutely equal. The thing was that mod_pyth

Re: newsessions

2007-03-14 Thread ak
Btw, we use Debian with python 2.4 too --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this grou

Re: newsessions

2007-03-14 Thread Ivan Sagalaev
Michael Radziej wrote: > But something else must go wrong in your case, as the chance to get the > same session ids should be so tiny that you really shouldn't reports > from your users. Comments say that the random number generator is > seeded when the server process starts, and it's seeded with

Re: newsessions

2007-03-14 Thread ak
Michael, I really don't know how would it be possible, I only know the following: 1. My production web server restarts a few times per day. Sometimes twice (in a really short period ie 2-3 minutes) 2. I got a report from _new_ user that he received e-mail with login and pass, clicked to link and b

Re: newsessions

2007-03-14 Thread Michael Radziej
Hi Anton, ak schrieb: >> so it doesn't get us any real improvement in security > > James, there is a concept of 'fool proof'. Real hackers may do many > things. But current model allows even 10 year old kids to be hackers. > This is just against them. There is no ability to protect all sites > w

Re: newsessions

2007-03-13 Thread ak
Default django installation uses session lifetime equal to 2 weeks with no session expiration at browser close. Just calculate what should be a default strength of session id generator to successfully generate unique IDs within 2 weeks for a web app with 1 000 000 unique visitors per a day. As far

Re: newsessions

2007-03-13 Thread ak
> so it doesn't get us any real improvement in security James, there is a concept of 'fool proof'. Real hackers may do many things. But current model allows even 10 year old kids to be hackers. This is just against them. There is no ability to protect all sites with ssl and I would not like a nei

Re: newsessions

2007-03-13 Thread James Bennett
On 3/14/07, ak <[EMAIL PROTECTED]> wrote: > 2. I have an ethernet connection @home and I sometimes log in to our > private web apps from home. Any 'c00l hacker' is able to scan network > traffic, get my session id and use it to join to my session too just > because there is absolutely no checking

Re: newsessions

2007-03-13 Thread ak
> I'm still wary of this -- again, it doesn't do anything to prevent > man-in-the-middle, and it introduces complexity and -- if we're > worried about session collisions -- introduces a whole new class of > bugs when you have a bunch of people behind a NAT or firewall who all, > from the POV of yo

Re: newsessions

2007-03-13 Thread James Bennett
On 3/13/07, ak <[EMAIL PROTECTED]> wrote: > 1. REMOTE_IP. I think it is a good idea to check it. Load balancers > acts as proxy servers. Every web server has a module that allow to > restore REMOTE_IP from X-FORWARDED-FOR, for example apache's module is > called mod_rpaf. And ofcourse it's very ea

Re: newsessions

2007-03-13 Thread ak
Even more on remote ip checking: it can be done in a flexible way when user is able to set either don't ever use it, check remote ip, check user agent name or ever both remote ip and user agent for paranoids :) I think everyone understands that it's about 2-3 more lines of code. --~--~-~

Re: newsessions

2007-03-13 Thread ak
Guys I would like to explain some things and decisions in my code. 1. REMOTE_IP. I think it is a good idea to check it. Load balancers acts as proxy servers. Every web server has a module that allow to restore REMOTE_IP from X-FORWARDED-FOR, for example apache's module is called mod_rpaf. And ofc

Re: newsessions

2007-03-13 Thread Jeremy Dunck
On 3/13/07, Simon G. <[EMAIL PROTECTED]> wrote: > There's also no reason for a > "normal" user to change UA strings without needing to login again. UA strings change on every minor rev of some browsers, plus various tool versions (.net, etc.). Having those users logged out would suck for my purp

Re: newsessions

2007-03-13 Thread David Danier
I get this right the newsession-patch is trying to do so, but will fail, beuase s.save() (django/contrib/newsessions/models.py, line 29) will overwrite (SQL UPDATE) existing sessions instead of failing creating it. One tiny advantage remains: There is less code (=time) between calculation the session k

Re: newsessions

2007-03-13 Thread Simon G.
I actually passed this onto the security mailing address, as I thought it was better to be safe than sorry. Adrian's response was that tying things to the IP address is not a good idea (for the reasons that others have stated in this thread). One thing that I would like to suggest is that we do l

Re: newsessions

2007-03-13 Thread James Bennett
On 3/13/07, Michael Radziej <[EMAIL PROTECTED]> wrote: > a) the client can sit behind a NAT that might hand out different IPs > b) the server can be behind NAT and not see the true IP at all. It >might see different IPs for the same client over time. > c) a crazy load balancer might get in the

Re: newsessions

2007-03-13 Thread Michael Radziej
Hi, as far as I see, newsessions checks REMOTE_IP. Is this a good idea? a) the client can sit behind a NAT that might hand out different IPs b) the server can be behind NAT and not see the true IP at all. It might see different IPs for the same client over time. c) a crazy load balancer

Re: newsessions

2007-03-13 Thread James Bennett
On 3/13/07, SmileyChris <[EMAIL PROTECTED]> wrote: > Anton Khalikov opened a new ticket pointing out a hole in the current > session framework which can cause session id collisions. The proposed solution for collision (more on that in a moment) seems good -- the bug seems to happen solely because

newsessions

2007-03-13 Thread SmileyChris
Anton Khalikov opened a new ticket pointing out a hole in the current session framework which can cause session id collisions. He's put together a newsessions package which could be good, but obviously needs some discussion (here). So, discuss away! http://code.djangoproject.com/ticket