1146 points · by lugg · 7y ago · 257 comments
"On Thursday, April 25th, 2019, we discovered unauthorized access to a single Hub database storing a subset of non-financial user data. Upon discovery, we acted quickly to intervene and secure the site.
We want to update you on what we've learned from our ongoing investigation, including which Hub accounts are impacted, and what actions users should take.
Here is what we’ve learned:
During a brief period of unauthorized access to a Docker Hub database, sensitive data from approximately 190,000 accounts may have been exposed (less than 5% of Hub users). Data includes usernames and hashed passwords for a small percentage of these users, as well as Github and Bitbucket tokens for Docker autobuilds.
Actions to Take:
- We are asking users to change their password on Docker Hub and any other accounts that shared this password.
- For users with autobuilds that may have been impacted, we have revoked GitHub tokens and access keys, and ask that you reconnect to your repositories and check security logs to see if any unexpected actions have taken place.
- You may view security actions on your GitHub or BitBucket accounts to see if any unexpected access has occurred over the past 24 hours -see https://help.github.com/en/articles/reviewing-your-security-log and https://bitbucket.org/blog/new-audit-logs-give-you-the-who-what-when-and-where
- This may affect your ongoing builds from our Automated build service. You may need to unlink and then relink your Github and Bitbucket source provider as described in https://docs.docker.com/docker-hub/builds/link-source/
We are enhancing our overall security processes and reviewing our policies. Additional monitoring tools are now in place.
Our investigation is still ongoing, and we will share more information as it becomes available.
Thank you,
Kent Lamb Director of Docker Support info@docker.com"
If they had write access, then leaked personal data is the least of anyone's worries. The real concern is how close the hackers came to infiltrating the image source for virtually every modern microservices system. If you could put a malicious image in say alpine:latest for even a minute, there's no telling how many compromised images would have been built using the base in that time.
See this issue: https://github.com/docker/hub-feedback/issues/873
Definitely wouldn't have helped prevent the compromise.
Even then just read access to code often allows enough info for leveraging/escalating privilege.
I'm not 100% sure if Docker hub uses deploy keys for repos it has access to thru the integration, but at least previously there was an option to manually add one to repository if it couldn't access it otherwise.
Their newer GH apps permission model allows fine-grained access to only specific repos (and also only read access e.g.). However their older Oauth flow only allows full access to everything. And 99% of GH integrations still seem to use the older authentication method.
This is also something that many CI providers suffer from. There are only few that already support GH apps.
With how much of the internet blindly pulls images from it, the potential gain from hijacking just one high-profile one would be monumental.
Shortcuts all around -- kind of reminds me of MongoDB. Sad it's the primary player...
How is this issue specific to Docker? Anyone can download a random library off github, use a shady linux distribution, or install utility tools loaded with spyware.
I don't think Docker aims to solve issues relating to trusting upstream software. It's a tool to help package applications, just like how tar allows you to package files. What you put in it is up to you.
Strawman. Anyone can use Debian Stable or at least Testing.
Actually only short names go to docker hub, one can setup their own registry and use it via dns names.
Example: docker pull quay.io/letsencrypt/letsencrypt
One day, there's going to be a colossal compromise, and that might finally change where we place security in the priority chain.
I do wish developers would be a little wiser around these things, especially when they see companies taking such huge amounts of capital. I found it quite depressing to watch the unquestioning way development communities assimilated the docker worldview.
But no, not Docker.
You're totally right; with as important as their registry is to well funded attackers, and as startup-y and "agile" as they are, and as godawful as the security practices are that underlie their tools and standards... they hadn't a chance. They still don't.
There is no reason to expect them to get better.
[0] https://twitter.com/WHHackersBR/status/1118393568656334850
Why wasn’t that the case before?!
It wasn't authentication credentials, but still.
as long as you're using software somewhere in the stack that isn't like maturity level 5, AND you don't have constant audits looking for novel attacks on working-as-intended systems, you're pretty much guaranteed to inherit (or create) a vulnerability at some point, and if you're important enough it will get exploited. the reason that doesn't mean we should start modeling computer systems as "living organisms that eventually get old and die" and should keep modeling security like war is that when you get hit, you can respond. all the layers matter, and insofar as Microsoft or Google do it right, they primarily do it right by having a mature process for monitoring, patching, isolating, etc.
as for docker hub though, yeah i'm totally with you. i'm just saying we shouldn't overestimate the preventive capacity of anyone, honestly. if you're doing anything important over the internet at all, you're making some compromises somewhere.
here are 2 links to things i handwaved at above, for example's sake:
https://www.wired.com/story/microsoft-email-hack-outlook-hot...
https://www.forbes.com/sites/kateoflahertyuk/2018/10/09/goog...
As I understand it, there's no element of signing from the actual devs of an image, just from the central trust service of Docker Hub.
There already have been questionable images hosted there ... just by users uploading compromised images. No hacking needed.
I thought, maybe I need to log out and try if the new password works. I clicked on Log Out link, the website has refreshed and I was still logged in.
I’m just hoping that I was using a password manager by then.
Any word as to the cause of this? Was something important stored in plaintext, etc.?
Eh? Doesn’t let you use what without an account?
Anyone can pull images anonymously. An account is only for publishing.
Mac: https://download.docker.com/mac/stable/Docker.dmg
Windows: https://download.docker.com/win/stable/Docker%20for%20Window...
Luckily I use both 2fa and random password for github, would suck to loose that account ;)
(Side note: this obviously wouldn't have prevented the current attack)
> Data includes usernames and hashed passwords
How are they hashed? And specifically, can we expect them to be already cracked?
It may also explain some suspicious behaviour / source of compromise in the past (we know when the issue was uncovered, not when the first dump was taken)
Though, as they say that passwords need changing, we can safely assume that their salting, hashing and work factor were insufficient and not following best practice. Just like the lack of 2FA.
Or did the get access to a partition of the user data? How is this even possible?
Some very old backup that had only 5% of earliest users?
Some log file which had plain-text creds of approx 5% users?
Or did they discover the attack as it was happening and kicked-out the attacker in the middle of a data download (only 5% complete)?
Also, why rely on users to change their passwords? Is there a security log I can check?
NPM is bad because the Javascript ecosystem is fast-moving with loose builds that have thousands of dependencies that are all bundled and run insider consumer's browsers.
It'd be a legit criticism of ruby gems or CPAN, but linux distros are an entirely different kettle of fish, and most of the mainstream distros take security pretty seriously
I hope this doesn't hurt docker too badly. I really like the hub / auto build service.
By replicating the images (or packages) that you need into your own account, you can minimise the possibility of a bad actor replacing a well-known image with something untrusted.
An alternative is to side-cart a service like Notary (https://docs.docker.com/notary/getting_started/) in order to establish a chain of trust for images. If an image gets changed, Docker will refuse to use it and you will be warned that it is untrusted.
Biased opinion on an alternative registry:
- Cloudsmith: https://cloudsmith.io/l/docker-registry/
But you've got other options, such as:
- Self-hosted: https://github.com/docker/distribution)
- Cloud-specific (e.g. ECR, GCR, ACR, etc.)
- Sonatype Nexus: https://www.sonatype.com
- ProGet: https://inedo.com/proget
- Gitlab: https://gitlab.com
- Artifactory: https://jfrog.com/artifactory/
If you're missing the auto-build functionality, this can be achieved reasonably easily with any of the mainstream and awesome CI/CD services out there, such as:
- SemaphoreCI: https://semaphoreci.com/
- CircleCI: https://circleci.com/
- DroneCI: https://drone.io/
Disclaimer: I work for Cloudsmith, and still think Docker Hub is great. :-)
Back to the images bit first:
Base images are only referenced/pulled at build time. So if you've already built your own image and stored it, it'll contain all of the layers necessary to run it without explicitly pulling from Docker Hub.
In the case that you're building new images (likely), it'll need to pull the base images from Docker Hub. However, if you pull the base image(s) from Docker Hub first, you can tag them and store them in your local (or hosted) registry, then refer to those explicitly instead.
For example (using a Cloudsmith hosted registry):
docker pull alpine:3.8
docker tag alpine:3.8 docker.cloudsmith.io/your-account/your-repo/alpine:3.8
docker push docker.cloudsmith.io/your-account/your-repo/alpine:3.8
Now, instead of the usual FROM directive: FROM alpine:3.8
You can refer to your own copy of alpine: FROM docker.cloudsmith.io/your-account/your-repo/alpine:3.8
As you can see Docker's syntax doesn't make this extremely pleasant, and you'll have to change existing Dockerfiles to point at the base images, but it's certainly possible to mirror your dependencies without rebuilding.Caveat: The downside is that you have to trust those dependencies at the exact point you pull them down, so I concede it is still not perfect without rebuilding the lot. :-)
Nevertheless: The base images will be pulled from dockerhub by default and I am not sure we should trust them. Do we have any better alternatives for this?
https://blog.madhuakula.com/some-tips-to-review-docker-hub-h...
Say I use Mongodb and enabled authorization. Will I be fine then? How to discover unauthorized access?
In the worst case, if someone notifies you of a configuration problem or some software bug that allows anonymous access to your database or the ability to remove logs, you may have to assume the entire database was compromised since the existence of that configuration issue or software bug.
> I imagine it is a one way hash
All hashes are one way. If it's lossless and can be reverted, it's a compression algorithm or isomorphism or encryption or cipher or any of a number of other things, but not a hash.
> I don’t even know how it can get decrypted.
It is not decrypted, but brute forced. For example, even if you can't algorithmically figure out what the input to md5sum is that gives you '1f3870be274f6c49b3e31a0c6728957f', you could apply md5sum to every word in the dictionary in a matter of seconds and find out that 'apple', when md5summed, has that output. You would then have one possible password for that hash (though technically there are infinitely many inputs that have that output).
The only way we can know how computationally difficult it is to brute force the password hashes is if we know the following: 1) the hash algorithm used (and other inputs like cost factor) and 2) the entropy of the salt used. Those two together lets us calculate the amount of computation needed to try one brute force "guess". Individual password's difficulty to be brute forced can then be calculated from their entropy (e.g. 'apple' has less entroy than '2SEZb'), to determine the average number of inputs needed to be tried, multipled by the cost of each attempt. Given that difficulty, you can then estimate how long an attacker will take to find your password by estimating how much computational power they have at their disposal.
In general, if you randomly generate 10+ character passwords and docker used best practices, the answer is that any attacker will not get your password in under a thousand years, and if you use a password which has been leaked before or is a dictionary word (or simple variation), it can be found on the order of minutes to days.
The most famous application of rainbow tables is one of Microsoft's family of terrible password hashes LM. But the reason it breaks that wide open is not just the lack of salt, it's also that LM hash only works for 7 character passwords, and up to 14 chars are supported by doing two entirely separate hashes - so you can craft rainbow tables for all possible 7 character inputs and then reverse the hash.
"Sorry, it's not you. It's us, but we are working on it!"
And the main usecase is k8s. So docker is just an implementation detail its relevancy is waning imo
Some organizations took the risk of running docker taking images directly from docker hub. They were relaying the security of the images to them.
Some organizations are going to panic now and host their own registry. Which they need to protect as well. But in general it will create a better decentralized ecosystem.
I think this is good for the docker community in general.
- Change your password on https://hub.docker.com
- Check https://github.com/settings/security
- Reconnect oauth for Automated Builds
- Roll over effected passwords and API keys stored in private repos / containers
Quick take:
- Password hashes
- Github tokens
- Bitbucket tokens
- Your Automated Builds might need new tokens
Checking my github logs - It looks like they've known about this for at least a full 24 hours. Most people aren't going to have this looked at until Monday which kind of sucks. Hopefully there is more of a postmortem coming.
Is anyone from github able to comment on this as well?
There doesn't seem to be a way for us to tell if a repo was read by these keys over that time period.
The following SSH key was added to the foo/bar repository
by myorg-dockerhub-user:
Docker Cloud Build
39:31:51:be:d6:00:c4:ef:c7:74:c2:16:66:33:93:06
If you believe this key was added in error, you can
remove the key and disable access...
I wonder if this is related? Dockerhub integration and its keys were still present on Github. In any case, I've revoked everything until the impact becomes clearer.It seems like Docker Hub is implemented as an OAuth app [2], where these granular options are not available and you have to grant access to all your repositories.
[1] https://developer.github.com/apps/differences-between-apps/
honest question, what's the point of using OAuth when the Authz is so coarse? Why not augment to have scopes per repo? Is it considered bad practice to have have a variable (repo name) as a scope?
> Service user (or machine/bot account) suggested
> Attaching your personal GitHub or Bitbucket account to this Docker Hub organization will allow other organization owners to create builds from your private repositories. We suggest using a service user (also referred to as a machine user or bot account).
c.f.: https://docs.docker.com/docker-cloud/builds/automated-build/...
Seems worthwhile to do this, if you're an enterprise or otherwise have sensitive private repos. But I agree that it would be better to have an easier per-repo authorization system, since many users won't bother going through the hassle of setting up a service account.
> c.f.: https://docs.docker.com/docker-cloud/builds/automated-build/....
Did they remove this language from your link? I don't see it anymore.
Also not sure what access permissions you need but deploy keys are repo level.
https://developer.github.com/v3/guides/managing-deploy-keys/...
Machine users are another option.
https://developer.github.com/v3/guides/managing-deploy-keys/...
EDIT: it finally worked, 4th attempt, and very slowly. Looks like something isn't working 100% as it should
EDIT 2: aaaand I can't login now with the new password. A password reset did work, but it looks like their password database is under some stress at the moment.
Specifically to make the password database more secure, the generation of password hashes is very computationally intensive by design (e.g. that's the whole point of something like bcrypt vs. sha1)
Password systems really shouldn't be designed to handle a 10x or 100x load without some slowdown. If they could handle that, it means their password DB probably isn't as hardened as it should be.
Can this be used to upload containers with security exploits in order to gain access to machines (i.e. does it give write access to the containers)?