News for hackers. Stuff that matters.
Re:Musl 1.2.4 adds TCP DNS fallback by leononame on Sunday July 30, 2023 @02:15PM (#36934251)
Can you point me on where to look for more details on securing a container? I'm a developer myself, and for me, the main benefit of containers is being able to deploy the app myself easily because I can bundle all the dependencies.

What would you suggest I restrict at runtime and can you point me to a tutorial or an article where I can go have a deeper read on how to do it?

Re:Musl 1.2.4 adds TCP DNS fallback by robinhoodexe on Sunday July 30, 2023 @02:36PM (#36934476)
What you want to read is the kubernetes pod security context fields[1].

In your Dockerfile, add a non-root user with UID and GID 1000, then in the end of your Dockerfile, right before a CMD or ENTRYPOINT you change to that user.

In your kubernetes yaml manifest, you can now set runAsNonRoot to true and runAsUser & runAsGroup to 1000.

Then there’s the privileged and allowPrivilegeEscalation fields, these can nearly always be set to false unless you actually need the extra privileges (such as using a GPU) on a shared node.

Then there’s seccomp profiles and the system capabilities. If you can run your container as the non-root user you’ve created, and you don’t need the extra privileges then these can safely also be set to the most restricted. Non-privileged non-root is the same as all capabilities are dropped.

The tricky one is the readOnlyRootfilesystem field. This includes /tmp, which is considered a global writeable directory, so the workaround is to make a in-memory volume and mount it at /tmp to make it writable. Likewise, your $HOME/.cache and $HOME/.local directories (for the user you created in your Dockerfile) are usually used by third party packages, so creating mounts here can be useful as well (if for some reason you can’t point it to /tmp instead).

[1] https://kubernetes.io/docs/tasks/configure-pod-container/sec...

Re:Musl 1.2.4 adds TCP DNS fallback by lenova on Monday July 31, 2023 @03:15AM (#36939630)
> In your Dockerfile, add a non-root user with UID and GID 1000, then in the end of your Dockerfile, right before a CMD or ENTRYPOINT you change to that user.

I'm not certain, but would it be more secure to create a non-root user in the Dockerfile, but _don't_ use UID 1000. Use volume mounts to grant host disk access instead.

Re:Musl 1.2.4 adds TCP DNS fallback by robinhoodexe on Monday July 31, 2023 @03:38AM (#36939750)
If you want to use the runAsUser and runAsGroup options in kubernetes that user needs to exist, hence why creating it is needed.

In our case, we have our own base container images that include this user. The base images are either just plain copies of official ones (such as dotnet or curl) or also includes stuff that almost everyone needs (such as MSSQL ODBC drivers, libxml2, curl etc) in the case of python/R/node.

Re:Musl 1.2.4 adds TCP DNS fallback by 4oo4 on Sunday July 30, 2023 @03:17PM (#36934888)
Re:Musl 1.2.4 adds TCP DNS fallback by vbezhenar on Sunday July 30, 2023 @03:45PM (#36935174)
Basically you need to work as unprivileged user and with immutable file system (of course you can have ephemeral /tmp or persistent /data, but generally the entire system should be treated as read-only).