News for hackers. Stuff that matters.
Re:Dockerfile Security Best Practices by 3pt14159 on Wednesday October 14, 2020 @10:53AM (#24777167)
Overall great post.

> If you rely on latest you might silently inherit updated packages that in the best worst case might impact your application reliability, in the worst worst case might introduce a vulnerability.

On this one I disagree. Your CI should handle reliability (and if not, you have a bigger problem) and you're more likely to patch a vulnerability than to introduce a new one and it's unlikely that by the time a PR hits production that the version is compromised.

I understand that updating cuts both ways when it comes to security, but I agree with Matt Tait's ultimate conclusion when he spoke on this issue a few years ago: For most medium size and smaller companies constantly updating is safer than delaying. He had real world data and graphs of compromise windows, etc. Short answer was that attackers are more time motivated than defenders.

Re:Dockerfile Security Best Practices by tomphoolery on Wednesday October 14, 2020 @11:34AM (#24777753)
Pinning the version tag for base images in Dockerfile is a good idea beyond the scope of security. It helps with onboarding as well. I've been in situations where depending on the `:latest` tag of a base image caused different versions of that image to be used on different machines, resulting in developers having weird issues that no one else was having ("I thought Docker was supposed to solve this!"). Now, I only use non-specific tags like `:latest` or `:12-alpine` before I distribute the Docker image, by either collaborating with others or pushing it to Docker Hub. It just gives me peace of mind to know that others are building on the exact same stack as I was building on.
Re:Dockerfile Security Best Practices by 3pt14159 on Wednesday October 14, 2020 @12:21PM (#24778374)
This is a reasonable choice to make depending on the complexity of your project.

For the projects I've been on, the latest version plus the test suite is enough to catch weirdness creeping in and, as a side benefit, it gets fixed faster than if it were pinned. Sometimes the issue really is caused by the base image and it is easier to get a fix merged if the issue was caused quite recently because the developers responsible see early reports of issues as more endemic than if they're reported days or weeks later.

Re:Dockerfile Security Best Practices by piaste on Wednesday October 14, 2020 @08:02PM (#24783221)
For many popular images, you can use a major-version tag and fetch the latest patch but avoid breaking changes.

Eg. postgres:12 instead of either postgres:latest or postgres:12.0.1

Re:Dockerfile Security Best Practices by dbrgn on Wednesday October 14, 2020 @11:14AM (#24777435)
Operating system updates are the responsibility of the base image. Use a base image that is regularly updated. For your own images, ensure that they are also being rebuilt regularly.

There are a lot of semi-official Docker images on Docker Hub that are published once and never updated until the next software release. That is a huge anti-pattern in my view, those images should not be relied on for production.

Re:Dockerfile Security Best Practices by 5d749d7da7d5 on Wednesday October 14, 2020 @06:49PM (#24782631)
This makes me wonder, why there has not been a bigger push towards microkernel/minimal OS with audited toolchains that were "done". Minimal features and minimal surface area. A plug and play distribution with security at the forefront which rarely needed updating because only the essential was available.

I would be fine taking a healthy performance hit if I knew that the base OS was secure. (At this point I expect the BSD folks to chime in that they have had this for years)

Re:Dockerfile Security Best Practices by piaste on Wednesday October 14, 2020 @08:08PM (#24783257)
Isn't that (one of) the design goals of CoreOS, Alpine, Clear Linux, etc.?
Re:Dockerfile Security Best Practices by theptip on Wednesday October 14, 2020 @11:41PM (#24784676)
Further in that direction, https://github.com/GoogleContainerTools/distroless β€” stripping out as much of the OS code as possible.
Re:Dockerfile Security Best Practices by michaelperel on Wednesday October 14, 2020 @12:34PM (#24778548)
Shameless Plug: I wrote a cli-plugin for docker, docker-lock, that will track the image digests (SHA's) of your images in a separate file that you can check in to git, so you will always know exactly which image you are using (even if you are using the latest tag). It can even rewrite all your Dockerfiles and docker-compose files to use those digests.

https://github.com/safe-waters/docker-lock

Would love for anyone dealing with this issue to check it out!

Re:Dockerfile Security Best Practices by cooljacob204 on Wednesday October 14, 2020 @11:33AM (#24777734)
Would you have a link to the talk? I couldn't find it with a google search.
Re:Dockerfile Security Best Practices by 3pt14159 on Wednesday October 14, 2020 @12:17PM (#24778317)
I don't have time to track down a link to a video at the moment, but it was at Infiltrate, an offensive-minded cybersecurity conference out of Miami.
Re:Dockerfile Security Best Practices by kronin on Wednesday October 14, 2020 @01:09PM (#24778990)
Re:Dockerfile Security Best Practices by donmcronald on Wednesday October 14, 2020 @12:30PM (#24778493)
I always thought `:latest` was a bit of a special case. Ex: Pushing `2.0.1` followed by `1.1.4` would leave `1.1.4` as the `latest` image which could be an issue by itself. Is that wrong?

I've always tried to pick stable tags [1] if they're available.

1. https://docs.microsoft.com/en-us/archive/blogs/stevelasker/d...

Re:Dockerfile Security Best Practices by sfoley on Wednesday October 14, 2020 @12:51PM (#24778762)
There is absolutely nothing special about `latest`, it’s just a tag like any other. It simply happens to be the default tag when omitted, just like how `origin` is the default remote name when performing a `git clone`.
Re:Dockerfile Security Best Practices by GauntletWizard on Wednesday October 14, 2020 @07:31PM (#24782990)
To expand on this: Well maintained projects do not often push to `:latest`; They treat that tag like a `stable` version and push to it only public, stable releases. Roughly, it should always be max(semver), though practically it often trails when a new major release happens.
Re:Dockerfile Security Best Practices by donmcronald on Wednesday October 14, 2020 @11:02PM (#24784449)
> There is absolutely nothing special about `latest`

> It simply happens to be the default tag when omitted

That makes it special though, right? It's different than any other tag because it can be inadvertently pushed via accidental omission.