Hackers backdoor PHP source code after breaching internal git server

POSIX

Seniorius Lurkius
38
Subscriptor++
Why pay a developer's salary to manage git, WordPress, Exchange security when you can pay people who support them full-time?
If all your company's knowledge is public, or if industry espionage doesn't matter, there's indeed not much reason to not use third party offerings. However, I've heard there are companies where it matters who reads emails and source code and who'd better not.

Git is unencrypted; whoever hosts the Git repository can read everything. The same is true for email, with the (rarely used) exception of end-to-end encrypted messages. Likewise for WordPress.
“Source code stored on GitHub.com will be encrypted at rest, by default.” https://github.blog/changelog/2019-05-2 ... n-at-rest/

If the encryption system in under control of Github, then its purpose isn't really to protect you from Github. (If the encryption is server-side, you can assume this is the case. I haven't done a deep-dive of Github's specific set-up; I don't work for Microsoft & company.) Their administrators or crypto officers could choose to break it open if the need arises. Encryption at rest in a service provider serves mostly to ensure that their datatechs in the DC, their non-technical staff, and any unauthorized intruders who get past the guards can't pull the hard drives and make off with all your data. It also serves to bind data access to whatever auth system they are using to vend out the encryption keys. Since the public servers you are talking to when you clone or pull can access those keys, their administrators can too.

None of this is to suggest that you shouldn't trust Github, Azure, AWS, etc. The thing that protects your data from industrial espionage and other malfeasance is that 1. that's hella illegal and the person responsible could face prison time, 2. it would get out and their reputation would be irreparably damaged, and 3, everyone would then sue the company into oblivion. Companies don't usually demand unbreakable technical controls to prevent their vendors from doing damage to them, as often this defeats the point of hiring the vender. Simply being in a place where the law binds the supplier is generally regarded as safe enough. With the notable exception of Uber, any company that catches an employee or associate doing industrial espionage is going to fire them on the spot and call the cops in a bid to limit their liability.
 
Upvote
12 (12 / 0)

jeremyp66

Ars Scholae Palatinae
1,029
Subscriptor
I can see why they are doing this, but it still worries me that all source code tends to end up on GitHub.

Haven't we learned that platform monoculture is bad?

(I guess not).
Git being Git, why should it matter if GitHub is a common place to host repositories? Does it naturally impose any kind of culture beyond Git itself? GitHub-specific features seem to be convenient wrappers for functionality that exists or could be replicated elsewhere.

Well, for one thing it promotes the git monoculture. There was a time when there were several different source code control systems and you could pick the one you liked or that suited your needs. Now there's only git for all practical purposes and git is a bit of a mess, really.

For another thing, GitHub is a proprietary platform owned by Microsoft. We seem to be moving in the direction of everybody using GitHub. You tell me if Microsoft hosting all the world's code is a good plan.
 
Upvote
-5 (3 / -8)

SeanJW

Ars Legatus Legionis
12,301
Subscriptor++
Why pay a developer's salary to manage git, WordPress, Exchange security when you can pay people who support them full-time?
If all your company's knowledge is public, or if industry espionage doesn't matter, there's indeed not much reason to not use third party offerings. However, I've heard there are companies where it matters who reads emails and source code and who'd better not.

Git is unencrypted; whoever hosts the Git repository can read everything. The same is true for email, with the (rarely used) exception of end-to-end encrypted messages. Likewise for WordPress.
“Source code stored on GitHub.com will be encrypted at rest, by default.” https://github.blog/changelog/2019-05-2 ... n-at-rest/

Which is a meaningless distinction. No one is breaking into the DC to steal the disks, and that’ll be the only time they’re at rest.
 
Upvote
3 (5 / -2)
If the encryption system in under control of Github, then its purpose isn't really to protect you from Github. (If the encryption is server-side, you can assume this is the case. I haven't done a deep-dive of Github's specific set-up; I don't work for Microsoft & company.) Their administrators or crypto officers could choose to break it open if the need arises. Encryption at rest in a service provider serves mostly to ensure that their datatechs in the DC, their non-technical staff, and any unauthorized intruders who get past the guards can't pull the hard drives and make off with all your data. It also serves to bind data access to whatever auth system they are using to vend out the encryption keys. Since the public servers you are talking to when you clone or pull can access those keys, their administrators can too.

None of this is to suggest that you shouldn't trust Github, Azure, AWS, etc. The thing that protects your data from industrial espionage and other malfeasance is that 1. that's hella illegal and the person responsible could face prison time, 2. it would get out and their reputation would be irreparably damaged, and 3, everyone would then sue the company into oblivion. Companies don't usually demand unbreakable technical controls to prevent their vendors from doing damage to them, as often this defeats the point of hiring the vender. Simply being in a place where the law binds the supplier is generally regarded as safe enough. With the notable exception of Uber, any company that catches an employee or associate doing industrial espionage is going to fire them on the spot and call the cops in a bid to limit their liability.
Well written!

At this point the question comes up whether it's actually illegal in the U.S. when a US company (or the NSA) spies at European, Asian or African companies.

European Union recognized this question as well and their answer is that confident data of public services (e.g. healthcare data) must not leave European soil. Accordingly, Microsoft offers its services from European data centers. Opinions on trustworthiness of these services still vary.
 
Upvote
0 (1 / -1)

cerberusTI

Ars Tribunus Angusticlavius
7,228
Subscriptor++
PHP 80 % of websites? Humanity is doomed.

Because 80% of websites running Python/ASP.NET/Node/whatever is sooooo much better?

The biggest problem with PHP and all the other languages IMO is that people grab sample code from some rando site and it works and they think they are developers and they leave this shit running on live servers hooked up to the net.

My number one task for the last month or so has been trying to explain the difference between code that functions, and production ready code to senior management...

Yeah, it's more the "I want it done yesterday and I can't sell bugfixes as a feature" mentality than PHP itself that's to blame for there being so much bad and insecure software out there, though PHP's very fast to develop in, which doesn't help. You show management the rough prototype you knocked together in a couple of hours and they want it up on a production server by the weekend once the design team have replaced all the placeholder graphics.

I feel that people have this backwards. Because you can get something functional quickly, it means there is more budget (time) to build solidly, because it means that the platform you're building on has a good set of composable primitives that get you up to speed.

I wasn't trying to make a commentary on the relative quality of developers in various programming languages, the point I was trying to make is that because it's easy to develop something in PHP very quickly that is minimally functional it can give a misleading impression to management. They see something that looks like a working product when in reality it's a roughly-hewn proof-of-concept or a prototype that requires more fleshing out. Instead of giving the dev team the time they need to do that fleshing out they pressure them to release an unfinished product.
I mostly still see that as a benefit.

In my experience the people who want to release your barely working prototype do not care what language it is in. This is a worse situation to be in with a C program than a PHP program.

It is not always the wrong decision to release a minimum product. Sometimes the business crowd does not know exactly what it needs to do, so that beta is important in ways which go beyond polish. There is a very real chance this project will be done several times, so the prototype is still serving the function of a prototype. It can also be worthwhile to assess if a market exists before committing a lot of time to development.

If that prototype ends up being popular and immediately extended such that the prototype code is going to become real code and nobody is going to let you rewrite it entirely, you are also not in such a bad place with PHP. This is another eternal problem which happens in all languages, and so the better question is which language you would prefer your mess of a prototype to be released in.

One of the reasons I think we see so many messes of a PHP program in production doing useful things, is that it is actually possible to take a PHP code base written by someone who had obviously never written software before and bang it into some sort of reasonable shape.

As with many practical solutions to inconvenient problems, it is not great, but not terrible.
 
Upvote
3 (3 / 0)

DanNeely

Ars Legatus Legionis
16,443
Subscriptor
To clarify, were these changes ever put "into production" or were the commits caught during a review?
The commits made it into their main/master branch. They weren't packaged up into a release, but they made it past the review stage.

Were they actually reviewed, or did the hackers cheat their way past that step too after injecting the commits in the first place?
 
Upvote
1 (1 / 0)
To clarify, were these changes ever put "into production" or were the commits caught during a review?
The commits made it into their main/master branch. They weren't packaged up into a release, but they made it past the review stage.

Were they actually reviewed, or did the hackers cheat their way past that step too after injecting the commits in the first place?

Looks like they were committed straight to master w/o a branch or any pull request. Which made them stand out even more.

Honestly the injection attempt itself was kind of lazy and a "wasted opportunity" considering the act of bypassing their Git security and being able to commit absolutely anything as one of the upper level developers. It would've been much worse if they amended an actual commit, which may already been reviewed, that actually did other things too (meaning their stupid one-and-done line wouldn't stick out like a sore thumb). Which also makes me fear how many other companies this has happened to...
 
Upvote
2 (2 / 0)

DanNeely

Ars Legatus Legionis
16,443
Subscriptor
To clarify, were these changes ever put "into production" or were the commits caught during a review?
The commits made it into their main/master branch. They weren't packaged up into a release, but they made it past the review stage.

Were they actually reviewed, or did the hackers cheat their way past that step too after injecting the commits in the first place?

Looks like they were committed straight to master w/o a branch or any pull request. Which made them stand out even more.

Honestly the injection attempt itself was kind of lazy and a "wasted opportunity" considering the act of bypassing their Git security and being able to commit absolutely anything as one of the upper level developers. It would've been much worse if they amended an actual commit, which may already been reviewed, that actually did other things too (meaning their stupid one-and-done line wouldn't stick out like a sore thumb). Which also makes me fear how many other companies this has happened to...

Wouldn't editing any existing commit cause the hashes to either be incorrect, or be changed; either of which would trigger major Something isn't Right indicators in the git clients of every developer who had a copy of the original?
 
Upvote
4 (4 / 0)
Were they actually reviewed, or did the hackers cheat their way past that step too after injecting the commits in the first place?
Whether they were actually reviewed or they cheated their way past that step is irrelevant; once they landed in main, the commits were part of the official product.
 
Upvote
1 (1 / 0)
Why pay a developer's salary to manage git, WordPress, Exchange security when you can pay people who support them full-time?
If all your company's knowledge is public, or if industry espionage doesn't matter, there's indeed not much reason to not use third party offerings. However, I've heard there are companies where it matters who reads emails and source code and who'd better not.

Git is unencrypted; whoever hosts the Git repository can read everything. The same is true for email, with the (rarely used) exception of end-to-end encrypted messages. Likewise for WordPress.
“Source code stored on GitHub.com will be encrypted at rest, by default.” https://github.blog/changelog/2019-05-2 ... n-at-rest/

Which is a meaningless distinction. No one is breaking into the DC to steal the disks, and that’ll be the only time they’re at rest.
This story is about a case where a server was hacked. We don’t know how the repo itself was compromised.
 
Upvote
1 (1 / 0)
If the encryption system in under control of Github, then its purpose isn't really to protect you from Github. (If the encryption is server-side, you can assume this is the case. I haven't done a deep-dive of Github's specific set-up; I don't work for Microsoft & company.) Their administrators or crypto officers could choose to break it open if the need arises. Encryption at rest in a service provider serves mostly to ensure that their datatechs in the DC, their non-technical staff, and any unauthorized intruders who get past the guards can't pull the hard drives and make off with all your data. It also serves to bind data access to whatever auth system they are using to vend out the encryption keys. Since the public servers you are talking to when you clone or pull can access those keys, their administrators can too.

None of this is to suggest that you shouldn't trust Github, Azure, AWS, etc. The thing that protects your data from industrial espionage and other malfeasance is that 1. that's hella illegal and the person responsible could face prison time, 2. it would get out and their reputation would be irreparably damaged, and 3, everyone would then sue the company into oblivion. Companies don't usually demand unbreakable technical controls to prevent their vendors from doing damage to them, as often this defeats the point of hiring the vender. Simply being in a place where the law binds the supplier is generally regarded as safe enough. With the notable exception of Uber, any company that catches an employee or associate doing industrial espionage is going to fire them on the spot and call the cops in a bid to limit their liability.
Well written!

At this point the question comes up whether it's actually illegal in the U.S. when a US company (or the NSA) spies at European, Asian or African companies.

European Union recognized this question as well and their answer is that confident data of public services (e.g. healthcare data) must not leave European soil. Accordingly, Microsoft offers its services from European data centers. Opinions on trustworthiness of these services still vary.
Opinions of the trustworthiness of financial institutions vary. Opinions of organizations who store all their money on site are considerably less varied.

Any organization needs trustworthy partners to function. If you are convinced that Microsoft cribbing from your GitHub repos is a risk, so be it. But that does not mean that keeping them on internal servers is more secure, even from a Microsoft gone rogue.
 
Upvote
2 (2 / 0)
One of the (few) times I'm grateful to be coding in perl 5.8.5 on a local disk! Fortune 500 paranoia and inertia FTW.

I did work for a startup until recently which, as part of its CI workflow, pulled libraries from all over including some sketchy .cz domain. This notion of pulling critical components from outside sources into your local network just seems so foreign to me. But that seems to be the way a lot of software development is going.

It's terrifying thinking of how much of Teh Internets are built on that foundation.
Ehm, .cz is Czech TLD, not some random sketchy TLD like .com where a lot of really sketchy domains reside. (Also repo.or.cz is one o folder and well known Git hosting services)

/gadgets/2021/03 ... ode=quote#
PHP 80 % of websites? Humanity is doomed.

That is primarily Wordpress, Joomla and other consumer CMSs.

High volume serious PHP websites use Symfony or Laravel, which is an entirely different beast.

Don't forget Yii!
Gonna go write my next (first) website in assembly. I don't even know if that's physically possible.


Well there's always webassembly, which you can compile to from C or Rust (and other languages)....

Or try to write yourself directly.
Blazor.
 
Upvote
3 (3 / 0)
I can see why they are doing this, but it still worries me that all source code tends to end up on GitHub.

Haven't we learned that platform monoculture is bad?

(I guess not).
Git being Git, why should it matter if GitHub is a common place to host repositories? Does it naturally impose any kind of culture beyond Git itself? GitHub-specific features seem to be convenient wrappers for functionality that exists or could be replicated elsewhere.

Well, for one thing it promotes the git monoculture. There was a time when there were several different source code control systems and you could pick the one you liked or that suited your needs. Now there's only git for all practical purposes and git is a bit of a mess, really.

For another thing, GitHub is a proprietary platform owned by Microsoft. We seem to be moving in the direction of everybody using GitHub. You tell me if Microsoft hosting all the world's code is a good plan.
It sounds like your problem with Github is that you wish Git were less popular. IIRC, Git eclipsed other tools in popularity long before Github came along and was eventually purchased by Microsoft.

One can believe that Microsoft is positioning itself to steal everyone’s secrets (those it can’t steal from Windows, Azure, etc.) I don’t. But more importantly, I don’t think avoiding Github would stop them.
 
Upvote
3 (3 / 0)
I can see why they are doing this, but it still worries me that all source code tends to end up on GitHub.

Haven't we learned that platform monoculture is bad?

(I guess not).
Git being Git, why should it matter if GitHub is a common place to host repositories? Does it naturally impose any kind of culture beyond Git itself? GitHub-specific features seem to be convenient wrappers for functionality that exists or could be replicated elsewhere.

Well, for one thing it promotes the git monoculture. There was a time when there were several different source code control systems and you could pick the one you liked or that suited your needs. Now there's only git for all practical purposes and git is a bit of a mess, really.

For another thing, GitHub is a proprietary platform owned by Microsoft. We seem to be moving in the direction of everybody using GitHub. You tell me if Microsoft hosting all the world's code is a good plan.
It sounds like your problem with Github is that you wish Git were less popular. IIRC, Git eclipsed other tools in popularity long before Github came along and was eventually purchased by Microsoft.

One can believe that Microsoft is positioning itself to steal everyone’s secrets (those it can’t steal from Windows, Azure, etc.) I don’t. But more importantly, I don’t think avoiding Github would stop them.
IIRC until GitHub, Git was pretty hard to use and only hardcore devs with certain needs like Linux Kernel used it. There was plenty of division in DVCS are between Git, Bazaar and Mercurial. GitHub hid a lot of Git complexity behind pretty and simple interface and made forking and some of social aspects of OSS projects accessible to wider audience thus making Git sort of winner.

(As for me, I keep using SVN whenever I can, including accessing GitHub repos. SVN-GIT Bridge was/still is full of WTFs like timeouting long running op, broken handling of obliterate in log, broken handling of subtree checkout)
 
Upvote
0 (2 / -2)

adamsc

Ars Praefectus
4,469
Subscriptor++
PHP 80 % of websites? Humanity is doomed.

Because 80% of websites running Python/ASP.NET/Node/whatever is sooooo much better?

The biggest problem with PHP and all the other languages IMO is that people grab sample code from some rando site and it works and they think they are developers and they leave this shit running on live servers hooked up to the net.

My number one task for the last month or so has been trying to explain the difference between code that functions, and production ready code to senior management...

I spent about a decade using PHP from around 1998 on, recently spent some time working with PHP 7, and could not agree less, despite missing the enthusiasm I had back then fleeing ASP and ColdFusion. PHP has two properties which are riskier than the common alternatives: error handling is off by default and it has various places which aggressively try to coerce types or execute code. There’s also a bunch of common foot-guns like the random ordering of function arguments in the standard library, which I’ve seen lead to security problems or simply background noise which masked more serious things (“we can’t lint this because it generates thousands of errors!”).

Is error handling really off by default? Maybe I'm just so used to working on larger enterprise-y projects but I thought it was on by default these days. I do see a lot of legacy (5.x) projects where the people who built it just turned off all warnings rather than fix the problems in their code (e.g. instead of checking that a variable is set before using it they just use it for comparison and turn off warnings so their logs won't get cluttered).

There's definitely a challenge here since culture varies a lot across teams. I think PHP is more prone to have confusion here because the language itself has had a long development history and so you get a mix of APIs which are C-style (often thin wrappers) where you have to scrupulously check return values and things which raise exceptions, confusing multi-type return values which require careful use of === or type checks, etc. because all of the developers using it have been trained to think that this is normal. There's been some general improvement in the community but it's hard to turn things around after 3 decades, especially since at least in my experience a high fraction of the people who care about software quality decamped to other languages in the 2000s.
 
Upvote
1 (1 / 0)

jock2nerd

Ars Praefectus
4,938
Subscriptor
I can see why they are doing this, but it still worries me that all source code tends to end up on GitHub.

Haven't we learned that platform monoculture is bad?

(I guess not).
Git being Git, why should it matter if GitHub is a common place to host repositories? Does it naturally impose any kind of culture beyond Git itself? GitHub-specific features seem to be convenient wrappers for functionality that exists or could be replicated elsewhere.

Well, for one thing it promotes the git monoculture. There was a time when there were several different source code control systems and you could pick the one you liked or that suited your needs. Now there's only git for all practical purposes and git is a bit of a mess, really.

For another thing, GitHub is a proprietary platform owned by Microsoft. We seem to be moving in the direction of everybody using GitHub. You tell me if Microsoft hosting all the world's code is a good plan.
It sounds like your problem with Github is that you wish Git were less popular. IIRC, Git eclipsed other tools in popularity long before Github came along and was eventually purchased by Microsoft.

One can believe that Microsoft is positioning itself to steal everyone’s secrets (those it can’t steal from Windows, Azure, etc.) I don’t. But more importantly, I don’t think avoiding Github would stop them.
IIRC until GitHub, Git was pretty hard to use and only hardcore devs with certain needs like Linux Kernel used it. There was plenty of division in DVCS are between Git, Bazaar and Mercurial. GitHub hid a lot of Git complexity behind pretty and simple interface and made forking and some of social aspects of OSS projects accessible to wider audience thus making Git sort of winner.

(As for me, I keep using SVN whenever I can, including accessing GitHub repos. SVN-GIT Bridge was/still is full of WTFs like timeouting long running op, broken handling of obliterate in log, broken handling of subtree checkout)

Nah, once Gerrit came along, internal teams could successfully use git.

The problem of standalone git isn't there isn't a really effective team-level code review and acceptance control system, so corporate teams couldn't really use it.

Adding Gerrit really makes the difference, and I find it superior to Github for enforcing code review and code acceptance.
 
Upvote
1 (1 / 0)
Well, for one thing it promotes the git monoculture. There was a time when there were several different source code control systems and you could pick the one you liked or that suited your needs. Now there's only git for all practical purposes and git is a bit of a mess, really.

Those other tools still exist & nothing really stops you from using them if they truly do suit your needs better than git.

Git is also an open source project, so anyone who thinks they can clean up something messy is invited to submit improvements.
 
Upvote
0 (1 / -1)

VividVerism

Ars Tribunus Angusticlavius
9,004
Well, for one thing it promotes the git monoculture. There was a time when there were several different source code control systems and you could pick the one you liked or that suited your needs. Now there's only git for all practical purposes and git is a bit of a mess, really.

Those other tools still exist & nothing really stops you from using them if they truly do suit your needs better than git.

Git is also an open source project, so anyone who thinks they can clean up something messy is invited to submit improvements.

Lack of a good free hosting service will stop a lot of people from using anything other than Git.

When BitBucket abandoned their Mercurial support last year, it pretty much sounded the death knell for Mercurial on small-scale public projects or personal pet projects.

I moved a few of my projects to SourceForge, but I'm not sure I'd start a new project there if I wanted to actually make it accessible to other people.
 
Upvote
0 (0 / 0)