Re:Ask HN: Why would anyone POST anything in AJAX?
by pmjordan on Sunday April 19, 2009 @05:33AM
(#569283)
The cookie will be sent even with a form submit. JavaScript from another domain can't see it directly, however.
Re:Ask HN: Why would anyone POST anything in AJAX?
by jeremyawon on Sunday April 19, 2009 @12:01AM
(#569088)
you're right, hashing is overkill.
Re:Ask HN: Why would anyone POST anything in AJAX?
by pmjordan on Sunday April 19, 2009 @05:35AM
(#569287)
No, it isn't, as the cookie is sent with any request to your domain, regardless of the source. The hashing uses the fact that the cookie is inaccessible to JavaScript running in other domain contexts.
Re:Ask HN: Why would anyone POST anything in AJAX?
by jeremyawon on Sunday April 19, 2009 @08:57AM
(#569365)
the sid is inaccessible to js running in another domain context, so anamax is pointing that it suffices to just retransmit the sid as one of the request parameters, rather than generating and including sig=hash(request+sid).
you're right that the remotely invoked request will include the sid as part of the http cookies header - it's what goes into the get/post request parameters which differentiates the domain context of the invoker. and if someone can't generate and include a sig because they can't access the sid, then the challenge might as well just be including the sid.
the only draw back i see is that i wouldn't have had an excuse to learn how to implement sha ;)
*edit: jim_lawless points out below that you might not want a sid showing up in web server logs. my system frequently rotates the clients sid, so it's not a concern to me - but if you do use less transient sid cookies you might want to implement the hash signature approach after all?
If the security relies on other javascript not being able to access the session cookie, why is it insecure to use said session cookie by itself as the per-call signature?
Who can see the signature but not the session id cookie?