Backdoored images downloaded 5M times removed from Docker Hub
arstechnica.com
arstechnica.com
https://github.com/pypa/warehouse/issues/3356
You can still get them through some obscure API and you still need to know the right PGP key for verification, but this really signals the lack of consensus and awareness on the path toward a secure software supply chain.
EDIT: typos
$ curl -s $(curl -s https://pypi.org/pypi/cryptography/json | jq '.releases["2.2.2"][] | select(.has_sig) | .url' | sed -e 's/^"//' -e 's/"$//').asc
-----BEGIN PGP SIGNATURE-----
iQEzBAABCAAdFiEEBf2foWz3VzUNkaVgI1rl8Sn57ZgFAlq6dNgACgkQI1rl8Sn5
7Zg0Ygf/WzulfXom9qdbCHrUJh2xkTxPqK2/SUqDqOQ1OdKJm+MxDBcMhwrCdBDh
8+eXyPTLnnhPUcCSqVFcJeUu9KyKB2MhKi7gdBUHrDxjbufexxPC+L/KwjOq3nod
gL4OPHGGeX2ZgSlwFPR4zPIIheUmf9kPX88qtW8DD8zmuyhci6ibac9a/3fHkDVt
H27B+aqs+WObMjcfwZV7gMnRbZwUOBZvVFRxwfMHVuMpfbwhQC8HdBK74XKNaoTd
Golmpa5fqRm1sNquBz9YRVElWuw1qj1CZJhRBuR7V5xyPLX8J7EVUrYa70/fVtfr
hW7oAlNbMFYb58hGC9K20v6WX8XT2w==
=zox2
-----END PGP SIGNATURE-----
At least that's what I was able to piece together from the docs...(A quick search couldn’t tell me the integration status or if there are still plans to do so, but I’m familiar with the pypi plans from the TUF side)
There's a redirector that is supposed to provide stable URLs, although IME it doesn't work immediately after upload, which is when I need it most. :-/
And how much as-of-now clean code will turn into malicious code when bad guys take over npm repos in the future.
It might be possible to tackle this issue by some intelligent trust algo that combines a trust rank similar to google-page-rank and signed messages.
Say somebody pushes an update to their repo. Now the first user of it might read it and sign it with 'Looks OK /Joe'. And the next user sees the signed message by Joe in some kind of package-review-message list. Based on all the reviews and the trust of the reviewers, they then can calculate a trust score for the update.
At least npm has auditing now, so checking for problems is relatively trivial. GitHub even does it automatically.
Assuming automated builds, you can just read the dockerfile (and it's hierarchy if necessary), it's less complex syntax than perl by a long way.
Even assuming no automated build, all the information is in the manifest, and using something like portainer it's pretty easy to read.
For many images, no Dockerfile is provided. And even if there is, it's not clear that it has been used to produce the software. I tried many times to reproduce images from Dockerfiles and failed: What `apt get update` does, depends on the current time and your network configuration. You can never be suer what you get from DockerHub.
My strategy has been to copy the Dockerfiles and run `docker build` myself, instead of using the image files. Alas it's does not work very well.
https://samaritan.ai/blog/reversing-docker-images-into-docke...
That is a good point about lack of reproducability though. I suppose an interesting attack would be to deliberately forge information in the manifest before pushing to Docker hub...
I also tend to use anything other than the official images as "inspiration" and re-implement myself.
"Forge" is a bit of a strong word. The main reason Docker included build information in the image history was so that build caching would work (from memory). It's not meant to be an authoritative source of information about how an image was built at all (not to mention that "RUN apt-get update" tells you almost nothing about what packages were installed, when they were updated, etc).
Personally I think that the current trend of using Dockerfiles is completely broken in terms of reproduciblity and introspectability (I'm working on a blog post to better explain the issue).
Run your own devpi server, build a compromised version of any dependency you want, and you can install whatever you would like, with no sign of it in the Dockerfile.
npm (and i think the other repos too) implement more and more security tools and procedures to reduce the risk. But 100% security is impossible.
Or in Windows, or in Linux, or in Android,
or in IOS, or in OSX
None of these let random users upload stuff to their repos.The point is: you have to trust the developers at this companies, that they not do anything bad and that the companies check every code of every dev. Trust.
Unfortunately there has been a trend to ignore these and install directly of late, especially for dynamic language modules.
Neat idea. However, to accomplish this you have to mount the docker socket into Traefik's container...
Which means that when a bug shows up in Traefik attackers can pivot out of the container and onto the host; access to the docker socket is equivalent to root on the host.
And of course Traefik is the thing you're exposing directly to the internet.
It's like giving the guards outside manning your castle's gate the skeleton key to the rest of the castle.
Of course, Traefik is quickly becoming popular because of its simplicity. But to achieve this simplicity it carves a giant hole in the security of your application.
So no, Traefik is not the big security problem you make it out to be.
Sorry to be so harsh, but Traefik is one of the most amazin pieces of software I have come across in the last years that has seriously made my life much easier.
Security today doesn't mean that you are safe if you do everything according to best practices and follow the docs. Modern Security includes making sure that default settings are safe, and that it should be impossible or hard to set up the software in an insecure manner.
If you make it easy to shoot yourself in the foot, that's what people will do.
Yes they will. Just repeating it here because it bears repeating.
Yes, they don't care. And yes, there will be an attacker trying to exploit it.
Sure its not a problem if you use k8s, mesos, consul, or any of the other schedulers, but the security gap is still there.
[1] https://docs.traefik.io/user-guide/swarm-mode/#deploy-trfik
mounting the socket readonly doesn't help.
It then iterates over those containers and writes a nginx.conf file to a shared volume, then sends a SIGHUP signal to another container running nginx as a reverse proxy to the containers.
The "polling job" container doesn't expose any ports and is not reachable from the outside world and the only input into this program is reading data from the Docker Socket.
Do you think this is still vulnerable to attacks like Traefik is or does this 2-container routing protect against the attacks you're thinking of?
As others have suggested, Traefik should really be doing something similar (or Docker should add ACLs to its API).
raised over a year ago(!) is really interesting. It seems like many of the downloads may have been malicious - the author of the malicious images was scanning for open docker api ports and then installing their own images to mine cryptocurrency.
So they're essentially using docker as a dropper. Clever, in a way.
DockerHub is just the delivery mechanism.
From Kromtech's article I deduced that this only happens when a docker daemon (or kubernetes interface) is exposed to the Internet and an attacker uses that to download and start a docker image on the victim's host. Then they can bind mount a host directory like described and attack the host computer.
(One of the ideas of rootless containers is to remove the possibility of any privileged codepath, which helps eliminate this issue.)
https://github.com/sumdog/bee2/blob/master/ansible/roles/doc...
sudo dockerd -H tcp://0.0.0.0:8080
will happily start Docker with it listening on my IP address without TLS. It will print an all-caps warning, but nothing else (you don't even need to pass a --give-the-internet-root-access flag). However, I just submitted a PR which adds the --give-the-internet-root-access flag[1] because it's pretty obvious to me that very few users do this intentionally (and with full knowledge of the consequences).The ArsTechnica article, like most AT articles, glosses over most details and focuses on a small-time cryptomining campaign
A lot of times you're just installing the package you want with apt-get within your Dockerfile anyway; a package you can't check for normal updates for anymore since it's in a container. So now you need a tooling system around making sure your packages in your containers don't have security issues.
Docker is kinda a mess.
its immutable infrastructure at its heart, so yeah, you don't do updates on containers... what you do need is periodic rebuild of your images for upgrades and each new image needs to run all integration and system tests again.
it just makes this process easier than it is without docker. But it doesnt alleviate you of writing the system that actually keep everything updated in an automated way.
It also doesnt help you deploy unless you're already experienced with docker. and while we'Re on the topic... no, if you know how to execute 'docker run -it --rm ubuntu bash' you still don't know shit about it. sigh sorry, i'm just remembering someone from work today...
I also wonder about other packaging systems. CPAN, pip (pypy?) AUR and so on. It doesn't surprise me to see this happen. I wonder what other surprises might be in any of these packages.
FWIW, I'm running mostly Debian and some Ubuntu. I always prefer to install packages via the package manager rather than directly from some tool specific repository because I'll get automatic updates and some level of testing/vetting.
This seems incorrect because its impossible to see wallet balances on the Monero network. So I'm assuming they just came up with the numbers based on some rough calculations.
> The actor has been able to mine about 630 XMR to date, which at the current USD rate is more than $172,000 for just a little more than one year of activity.
[1]: https://www.fortinet.com/blog/threat-research/yet-another-cr...
While this will be anecdotal I found my `pip freeze` packages a lot more manageable compared to `npm ls --parseable`.
My Full Stack Flask application sits at about 64 requirements. Where last time I used expressjs my dependancies inside of node_modules inside of node_modules border-lined to insanity.
I can see myself hand picking and reviewing my requirements.txt, which I did to some extent.
But I just gave up with npm.
Which is a bit of a personal dilemma for me, because some of my tooling needs npm.
The numbers and ecosystem maturity make a huge difference in being able to vet dependencies.
And node_modules is now a flat tree for the most part.
The number of dependencies a basic JavaScript project pulls is definitely something to be concerned about though.
Also the versioning on npm is incredibly pathetic vs pypi. I would never trust npm for anything serious or waste my time debugging that crap.
FWIW that headline isn't great. Docker hub pulls in no way correlate to innocent users pulling/using those images. It could be (and this is quite likely) just other malware which made use of those images and just used Docker hub as a repository.
There are official images for the software in question and I don't think it's that likely that that many people ignored the official ones and got these ones.
This is basically what you do every time you install something (except when it's via a walled garden like an 'app store'). Besides, I'm not sure I would even classify mining for someone else as 'malicious'. It hogs your CPU a little, but if that's malicious then visual studio should be considered malicious as well.
The JS example another commenter made is more apt however the argument there is that you still requested the site and it's content (even if you didn't really want it). Whereas many of the installs of this "dockerised" miner were remotely via exposed Docker APIs. That I think is the real crux of the potential "malice" (for want a better description) here.
Screw the extra work, I'd rather write my own roles and Dockerfiles.
Most roles and Docker Hub images are pretty simple, and you should be evaluating them anyways before using them. If you’re concerned about the security but want to save the time in building and debugging, fork it, and maintain your fork, only pulling in changes from the upstream when you have time to vet them.
search for "Figure 7"
If your image is called monero-miner and a bunch of people download it, of course it's not going to be considered malicious code.
If your image is called apache-webserver and a bunch of people download it and you've stealth bundled a monero miner, of course it's going to be considered malicious code.
EDIT: even worse than that, the images are actually back doored they open up a reverse shell to allow the remote to execute arbitrary commands.