News for hackers. Stuff that matters.
Re:Global scan – exposed .git repos by AgentME on Thursday September 06, 2018 @07:17PM (#17930486)
A similar issue I've found before on live sites: people exposing the source of php of files through backup files named with the ~ suffix produced by editors like Emacs or vim. In a standard LAMP stack, files with names ending in ".php" get executed and don't have their raw contents exposed, but files with names ending in ".php~" get no special treatment. If the admin uses Emacs or vim to edit any php files directly on the server, then ".php~" files will be produced which will be accessible by default. If a page has a URL like example.com/foo.php, then example.com/foo.php~ may be accessible and expose the source code (and possibly database credentials, etc).
Re:Global scan – exposed .git repos by NickBusey on Thursday September 06, 2018 @11:04AM (#17926780)
"After sending the emails, I exchanged about 300 additional messages with affected parties to clarify the issue. I have received almost 2,000 thank-you emails, 30 false positives, 2 scammer/spammer accusations, and 1 threat to call the Canadian police," Smitka said.
Re:Global scan – exposed .git repos by pjc50 on Thursday September 06, 2018 @03:06PM (#17928715)
> 1 threat to call the Canadian police

Fairly good hit rate. People have been jailed for performing "unsolicited pentesting" before. And @malwaretech is currently stuck in the US indefinitely for intervening in the WannaCry command-and-control system.

(fixed handle, sorry)

Re:Global scan – exposed .git repos by bradstewart on Thursday September 06, 2018 @03:28PM (#17928889)
Its @malwaretech/malwaretechblog, not malwarebytes.

https://twitter.com/MalwareTechBlog

Re:Global scan – exposed .git repos by ryanlol on Thursday September 06, 2018 @03:55PM (#17929075)
>malwaretech is currently stuck in the US indefinitely for intervening in the WannaCry command-and-control system.

Utter nonsense. Who told you this?

Re:Global scan – exposed .git repos by baby on Thursday September 06, 2018 @08:14PM (#17930828)
Not sure why your getting downvoted. GP is spreading FUD.
Re:Global scan – exposed .git repos by Rotdhizon on Thursday September 06, 2018 @03:15PM (#17928792)
Can you elaborate or give some links about that malwarebytes statement? I'd really like to read up about that.
Re:Global scan – exposed .git repos by pjc50 on Thursday September 06, 2018 @03:51PM (#17929052)
Re:Global scan – exposed .git repos by yorwba on Thursday September 06, 2018 @04:10PM (#17929173)
That article contradicts your claim that he was arrested "for intervening in the WannaCry command-and-control system".

Upon his arrest, the Department of Justice unsealed an indictment against Hutchins, charging that he created the Kronos banking trojan, a widespread piece of malware used to steal banking credentials for fraud.

Re:Global scan – exposed .git repos by Rotdhizon on Friday September 07, 2018 @12:31AM (#17931881)
Ah I knew about that. I thought you meant the actual company malwarebytes was like stuck in the US and couldn't go overseas or something.
Re:Global scan – exposed .git repos by halotrope on Thursday September 06, 2018 @07:14PM (#17930462)
I got one of his emails. Send a thank you email and some beer money as a thank you. Funny to see it on HN now.
Re:Global scan – exposed .git repos by C_Sto on Thursday September 06, 2018 @11:21AM (#17926908)
Internet wache performed similar analysis in 2015 - https://en.internetwache.org/dont-publicly-expose-git-or-how...

I performed similar research in April - https://blog.hivint.com/exposed-git-repos-on-the-ipv4-addres...

I get the feeling this problem isn't going away any time soon...

Re:Global scan – exposed .git repos by Assadi on Thursday September 06, 2018 @09:57AM (#17926281)
Haha, maybe I should have written this article.

I ran into this on a couple of legacy CodeIgniter applications that I was rewriting for a small Swedish company and had such a visceral level of shock and disgust when I realised all the production servers contained a publicly accessible ".git" folder.

Worst of all, people had been committing database details. So, not only was the source code for all the applications public, all the user data effectively was too (and, let me tell you, those passwords were NOT hashed properly!).

Re:Global scan – exposed .git repos by tomjakubowski on Thursday September 06, 2018 @05:47PM (#17929869)
it was so much fun when I discovered this same thing* at an earlier job and ops pushed back on it being a problem at all. to me it was insane to begin with to use "git pull on a cron job" as a "deployment" mechanism.

* even down to the "DB credentials + hostname/port to an Internet-exposed mysql server committed to the repo" detail

Re:Global scan – exposed .git repos by ashton314 on Thursday September 06, 2018 @01:58PM (#17928019)
Why would you ever want to put a git repo on a production server in the first place? Unless you're using the production server for development (gasp) it sounds like a waste of space and (as pointed out here) a major security vulnerability.
Re:Global scan – exposed .git repos by ktpsns on Thursday September 06, 2018 @02:51PM (#17928563)
An answer for Subversion would be: Because "svn update" (http://svnbook.red-bean.com/en/1.8/svn.ref.svn.c.update.html) runs faster then "svn export" (http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.export.html).

For git there is not even an "export" option anymore (cf. https://stackoverflow.com/questions/160608/do-a-git-export-l...), but nevertheless "git pull/push" is an easy way to keep the production server code synced. It is certainly not the best.

Re:Global scan – exposed .git repos by wongarsu on Thursday September 06, 2018 @03:01PM (#17928665)
>It is certainly not the best.

What is the better alternative? Git checkout makes reverting to a previous version fast and convinient, and git's protocol seems more efficient than transmitting the files via scp or similar since most of the files are already there.

I guess I could have a build server rsync the files over, but that seems like a lot of complexity for little gain.

Re:Global scan – exposed .git repos by icebraining on Thursday September 06, 2018 @04:24PM (#17929261)
Git doesn't ensure the checkout process is atomic; it might leave you with an unfinished mess if it fails for some reason.

Also, it means that everything you ever committed on the release branch will be available on a more exposed server.

Re:Global scan – exposed .git repos by _-david-_ on Thursday September 06, 2018 @09:21PM (#17931187)
>What is the better alternative?

This is a bit complicated to do by hand, but this is probably the best way. I would suggest using existing software to handle this though

Create a file that just has "2" with no quotes in it. Create a directory called 1. Create a symlink that points to that directory. Have the webserver use the symlink instead of the actual code directory.

When you want to update code lock the file that has the number in it. Read in the contents of the file. Replace the contents of the file with the next number. Unlock the file. Create a directory with whatever number you read in. Git clone in that new directory. Do whatever else you need to do (compilation or whatever). If all goes well then change a symlink to point to the new directory.

If you need to revert then change the symlink to the old directory. You could also delete old directories as well to save some space.

Re:Global scan – exposed .git repos by cpburns2009 on Thursday September 06, 2018 @05:14PM (#17929600)
Using git pull (or some equivalent) to update a production environment is fragile and just asking for trouble.
Re:Global scan – exposed .git repos by tzs on Thursday September 06, 2018 @03:31PM (#17928912)
You can go a long way toward avoiding the security issue by making good use of the GIT_DIR and GIT_WORK_TREE environment variables.
Re:Global scan – exposed .git repos by nooyurrsdey on Thursday September 06, 2018 @02:03PM (#17928054)
This question basically restate the problem. It's not that people want to do that, they just don't know better
Re:Global scan – exposed .git repos by siruncledrew on Thursday September 06, 2018 @03:17PM (#17928807)
I've seen someone SCP a local git repo to an Amazon EC2 (obviously not best practice) for a manual deployment.
Re:Global scan – exposed .git repos by ktpsns on Thursday September 06, 2018 @11:58AM (#17927155)
Certainly disabling access to directories like .git, .svn or .hg should be default in any webserver. It is a pity to see this option not active by default in a Debian/Ubuntu Apache2 installation, c.f. https://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/... which mentions it (1) only for svn and (2) has it commented out.
Re:Global scan – exposed .git repos by jolmg on Thursday September 06, 2018 @02:10PM (#17928131)
I feel that'd be like shoemakers putting metal plates on top of their shoes to prevent bullets from penetrating when customers shoot themselves in the foot. It's silly. Those same customers could shoot themselves in the leg (another software they misuse and expose .git/ from), or hurt their foot via some other method that the plate can't protect from (expose other non-git sensitive information via the webserver; i.e. the webserver can't predict all ways it can be misused).

However, now I see you said it should be Ubuntu and not Apache that should do this default configuration. I guess that'd make a little more sense as Ubuntu could be interpreted in this analogy as the vendor of the boot, pants and gun, and is generally geared toward beginner cowboys.

The real solution, though, would be for the customers to learn to use the gun properly. If they shoot themselves, then that's valuable experience they can learn from. If you put the metal plate, they might go on without realizing they're shooting themselves.

Re:Global scan – exposed .git repos by pjc50 on Thursday September 06, 2018 @03:02PM (#17928677)
This kind of anti-safety sentiment isn't based on a real consideration of user needs, just a victim-blaming machismo. Reminds me of mongodb shipping exposed to the internet by default.

(You can of course buy shoes with metal plates in them to prevent injury, they're called "safety boots" and are mandatory in some workplaces)

Re:Global scan – exposed .git repos by jolmg on Thursday September 06, 2018 @04:51PM (#17929441)
I'm not anti-safety, I'm anti-bad safety design. I clarified the point of the analogy in a reply to another reply.

EDIT: You can't substitute gun safety knowledge with legislation that requires all things (and I mean all) to protect against gun misuse.

Re:Global scan – exposed .git repos by 21 on Thursday September 06, 2018 @04:57PM (#17929486)
Defense-in-depth is not bad design, it's good design.
Re:Global scan – exposed .git repos by mikeash on Thursday September 06, 2018 @04:07PM (#17929155)
It would be more like car makers building cars that won’t engage the starter motor if the transmission isn’t in Park, garage door openers reversing if they encounter too much resistance, or lawn mowers that won’t run if you don’t hold down a safety bar.

Which is to say, anti-footgun measures are extremely common anywhere foot-shooting is.

Re:Global scan – exposed .git repos by jolmg on Thursday September 06, 2018 @04:24PM (#17929256)
The difference here, and the main point of my analogy is that webservers and git are completely unrelated things like shoes and guns are. That all webservers should guard against misuse with another random piece of software is like having all shoes have protections specifically against a random product that's completely unrelated to shoes. Also, to take the analogy further, the original suggestion was to guard against specific directories .git, .hg, etc. That's like having all shoes protect against only specific models of guns and not others.

The point here is that if you want to take this methodology for security, then you'll have to come with an enumeration of all ways the user hurt himself and implement a safety measure for each. That's neither effective nor efficient. Think of all pieces of clothing being required to be bullet-proof, cut-proof, stab-proof, acid-proof, hunger-proof, suffocation-proof, smash-proof, etc. You can't have everything protect the user from everything else via having a safety mechanism for each model-specific thing.

Re:Global scan – exposed .git repos by mikeash on Thursday September 06, 2018 @06:27PM (#17930190)
How is that different from my examples where they protect against certain common dangers but don’t even attempt to protect against all the ways you can hurt or kill yourself with them?
Re:Global scan – exposed .git repos by jolmg on Thursday September 06, 2018 @06:56PM (#17930348)
That the safety mechanisms in your examples depend only of knowledge of the object's own mechanisms or generic "other things". For example, your garage door opener reverses when it encounters resistance from anything. It's not that it only reverses when there is one of a specific list of car models that are in its way, and continues to try to close when there is a human in its way or some other type of vehicle or thing. It'll work even if a new type of thing that never existed before gets in its way.

It's also different in that it doesn't limit the products functionality when it thinks that you want to make an exception to its primary purpose. A garage door opener is not going to refuse to open when you're trying to come in with a vehicle on fire.

A webserver serves files, and inside .git/ are files. You ask it to serve them, then its going to serve them. That you didn't realize you were coming into the garage with a vehicle on fire is no reason for the garage door opener to be required to implement a security mechanism for that very specific thing when there's loads more you could do without realizing.

Re:Global scan – exposed .git repos by mikeash on Thursday September 06, 2018 @08:59PM (#17931096)
I still don’t see the difference. Consider a lawnmower. Its purpose is to cut things. It doesn’t care whether it’s grass or hoses or feet. A common failure mode is to cut the user’s hands or feet. The safety bar helps prevent this. It doesn’t stop you from cutting other people’s hands or feet, and it’s easily bypassed if you want to cut your own, but it’s still a valuable safety feature because this particular accident is so common.

Likewise, serving .git is a common problem. Not serving it by default would prevent it. Why is that bad?

Re:Global scan – exposed .git repos by fake-name on Thursday September 06, 2018 @03:51PM (#17929050)
Uh.... steel toed boots are a very common thing?
Re:Global scan – exposed .git repos by ktpsns on Thursday September 06, 2018 @02:49PM (#17928540)
In fact Debian ships Apache with a decent default setup which also allows further Debian packages to seamlessly hook into the configuration (with directories likes /etc/apache2/conf.available and /etc/apache2/conf.enabled and softlinks inbetween). Apache itself does not have any "default" configuration at all, it most likely also starts fine with an empty configuration file.

Of course "fixing" security problems at the level of the web server feels like adding a firewall to your server instead of avoiding daemons listening on public ports. It feels wrong. But it can be seen as another layer of security.

Re:Global scan – exposed .git repos by judge2020 on Thursday September 06, 2018 @02:39PM (#17928443)
The difference being in this situation, shooting yourself in the foot can cause loads of confidential user information to be stolen by someone exploiting this (when storing DB credentials in SCM)
Re:Global scan – exposed .git repos by DCoder on Friday September 07, 2018 @01:26AM (#17932070)
It's interesting to compare this behaviour against IIS. If Apache can't identify the MIME type of the requested file, it will serve it without a Content-Type header. IIS will return a 404 instead.
Re:Global scan – exposed .git repos by megous on Thursday September 06, 2018 @05:50PM (#17929902)
There's something to beig able to review/glance at website's code before commiting to using the website...

Just saying. There are other perspectives than the website owner's one.

Re:Global scan – exposed .git repos by bdcravens on Thursday September 06, 2018 @11:21AM (#17926910)
Article now redirecting to a different unrelated article.

cached:

https://webcache.googleusercontent.com/search?q=cache:wIEQNW...

Re:Global scan – exposed .git repos by dang on Thursday September 06, 2018 @01:26PM (#17927805)
That's probably good since the article was basically blogspam of the original work. We changed the URL to that from https://www.scmagazine.com/400000-websites-vulnerable-throug....