News for hackers. Stuff that matters.
Re:One in every 600 websites has .git exposed by tokenizerrr on Sunday July 26, 2015 @09:30PM (#9952924)
Environment variables are the best and easiest way that I know of. You can supply those anyway you want to, and any programming language can easily get their values.
Re:One in every 600 websites has .git exposed by jsjohnst on Monday July 27, 2015 @12:23AM (#9953329)
Glad I don't work at your shop then. Environment variables are a terrible way to give your app secure information. There's well over a dozen reasons why you shouldn't do this in your apps, but one super obvious one is there's way to many frameworks that expose environment variables in their debug output if not properly configured. Think you'll never misconfigure a server? Guess again, pretty much every major site (Google, FB, Twitter, Yahoo, EBay, Microsoft, etc) have all done it at some point.
Re:One in every 600 websites has .git exposed by tokenizerrr on Monday July 27, 2015 @05:16AM (#9954164)
Please review HN's guidelines on civility.
Re:One in every 600 websites has .git exposed by jsjohnst on Monday July 27, 2015 @08:28AM (#9954709)
Fair point, I potentially should've left off the first sentence. I stand behind the rest of the post, but the first sentence is a bit on the edge and I apologize.
Re:One in every 600 websites has .git exposed by tokenizerrr on Monday July 27, 2015 @08:32AM (#9954726)
Alright, well, I've never seen an application/framework spit out environment variables when it was misconfigured. But then again, I barely work with web-related stuff so maybe I just don't use the kind of software that does this. Could you provide some examples?
Re:One in every 600 websites has .git exposed by damon_c on Monday July 27, 2015 @09:36AM (#9955063)
Many web frameworks do this when in "debug" mode.
Re:One in every 600 websites has .git exposed by dang on Monday July 27, 2015 @03:07PM (#9957292)
Your comment sounded more colloquial than uncivil to me, but thanks for responding so respectfully.
[dead]
Re:One in every 600 websites has .git exposed by tokenizerrr on Monday July 27, 2015 @07:11AM (#9954470)
I'm glad you made a new account named 'shutupbitch' just to tell me this. Thank you for your contribution.
Re:One in every 600 websites has .git exposed by dang on Monday July 27, 2015 @03:06PM (#9957286)
Please don't feed trolls.
Re:One in every 600 websites has .git exposed by otterley on Tuesday July 28, 2015 @11:22PM (#9965993)
The "dump environment" problem is an issue for novice developers, but mature shops should have security-conscious frameworks for secrets handling that do things like clear the variable from the environment at initialization time.

What are your other 11 objections?

Re:One in every 600 websites has .git exposed by alexisnorman on Sunday July 26, 2015 @11:35PM (#9953195)
I'm surprised this isn't higher up. Are there any arguments against ENV variables in favor of something else?
Re:One in every 600 websites has .git exposed by smtddr on Monday July 27, 2015 @12:07AM (#9953277)
Here's my caution to this. If low level processes can do "ps aux", and they see something like:

DB_USER=scott DB_PASSWORD=b3withm3pl3aze /usr/bin/python webapp.py

That could be troublesome if an attacker figured out a way to run remote commands on your server even as an unprivileged user.

Re:One in every 600 websites has .git exposed by Dylan16807 on Monday July 27, 2015 @11:57AM (#9955915)
When I test that, the command line does not include the variable-setting. Is this a problem that depends on version or are you mistaken?

It would be kind of weird to include that considering how argv works.

Re:One in every 600 websites has .git exposed by yrro on Monday July 27, 2015 @05:57AM (#9954268)
Reading the environment of another process is a privileged operation.
Re:One in every 600 websites has .git exposed by smtddr on Monday July 27, 2015 @05:23PM (#9958105)
If an attacker can get the process that's running the webapp.py to exec some abitrary bash command, that process has the ability to read its own /proc/$PID/environ . In general, you can read /proc/$PID/environ on processes that you own. At least I can do that on my Debian system:

    pikachu@POKEMONGYM ~ $ sleep 99 &
    [1] 21340
    pikachu@POKEMONGYM ~ $ cat /proc/21340/environ
XDG_SESSION_ID=5COMP_WORDBREAKS= "'><;|&(:TERM=screenSHELL=/bin/bashXDG_SESSION_COOKIE=8571b679eed8952dd96ad28a54...<etc>

(I actually gave the wrong example in my previous comment. While it is true that giving the ENV on cmdline will show up in ps eaux, the more appropriate example is what I just explained in this comment.)

Re:One in every 600 websites has .git exposed by tokenizerrr on Monday July 27, 2015 @06:38PM (#9958463)
If you can get it to exec some arbitrary bash command (or otherwise access the environ of a process) you can also have it cat any file on the server, and even the memory of the running processes that belong to the same user as the exploited process, and also execute network requests. So if you get that far, pretty much nothing will protect you.
Re:One in every 600 websites has .git exposed by smtddr on Monday July 27, 2015 @07:12PM (#9958613)
Sure, but there are some shops that do their security from a point-of-view of "Attacker can run commands on your server as the user that started whatever-public-service/webapp/api", and go from there. I happen to think that's the best way to think about it.

Now, if an attacker manages to get root access then it's game over[1]. That just shouldn't happen. But nobody should be running their webserver as root. So, whatever that user is should be low-powered with only enough privileges to start the webserver & bind port 8080 (and use iptables or whatever to reroute connections to port 80 --> 8080) and the whole setup should be designed that this account won't be able to escalate things further if someone got a bash shell to it.

______

1. You should at least have some way of detecting that it happened and consider all data & files compromised and just wipe the whole machine & start over. Or take that machine offline for investigation into what happened and put a fresh new one in its place.

Re:One in every 600 websites has .git exposed by yrro on Wednesday July 29, 2015 @07:39PM (#9972388)
If an attacker can run an arbitrary command on your server, it's already time to rotate all the credentials in your system and let any data subjects whose data you hold know that you fucked up, big time. That's just the Linux model.
Re:One in every 600 websites has .git exposed by vidarh on Monday July 27, 2015 @07:40AM (#9954564)
The example above is someone who have stupidly started a process with the environment variables exposed on the command line
Re:One in every 600 websites has .git exposed by yrro on Wednesday July 29, 2015 @07:34PM (#9972361)
Ok, but that's not a problem caused by the exposure of the environment, it's caused by the exposure of the command line.
Re:One in every 600 websites has .git exposed by vidarh on Thursday July 30, 2015 @04:56AM (#9973811)
I agree - I was just explaining what the issue the above commenter raised. It just means you should use a saner way of initializing your environment with sensitive values.
Re:One in every 600 websites has .git exposed by marcus on Sunday July 26, 2015 @11:58PM (#9953240)
ENV variables are inherited by child processes by default, so please use care when using this approach.