Live data from Hacker News

One in every 600 websites has .git exposed

jamiembrown.com

191–200 of 214 posts

Re: One in every 600 websites has .git exposed

#191

Imagine you implement every type of possible security... Keeping your entire server-stack up-to-date, making sure you have SSL, using strong encryption for logging-in, hashing the passwords, making sure your server can only be reached via SSH, adding firewalls, filters, etc. etc. Then some hacker in Eastern Europe comes along (or some beginner at the NSA/GCHQ) and finds out that your .git is exposed and somehow gains…

What "all vital user-data and admin data"?

Re: One in every 600 websites has .git exposed

#192

Imagine you implement every type of possible security... Keeping your entire server-stack up-to-date, making sure you have SSL, using strong encryption for logging-in, hashing the passwords, making sure your server can only be reached via SSH, adding firewalls, filters, etc. etc. Then some hacker in Eastern Europe comes along (or some beginner at the NSA/GCHQ) and finds out that your .git is exposed and somehow gains…

This is what makes security hard: To attack successfully you only have to find one significant mistake, to defend successfully you can't make any mistakes.

Re: One in every 600 websites has .git exposed

#193

Some of the other commenters suggest adding git-dir and work-tree to the git commands, but there's a better solution: use the --separate-git-dir option when cloning the repository. For example: git clone --separate-git-dir= where is outside of any directory served by the web server and is the htdocs root. This option makes /.git a file whose content is: gitdir: The advantage is that all git commands work as usual, wi…

I disagree It may be possible that gitdir is still accessible through a misconfiguration or security issue (and you're giving them exactly where to look) Production servers have no business having the .git directory anywhere.

> Production servers have no business having the .git directory anywhere.

I agree with you in principle, but in practice this is not always possible, there are situations when having a git checkout in production is better than nothing.

I've seen WordPress sites where a semi-technical administrator updates plugins and themes directly in production: with that git checkout I would at least be able to track the changes and pull them in a dev or staging environment.

This could be the first step to a saner deployment workflow for those sites, where production gets changes that have been tested and validated elsewhere.

Re: One in every 600 websites has .git exposed

#194
I'll get on tangent here, and blame PHP.

The model of exporting a Unix directory as the structure of a website is barely good enough for static sites (you'll get into all kinds of problems with URL management), and is completely unsuited for applications.

Now, of course, PHP was created as a tool to add a visitor counter at the bottom to your pages. With a bit of caution, it's indeed secure enough for that. Nowadays people create huge applications using the same security model, and PHP developers don't even think about changing it.

Re: One in every 600 websites has .git exposed

#195
post #188

How can a project be accessed/downloaded with just the .git folder?

Even with directory listings disabled, you could request http://example.com/.git/refs/heads/master to get the sha of master, then get http://example.com/.git/objects/ 2 char>/ to download the data for that one sha, then you can get the rest.

Wouldn't be terribly difficult to write a script to crawl it. Git's format is well known and documented.

Re: One in every 600 websites has .git exposed

#196
This is one example for why hierarchical directories are bad. They're not all bad, but with all their power and flexibility, they carry some inherent flaws. It's much the same as JSON, which is also versatile and highly useful. However, both of these abstractions tend to lead to the ad-hoc creation of more complexity and more details to remember, while having no clearly delineated way to be self-describing.

(Is JSON an abstraction? Not really, as it's a concrete spec, but its general kind of serialization format is an (incomplete) abstraction.)

Re: One in every 600 websites has .git exposed

#197
post #115

Earlier quoted context omitted.

I'm surprised this isn't higher up. Are there any arguments against ENV variables in favor of something else?

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.

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

#198
post #184

Earlier quoted context omitted.

Very simple setup. You have: .git web/index.php src/*.php Make the document root /full/path/to/web/index.php. Edit: Also use a deployment tool like Capistrano which removes the .git directory as well.

Yes, it is easily avoided. But it is still violated by lots of PHP projects, including well-known projects with large userbases: * Wordpress * Tiki * ... and so on. I don't think this is by accident: This technique is too old and well-known to be ignored by large projects. Rather, they conciously don't do that to cause less hassle for the occasional admin: Those can simply dump it into some directory and don't have t…

Drupal, MediaWiki, Laravel, Slim, it's a pretty long list, and it includes projects that target Serious Devlopers.

Re: One in every 600 websites has .git exposed

#199
post #184

Earlier quoted context omitted.

Yes, it is easily avoided. But it is still violated by lots of PHP projects, including well-known projects with large userbases: * Wordpress * Tiki * ... and so on. I don't think this is by accident: This technique is too old and well-known to be ignored by large projects. Rather, they conciously don't do that to cause less hassle for the occasional admin: Those can simply dump it into some directory and don't have t…

Drupal, MediaWiki, Laravel, Slim, it's a pretty long list, and it includes projects that target Serious Devlopers.

Also, this is really PHP specific.

Look at any larger Python (Django/Flask/...) or Ruby (Rails/...) project, and you will always find a proper "public" directory, although it may be named differently.

Not sure about Perl though ...

Re: One in every 600 websites has .git exposed

#200
Talked to a infosec savvy friend about this issue, and he responded that with a private repo via github, and directory listing disabled, the risk of information being retrieved from a .Git directory is low. However, looking through the responses here, I don't see any mention of this.

Without directory browsing, is it exorbitantly difficult to rebuild the contents of a .git folder from the known parts of a repo, eg, .Git/config, .Git/HEAD? I'm a novice when it comes to git, been relying on the github GUI, so I don't really know where to start.

Thank you for any insight!

Post reply on HN