Minimize the risk of SECRET_KEY leaks
|Reported by:||jacob||Owned by:||aj7may|
|Cc:||unai@…, eromijn@…, bendavis78||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
We should consider generating it on the fly something like the way Horizon does:
The things we lose when the secret key changes (sessions and password reset links IIRC) are generally per-deployment specific anyway. There's still a lot of bikeshedding to be found behind that issue (should production servers have the ability to write this file), but it's not a bad approach for those same users who commit their secret keys to their public github repos.
Oh this is neat! So basically when the server starts up it writes out
a secret key file if it one doesn't already exist? I like it, seems
like a really good thing to do in core. Security-by-default and all
How does this handle multiple web servers, though? Seems like if you
weren't careful you'd end up with differing secrets across your web
nodes, bad news. Couldn't we do something similar but store the key in
the database? That seems like it wouldn't be any more or less secure
than the filesystem, and would solve N=1 problems.
Yeah, the multiple servers deployment its downside and the reason I originally objected to including it in Horizon. What it does is bump the user-facing issue (you have to deal with and understand a secret key) a bit further along the line. I'd be willing to guess that a majority of Django sites that leak the secret key fall into the N=1 category, or would do the correct thing WRT secret key if it weren't so easy to commit to the repo and was a specific action they had to take when N > 1. The downside of course is that there will always be a learning curve.
I'm -1 on storing the key in the database - databases tend to be easier to compromise than file systems, and people tend to be lazy about the security of their DB backups.
Change History (22)
comment:10 Changed 18 months ago by bendavis78
- Cc bendavis78 added
comment:14 Changed 18 months ago by aj7may
- Owner changed from nobody to aj7may
- Status changed from new to assigned
comment:21 Changed 11 months ago by berkerpeksag
- Needs documentation set
- Patch needs improvement set
- Version changed from 1.5 to master