Earlier quoted context omitted.
No; Django does that, and the result is that people check that random secret into source control. The correct solution is to not have the secret in code at all, but to read it at initialization time out of some kind of secrets management system (traditionally via environment variables). Unfortunately, frameworks generally can't do this in a hosting-setup-agnostic way; you have to understand the specific facilities th…
I THOUGHT Django generated a random secret! What's MF on about?
One Line of Code That Compromises Your Server
11–20 of 46 posts
Re: One Line of Code That Compromises Your Server
#12Earlier quoted context omitted.
No; Django does that, and the result is that people check that random secret into source control. The correct solution is to not have the secret in code at all, but to read it at initialization time out of some kind of secrets management system (traditionally via environment variables). Unfortunately, frameworks generally can't do this in a hosting-setup-agnostic way; you have to understand the specific facilities th…
I THOUGHT Django generated a random secret! What's MF on about?
Re: One Line of Code That Compromises Your Server
#13Earlier quoted context omitted.
But then it also means the malicious user cannot eavesdrop on other users, so other users will be secure, right?
The attack in the article isn't about a malicious user eavesdropping and obtaining someone else's cookie directly. It's about a user who gets a cookie from the server, brute-forces to determine the key used to sign the cookie, and then uses that key to generate cookies that authenticate them as other users (or that execute code during deserialization, etc).
@franciscop -- keep an eye out for the rest of the article (it's already written and will be released soon). I go over the impacts of an attacker knowing the secret in much more detail. I also have sections on prevention for both application developers and library/framework authors that I think you'll find interesting!
Re: One Line of Code That Compromises Your Server
#14There are some use cases this does not cover, such as authentication across multiple systems, where one or more may not have access to the authentication source, but even in that case it'd be preferable to have a separate, internal, private microservice that exchanges tokens for session information.
None of this will stop an attacker that has network access, but that's not what the article is considering, and if somebody is inside your network you might have bigger problems than session hijacking.
Re: One Line of Code That Compromises Your Server
#15Earlier quoted context omitted.
No; Django does that, and the result is that people check that random secret into source control. The correct solution is to not have the secret in code at all, but to read it at initialization time out of some kind of secrets management system (traditionally via environment variables). Unfortunately, frameworks generally can't do this in a hosting-setup-agnostic way; you have to understand the specific facilities th…
I THOUGHT Django generated a random secret! What's MF on about?
I'll think about ways to make it more clear! Thanks
Re: One Line of Code That Compromises Your Server
#16Earlier quoted context omitted.
The attack in the article isn't about a malicious user eavesdropping and obtaining someone else's cookie directly. It's about a user who gets a cookie from the server, brute-forces to determine the key used to sign the cookie, and then uses that key to generate cookies that authenticate them as other users (or that execute code during deserialization, etc).
@AgentME -- correct @franciscop -- keep an eye out for the rest of the article (it's already written and will be released soon). I go over the impacts of an attacker knowing the secret in much more detail. I also have sections on prevention for both application developers and library/framework authors that I think you'll find interesting!
Re: One Line of Code That Compromises Your Server
#17What a splendid example of an aptronym! [0]
Re: One Line of Code That Compromises Your Server
#18https://github.com/rack/rack/blob/master/lib/rack/session/co...
https://rdist.root.org/2009/05/28/timing-attack-in-google-ke...
Of course folks are much more likely to misuse their cookie secret than purposefully break a library function. That said you can look at the history of most projects that use HMAC to authenticate data and they did it wrong.
(e.g. https://github.com/rack/rack/commit/0cd7e9aa397f8ebb3b8481d6...)
Re: One Line of Code That Compromises Your Server
#19I think any sane framework should generate a random secret each time an app is generated.