Live data from Hacker News

Escaping privileged containers for fun

pwning.systems

31–40 of 42 posts

Re: Escaping privileged containers for fun

#31

Earlier quoted context omitted.

Unless you have a secure mechanism to forbid containers from running with `--privileged` (which does not come with container runtimes that I'm aware of), or unless your container runtime launches a VM to run the containers in, then the conception of containers being a security mechanism is a pretty thin one, indeed. Containers can be part of a secure application runtime environment, but much like sugary cereal can be…

Attackers have no control over the --privileged flag, so what you're basically asking for is a lint that greps for "--privileged" and fails CI if it finds it. Some things may make this harder, like Kubernetes presumably, but idk it seems relatively straightforward and also not exactly the fault of containers.

> Attackers have no control over the --privileged flag

Maybe, maybe not. It really depends on the environment. If one's orchestration system allows an attacker to supply arbitrary arguments to a runtime, then it's quite possible that a container could be run in privileged mode without explicit authorization.

Good CI hygiene is part of the solution, but again, a comprehensive approach is needed.

The thing that makes `--privileged` an attractive nuisance is that the container runtime usually runs as root, and so it's literally a mechanism for trivial privilege escalation if the agent trusts the request being given to it, and container agents are rarely configured to require authentication of any sort. (The typical default is to run without TCP enabled, and where the Docker socket has some sort of group membership required.) Compare with the traditional UNIX privilege model, in which non-root users don't get privileges, and escalation happens through an agent like sudo(1) which typically requires re-authentication unless you're explicitly adding `NOPASSWD` to the sudoers(5) file.

Re: Escaping privileged containers for fun

#32

Earlier quoted context omitted.

Attackers have no control over the --privileged flag, so what you're basically asking for is a lint that greps for "--privileged" and fails CI if it finds it. Some things may make this harder, like Kubernetes presumably, but idk it seems relatively straightforward and also not exactly the fault of containers.

> Attackers have no control over the --privileged flag Maybe, maybe not. It really depends on the environment. If one's orchestration system allows an attacker to supply arbitrary arguments to a runtime, then it's quite possible that a container could be run in privileged mode without explicit authorization. Good CI hygiene is part of the solution, but again, a comprehensive approach is needed. The thing that makes `…

Oh, you're talking about an attacker who's outside of the container? That's a completely different threat model.

Re: Escaping privileged containers for fun

#33

Earlier quoted context omitted.

Why is the Linux kernel garbage? I thought Linux had decent security chops?

Written in C, huge codebase, decades of alienating security researchers, etc.

Is this "Linux is garbage" opinion shared broadly by security researchers? I did some Googling around about opinions, and I didn't find anything that suggested that this view is widely shared by security researchers (I found some claims that security researchers held Linux in high regard, but those claims themselves didn't seem particularly authoritative). Also, what is "alienating"? (I don't have much of a view into interactions between kernel maintainers and security researchers) As for "written in C", what production-grade kernels aren't written in C?

Re: Escaping privileged containers for fun

#35

Earlier quoted context omitted.

Written in C, huge codebase, decades of alienating security researchers, etc.

Is this "Linux is garbage" opinion shared broadly by security researchers? I did some Googling around about opinions, and I didn't find anything that suggested that this view is widely shared by security researchers (I found some claims that security researchers held Linux in high regard, but those claims themselves didn't seem particularly authoritative). Also, what is "alienating"? (I don't have much of a view into…

> Is this "Linux is garbage" opinion shared broadly by security researchers?

Everyone I know would agree, yeah. I think the infosec world is probably more or less aligned on this, as much as anything, although that's a low bar and there is no single infosec community.

> what is "alienating"

Decades of Linus and Greg insulting or attacking security researchers in various ways. It's become pretty antagonistic on both sides I think.

> As for "written in C", what production-grade kernels aren't written in C?

None afaik. It just all jumbles together to paint the 'garbage' picture.

Re: Escaping privileged containers for fun

#36

Earlier quoted context omitted.

Is this "Linux is garbage" opinion shared broadly by security researchers? I did some Googling around about opinions, and I didn't find anything that suggested that this view is widely shared by security researchers (I found some claims that security researchers held Linux in high regard, but those claims themselves didn't seem particularly authoritative). Also, what is "alienating"? (I don't have much of a view into…

> Is this "Linux is garbage" opinion shared broadly by security researchers? Everyone I know would agree, yeah. I think the infosec world is probably more or less aligned on this, as much as anything, although that's a low bar and there is no single infosec community. > what is "alienating" Decades of Linus and Greg insulting or attacking security researchers in various ways. It's become pretty antagonistic on both s…

Fair enough. While I understand that there may not be any body which perfectly represents the infosec community, I would be curious if there are any surveys or even statements by somewhat authoritative bodies (something like NIST?).

No doubt that Linus is antagonistic. I haven't heard anything that suggests security researchers as a collective have taken it personally (I would expect they, like most people, understand that this is a personality quirk).

> None afaik. It just all jumbles together to paint the 'garbage' picture.

It seems pretty meaningless and unhelpful to categorize all C software as "garbage". Programming language isn't the only factor in the number or severity of vulnerabilities, and indeed you could have a Rust (or whatever) kernel which has more numerous and/or severe vulnerabilities than the Linux kernel. To deserve the "garbage" designation, I would expect some supporting evidence that the Linux kernel development process lacks rigor.

Moreover, "secure" is relative, so if you're going to call the Linux kernel "garbage" then it seems like you should have some kernel which is not "garbage" (and personally my minimum qualification for a "non-garbage" kernel is "production grade" i.e., not a research project).

Re: Escaping privileged containers for fun

#37
post #25

One-liner to trigger core dumping: $ sh -c 'kill -ABRT $$' Aborted (core dumped)

$$ would give the pid of the inner sh command right? Because the single quote would disable interpolation in the outer shell. So why would this work?

It works by killing the inner shell. The outer shell remains alive, so that it can print the "core dumped" message.

If you don't mind losing your current shell and don't care about the message, you can use just:

  $ kill -ABRT $$

Re: Escaping privileged containers for fun

#38
post #37

Earlier quoted context omitted.

$$ would give the pid of the inner sh command right? Because the single quote would disable interpolation in the outer shell. So why would this work?

It works by killing the inner shell. The outer shell remains alive, so that it can print the "core dumped" message. If you don't mind losing your current shell and don't care about the message, you can use just: $ kill -ABRT $$

[deleted]

Re: Escaping privileged containers for fun

#39
post #12

Earlier quoted context omitted.

Containers increase the effort for the attacker to put into escaping that container — provided the developers actually run code that doesn't make that easy right of the bat. I have seen to much code where you can really feel the thought of "let's just use docker, then we don't have to think about complicated linux things like priviledges and permissions". Using containers as an extra layer of security is perfectly fi…

> "let's just use docker, then we don't have to think about complicated linux things like priviledges and permissions" Honestly, that's fine. What more do you want? For developers to roll their own SELinux and Apparmor profiles? For them to manually implement seccomp filtering? No one does that. The reality is that no one is choosing between "containers or some other approach", they're choosing between "containers or…

[deleted]

Re: Escaping privileged containers for fun

#40
post #17

Earlier quoted context omitted.

Hopefully they aren't choosing containers between "containers + insecure app" or "no containers + secure app", thinking containers will secure the app.

Who does that? I have specific apps to run, the choice is to deploy them bare or in containers.

As a user yes, as a developer many people who would have to think long and hard about when to use which linux user with which priviledges, when to drop them outside of an container will just use root for everything within the container out of an false sense of security.

Software security always works in layers and if your only layer is the container, good luck with that.

Post reply on HN