News for hackers. Stuff that matters.
Re:Pure Bash Web Server by solatic on Friday February 16, 2024 @09:35AM (#39397545)
Projects like this reiterate just how important it is, from a security perspective, to ensure your production services are running in containers without an included shell. If an attacker can get a shell, they can do pretty much anything.

Debug containers are now a stable feature in Kubernetes. It honestly boggles my mind how companies will throw so much time, money, and effort into the cybersecurity product du jour when they can get the vast majority of the value by moving everything into distroless, shell-less containers running on managed VMs that are optimized for container workloads.

Re:Pure Bash Web Server by deathanatos on Friday February 16, 2024 @11:29AM (#39399198)
Debug containers have been a bit of a let down in UX. It's rather difficult to do sort of basic stuff, and a lot of stuff is hidden behind flags.

E.g., if you just sort of roll with the defaults, you're dropped into a pod in a very confused state: `ps -ef` says nothing in your debugee is running, and the filesystem of the debugee is nowhere to be found.

You can work around both of those (the first is --target, but the latter requires an intricate SO answer¹) but its the sort of thing that would be nicer out of the box?

The node debugging mode is a bit better: by default, puts you in at least the host pidns, and mounts the host FS.

¹https://stackoverflow.com/questions/73355970/how-to-get-acce...

Re:Pure Bash Web Server by bravetraveler on Friday February 16, 2024 @11:57AM (#39399656)
As someone who doesn't do much (any) k8s...

Seems only marginally better than using nsenter on a privileged container to just go muck with the host

Re:Pure Bash Web Server by freedomben on Friday February 16, 2024 @04:25PM (#39403171)
I've also been disappointed with debug containers. They are often not useful for debugging trick production-only issues because so many of those issues are related to container state, which can be (often is) different inside the container. Certain languages/platforms and developer discipline are better about this than others, like if you're using functional/immutable languages then it's less of an issue.

For applications that aren't super high security, I've been really appreciating using immutable hosts (that get regularly updated/rotated), along with CI/CD that is constantly rebuilding from source, applying latest software updates, and deploying the latest version of the app. Combined with other tools like scanners, and de-bloating your images, it really raises the height of the fruit.

Re:Pure Bash Web Server by solatic on Friday February 16, 2024 @06:31PM (#39404453)
> UX

I would agree, but so much of day-to-day Kubernetes is arcane CLI commands to begin with. Other stuff that is non-trivial to do on the CLI but comes up in most reasonable production deployments:

  * Rotating secrets without exposing the secret to the shell history file (hint: kubectl apply -f can take - to signify atdin, but not kubectl patch!)
  * Ensuring your edits to a ConfigMap pass application-level validation (i.e. your configuration changes won't crash your app, not just that it's a valid ConfigMap)
  * Anything to do with user auth or RBAC
  * Scaling the default persistent volume size of a StatefulSet
The truth is that Kubernetes is a platform, and just like how most people don't want to run a bare copy of Bash or VIM on their laptop, people will figure out aliases, one-liners, and other functions to help make them effective. So some of working effectively with Kubernetes means, yes, building your own custom debug containers, and writing your own helper shell stuff.
Re:Pure Bash Web Server by arve0 on Saturday February 17, 2024 @12:57AM (#39406833)
> without exposing the secret to the shell history file

Any command in shell with a space before it will be omitted from history.

Agree it should take input from stdin.

Re:Pure Bash Web Server by sirn on Saturday February 17, 2024 @01:30AM (#39406958)
This requires `setopt HIST_IGNORE_SPACE` (zsh) or `HISTCONTROL=ignorespace`/`HISTCONTROL=ignoreboth` (bash/ksh) to be set and may not be enabled by default in many distros (e.g. NixOS doesn't, Alpine doesn’t, etc).

Always check your shell before assuming this will work!

Re:Pure Bash Web Server by swozey on Friday February 16, 2024 @10:22AM (#39398229)
I work on multi-tenant k8s clusters at CDNs and used to work at Rancher and have seen just about every multi-tenant / federated deployment there is, nasa, meta, etc. Stuff where even the hardware vfio paths mounting the nic or gpu channels keep users apart from one another, and the entire path out of the cluster are completely apart from k8s and any userspace and would be something like multus as a shim- what exactly are you referring to that can cgroup hop via a shell that we're not currently mitigating? It's the hardware being infected by something we worry about at this level.

A lot of the CDNs even use tools like kubevirt where the segmentation is even further. And then we have gvisor, firecracker, etc.

I admittedly haven't touched k8s code since 1.18 but I can't think of anything like you're referring to and I definitely would like to know about it.

Thanks.

Re:Pure Bash Web Server by kiririn on Friday February 16, 2024 @11:27AM (#39399150)
Also can go even simpler and use apparmor and/or systemd hardening instead of containers
Re:Pure Bash Web Server by riddley on Friday February 16, 2024 @10:06AM (#39397996)
Please do a write-up of these debug features. I'd love to learn about them.
Re:Pure Bash Web Server by deathanatos on Friday February 16, 2024 @11:31AM (#39399222)
Re:Pure Bash Web Server by robinhoodexe on Friday February 16, 2024 @09:42AM (#39397660)
Out of curiosity, how would you run Python or R workloads in kubernetes without a distro or shell?
Re:Pure Bash Web Server by ttymck on Friday February 16, 2024 @10:09AM (#39398039)
Re:Pure Bash Web Server by oneshtein on Friday February 16, 2024 @11:37AM (#39399323)
Python is better than shell, so intruder will use it first.
Re:Pure Bash Web Server by jonhohle on Friday February 16, 2024 @10:06AM (#39397999)
Python needs an ld.so and libc (minimally) but not a shell or other external utilities. Shebang scripts are loaded by ld.so, not the shell.
Re:Pure Bash Web Server by khrbtxyz on Friday February 16, 2024 @10:22AM (#39398219)
Shebang scripts are supported directly by the kernel via the exec family of system calls, so ld.so shouldn't be involved.

https://github.com/torvalds/linux/blob/master/fs/Kconfig.bin...

  config BINFMT_SCRIPT
 tristate "Kernel support for scripts starting with #!"
 default y
 help
   Say Y here if you want to execute interpreted scripts starting with
   #! followed by the path to an interpreter.
Re:Pure Bash Web Server by usr1106 on Friday February 16, 2024 @11:37AM (#39399329)
Python with batteries included, doesn't that mean exploit tools included?

No personal attack intended, I am wondering this about my own embedded product which contains Python.

Re:Pure Bash Web Server by thecodedmessage on Friday February 16, 2024 @11:05AM (#39398818)
Yeah, I remember reading the code in the kernel that handles shebang a long time ago. ld.so is not involved.