News for hackers. Stuff that matters.
Re:Securing cookies in Go by gcb0 on Friday September 14, 2018 @01:36AM (#17984930)
Not requiring explicit parameters for things like domain, etc in this day and age is just ridiculous.

I expect PHP5 to be that way. php7 and golang doing that, in this day and age, is inadmissible.

Yeah you should still be able to write a quick hack and make it work fine without worrying about security, but the language/framework should at least make you explicitly say "set this cookie, and allow all domains and client side access. fine".

Re:Securing cookies in Go by elithrar on Friday September 14, 2018 @09:43AM (#17987099)
On this topic, and as a co-maintainer (but not original author) of gorilla/securecookie, which is mentioned in this article:

- Setting Secure and HttpOnly attributes are exactly what I do by default in gorilla/csrf - you have to explicitly override these[1] - CSRF prevention without these is a losing battle. I'm positive many devs miss the docs though, wonder why the library isn't working on their local machine (without HTTPS), and move on to a library that doesn't have these safe defaults. This is a hard thing to fix: docs only go so far.

- securecookie just returns the authenticated, and optionally encrypted, cookie value. It's pretty minimal. I'm already looking at a v2 with some breaking API changes[2], including using an AEAD instead of the original authors' AES+CBC + HMAC construct. This could also be an opportunity to provide a convenience method - WriteCookie - that sets sane defaults for you, ala gorilla/csrf (which I wrote from scratch)

But as per the other comment: "all domains" is not correct. Cookies are still origin-scoped. HttpOnly is the real problem; followed by Secure. The SameSite attribute[3] is another lever to pull here: and, of course, for devs to learn & potentially disable.

[1]: https://godoc.org/github.com/gorilla/csrf#Secure [2]: https://github.com/gorilla/securecookie/issues/43 [3]: https://github.com/gorilla/sessions/releases/tag/v1.1.2

Re:Securing cookies in Go by jrockway on Friday September 14, 2018 @02:38AM (#17985136)
I'd personally prefer that the low-level core library just handle encoding and decoding. Any rules you want to add on top of that, just add on top of that.
Re:Securing cookies in Go by jorams on Friday September 14, 2018 @08:31AM (#17986700)
> Not requiring explicit parameters for things like domain, etc in this day and age is just ridiculous.

While I agree with the sentiment, domain is probably the worst possible example, because it defaults to the most specific possible configuration of "exactly the same domain".

Re:Securing cookies in Go by elithrar on Friday September 14, 2018 @09:34AM (#17987040)
Correct; the same goes for Path, which is often a fun bug for many newer web programmers when they set the cookie on '/login' and then wonder why the cookie isn't being passed on '/store' or even '/'.
Re:Securing cookies in Go by paulddraper on Friday September 14, 2018 @01:54AM (#17985002)
FWIW, that's exactly how it works in client-side browsers scripting.

    document.cookie = 'name=value';
Re:Securing cookies in Go by gcb0 on Friday September 14, 2018 @03:38AM (#17985408)
client side cookoes are already inherently unsafe.

on the server, the chance that your cookie is for auth is high, so make a secure cookie the defaul. force http headers that say server only, etc. Then allow for the security to be dropped via the extra arguments, not the other way around.