Better HN
topnewbestaskshowjobs
Log inSign up

staticassertion

13,486 karma · joined Jun 1, 2016 (10y ago) · 4,896 submissions

@insanitybit
Submissions

comment 4y ago · link · parent

> With this year's number of container breakout CVEs, seems like an important area.

Worth noting that even basic hardening in docker will prevent a lot of them. I say "in docker" because K8s disables seccomp, which matters a lot since `unshare` is denied by docker's seccomp and is very useful for attackers in a container. If you use Docker the main thing to do is just not run as root.

If you do that much, and it's not hard at all, you are in a much better place than a default k8s pod.

comment 4y ago · link · parent

> Without SELinux or seccomp restrictions, root can still pretty much do anything to the host even inside the containers.

That's not true

        Having a capability inside a user namespace permits a process to
       perform operations (that require privilege) only on resources
       governed by that namespace.  In other words, having a capability
       in a user namespace permits a process to perform privileged
       operations on resources that are governed by (nonuser) namespaces
       owned by (associated with) the user namespace (see the next
       subsection).

       On the other hand, there are many privileged operations that
       affect resources that are not associated with any namespace type,
       for example, changing the system (i.e., calendar) time (governed
       by CAP_SYS_TIME), loading a kernel module (governed by
       CAP_SYS_MODULE), and creating a device (governed by CAP_MKNOD).
       Only a process with privileges in the initial user namespace can
       perform such operations.
> For the most part this is troublesome when parts of the kernel or host userspace code are not fully aware of the different forms of namespacing (there are still portions that just check for an effective UID of 0, without checking whether they're in a namespace for example).

Yes, like I said:

> But an attacker can escape by exploiting the kernel, which I think most security people would consider to be not particularly high effort.

> Dropping privileges to a different user still trace's it origin back to the root user on the host

It does not. Only if the process creating the container is root, which with unprivileged user namespaces is not (necessarily) the case.

> The NS_GET_OWNER_UID ioctl(2) operation can be used to discover the user ID of the owner of the namespace; see ioctl_ns(2).

"root" isn't the point anyways, it's about checking capabilities. The problem is that the Linux kernel has historically not cared about root -> kernel privesc, and containers expose more attack surface because of that. But an attacker outside of a container can still just enter a namespace (user namespaces are unprivileged) and perform the same exact privesc, so containers aren't making anything worse.

> As long as the container runtime is performing the various namespace isolation primitives starting from the root user these container bypasses are going to be a risk. There are 'rootless' versions of containers which can only use the privileges available to lower (presumably heavily restricted) user but those aren't widely used.

That's not how namespaces work. Even with 'rootless' containers your guest has CAP_SYS_ADMIN. The only difference is that the daemon that starts the container isn't privileged because user namespaces are increasingly becoming unprivileged. Rootless changes nothing, except that attacks against the daemon itself won't be an insta-privesc to root on the host, they'll only be a privesc to the user running the daemon on the host.

Anyway, let's step back.

What is a security boundary? I would say it is a mechanism by which an attacker is restricted where the attacker must exploit a vulnerability in order to get around that restriction. By that measure, containers are a boundary. Is exploitation difficult? Not necessarily, like I said, the Linux kernel has loads of attack surface. But it meets a reasonable criteria for a boundary.

As an example, chroot on its own is not a boundary because attackers can just call chroot again - this requires no vulnerability, it will never be patched, and you need another layer to prevent that. Containers have nothing like that, there is no "just let me out" syscall, you require another vulnerability.

You can read more about user namespaces here:

https://www.man7.org/linux/man-pages/man7/user_namespaces.7....

comment 4y ago · link · parent

This doesn't matter if the attacker is in the container. It just means that if the attacker is outside of the container they have a trivial privesc to root on the host.

comment 4y ago · link · parent

I think this is outdated. Docker is a security boundary. There is no built-in way to get out of a Docker container just by asking by default (if you mount the socket into the container, it's trivial).

How good of a boundary it is may be another story. There's some seccomp filters going on and namespacing is pretty sweet too.

But an attacker can escape by exploiting the kernel, which I think most security people would consider to be not particularly high effort.

So, suitable for internal services that you generally trust, not suitable for hostile code or highly exposed services. In an ideal world maybe we'd all use Firecracker but it's not nearly as easy to do that vs just putting something in a container.

comment 4y ago · link · parent

Maybe they mean instances? That doesn't seem too crazy.

comment 4y ago · link · parent

> Whether it's kernel/OS or a bare metal hypervisor isn't really all that meaningful: exploits and vulnerabilities exist for either.

This is just not true, or at least it's extremely disingenuous.

Container isolation relies on the Linux kernel. Other than seccomp-denied syscalls (which aren't a thing in k8s by default) any program in the container has full access to the kernel. The Linux kernel has massive attack surface, especially to root users.

VM isolation like Firecracker is much safer. The attack surface is considerably lower. For one thing, you can isolate the process in the guest just as well as you could outside, further limiting attack surface. But more importantly, an attacker either has to attack:

1. Firecracker

2. KVM

Both are very small codebases.

Firecracker is:

1. Written in Rust.

2. Sandboxed aggressively.

KVM has basically never had a public guest to host breakout. You can read about one here, https://googleprojectzero.blogspot.com/2021/06/an-epyc-escap...

So, to recap, we have "security boundary relies on a fully exposed Linux kernel" and "security boundary relies on hardened, tiny, security-driven programs".

It is not even close.

> There should be proper hardware-level isolation here, depending on the scenario. Most cloud companies can't afford that though, because they're not rolling out their own hardware.

Hence hardware building hypervisor support in.

comment 4y ago · link · parent

> Well, the body has a whole mechanism for manufacturing cholesterol, so it must be good for something.

It's good for all sorts of things, for example building cells - cell membranes are made of cholesterol, which is why our body produces a shitload of it.

comment 4y ago · link · parent

Yeah, reasonable.

comment 4y ago · link · parent

I'm oversimplifying. The interesting bits are in (2), which typically takes contextual information into account with regards to policy.

But sure, AAA is an extremely broad term that absolutely could encompass ZT. Just like SOA encompasses Microservices.

comment 4y ago · link · parent

It has nothing to do with a third party. You can do everything yourself if you'd like. Zero Trust just means:

1. Server is authenticated. Client is authenticated.

2. Client has to pass some kind of attestation / meet policy requirements of the service.

3. Actions are auditable.

What would you call it? Zero Trust seems fine to me.

comment 4y ago · link · parent

Do farmers investigate the inner workings of duck vaginas?

comment 4y ago · link · parent

It doesn't. Some other tools are worse. Great, saved you a read.

comment 4y ago · link · parent

So you were vague about where I execute the script. If I execute the script on my client, obviously you have my key, but that's not interesting. If I execute the script on my server, you do not have my private key, period.

This whole "I can ssh back to your machine past your firewall" is not a thing I understand, I am not aware of that capability in SSH.

comment 4y ago · link · parent

edit: or landlock

comment 4y ago · link · parent

Oh, I wasn't thinking of firejail, I was thinking about programs sandboxing themselves via seccomp.

comment 4y ago · link · parent

You're not on my machine. You're on the server. You still don't have my private key.

comment 4y ago · link · parent

I'm not sure I understand the attack. I connect to a server that you, the attacker, are on. How does your attack get my private key? Assuming I'm not forwarding my key, and you're not on my laptop.

comment 4y ago · link · parent

Yes, I think that ultimately the solution is to remove entropy counting entirely.

comment 4y ago · link · parent

boot the mouse first, then the os

comment 4y ago · link · parent

Local

comment 4y ago · link · parent

I see. That is a bit tricky... the entire "count the entropy" thing sounds like a pain. I guess I don't see a way around it - they link to fortuna, but I don't see how that's going to fix it. It sounds like fortuna is a better prng, so in theory if you have N outputs it's harder to get back to the seed? But the attacker is so early in the boot process...

It would help I guess.

I'll have to read up on Fortuna, at the least, as it sounds really neat.

edit: OK Fortuna is more than I expected. I have to read up.

comment 4y ago · link · parent

It doesn't, no.

comment 4y ago · link · parent

The source shouldn't be an issue even if the timestamp is reused. Timestamps just don't add a ton of entropy - a timestamp is generally 64bits, so even if it were actually random you could only ever get 64bits of entropy. And it's obviously way way way less than that since the clock is probably somewhat accurate, the computer is probably less than ~10 years old, and it's probably not way in the future.

So it should be fine to add in, but I don't know how many bits you'd want to count that as.

comment 4y ago · link · parent

Yep, that is a good idea! But a timestamp only adds a little bit of entropy, and you want a few hundred if not a few thousand bits.

comment 4y ago · link · parent

You can't reduce the entropy just by adding low entropy data to the pool. If I hand you 256bits of entropy you can hash "a" into it as many times as you like - it won't reduce the entropy.

The only thing I can think here is that the attacker would trick the system into thinking it had hit its 256bit entropy minimum before it actually had.

At which point... I don't know what they gain, but sure, it's at least a dick move.

comment 4y ago · link · parent

It seems like one of the main issues is that writes to /dev/urandom aren't counted towards the entropy count.

> Torvalds's suggestion would help much. Ted Ts'o, the other kernel RNG maintainer, cautioned that writing to /dev/urandom is not a privileged operation, so a malicious user-space program could write specific values to it; that is the reason why inputs to the device are not used "until there is a chance for it to be mixed in with other entropy which is hopefully not under the control of malicious userspace".

> "we can haphazardly mix whatever any user wants, without too much concern" as long as it is not given entropy credit.

What's the attack here? An attacker can't lower the security of a system by writing data to urandom if the data gets hashed and there's any other entropy in the system. If there isn't entropy in the system, how is it a regression?

> The Android system writes its kernel command line to /dev/urandom early in the boot process with the expectation that it will not count as entropy, "given that the command line might not contain much entropy, or any at all".

So I assume the problem here is that if you write low entropy data here and then the system counts it, the threshold to reach 256bit is lowered?

Can a crypto-person explain? Is the issue basically that an attacker would be able to make the system look like it had more entropy than it does?

comment 4y ago · link · parent

I don't think it's hard to figure out the desired interface. As you said, the hard part is changing the interface to what's desired decades later.

comment 4y ago · link · parent

Yes, seeding entropy from a server is a thing you can do. One such service is "pollinate".

I don't think that would help here.

comment 4y ago · link · parent

I think Chrome may be the single most impactful piece of software with regards to end-user security. Click to play plugins, sandboxed flash, sandboxed renderer, process isolation, auto updates, etc.

Chrome completely changed the threat landscape in just a few years.

1
515253
164