Live data from Hacker News

Linux kernel use-after-free in Netfilter, local privilege escalation

seclists.org

81–90 of 107 posts

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#81
post #8

"We developed an exploit that allows unprivileged local users to start a root shell by abusing the above issue. That exploit was shared privately with to assist with fix development. Somebody from the Linux kernel team then emailed the proposed fix to and that email also included a link to download our description of exploitation techniques and our exploit source code. Therefore, according to the linux-distros list p…

> but the specific module in question in the patch, nf_tables, is not loaded on my Ubuntu 20.04LTS 5.40 kernel running iptables/ufw at least This doesn't matter since Linux has autoloading of most network modules, and you can cause the modules to be loaded on Ubuntu since it supports unprivileged user/net namespaces. ubuntu:~% grep DISTRIB_DESCRIPTION /etc/lsb-release DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS" ubuntu:~…

For comparison, on my Debian Bookworm (aka "testing" but in hard freeze and full freeze in a few days I think, stable release in june) here...

    ...$  lsmod|grep nf_table    (tried without any just to make sure) 
    ...$  unshare -U -m -n -r
    unshare: unshare: failed: Operation not permitted
    ...$  /sbin/nft add table inet filter
    Error: Could not process rule: Operation not permitted
    add table inet filter
    ^^^^^^^^^^^^^^^^^^^^^^

    root #  cat /proc/sys/kernel/unprivileged_userns_clone
    0

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#83
post #34

Earlier quoted context omitted.

I'm not sure if your claim here is correct. The patch is to change call sites like priv->set->use++; To look like: nf_tables_activate_set(ctx, priv->set); Where this function is defined as: void nf_tables_activate_set(const struct nft_ctx *ctx, struct nft_set *set) { if (nft_set_is_anonymous(set)) nft_clear(ctx->net, set); set->use++; } So to me (someone who is not an expert in this code) it looks like the fix is che…

One of the parts of Rust’s safety story is to always use smart pointers for reference counting rather than the type of ad-hoc manual reference count management seen in the code you quoted. Combined with lifetime checking, it makes it impossible for some random logic error to cause a use-after-free.

Correction: it is impossible in safe Rust that only ever calls safe Rust. The moment you're calling unsafe Rust, the possibility returns.

Not saying Rust isn't an improvement, it's a huge improvement over C, but there's no reason to oversell it. Rust is not going to make these errors magically go away, at least not in a kernel, even if you wrote the kernel from scratch, all in Rust. Unless you managed to write all of it in safe Rust which... good luck with that.

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#84
post #75
post #72

Earlier quoted context omitted.

Why not? It isn't clear to me why monolithic kernel wouldn't still have better performance.

It doesn't matter with layers hypervisors, virtualization, containers and sandboxes running on top. All mitigations to achieve microkernel like capabilities.

Hm, if you're making the underlying hardware slower, don't you want the kernel to be even faster though?

VMs are much more than micro kernels. It's about allowing the user to install whatever they want in their machine. Containers are just a userland abstraction. Not sure where the link to microkernels is there.

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#85
post #74

Earlier quoted context omitted.

I'm not really in the mood for trolling.

The name-calling is uncalled for. To elaborate, seL4 claims to be the fastest kernel around[0], a claim that remains unchallenged. To put it into context, the difference in IPC speed is such that you'd need an order of magnitude more IPC for a multiserver system based on seL4 to actually be slower than Linux. A multiserver design would imply increased IPC use, but not an order of magnitude. 0. https://trustworthy.sys…

Sorry I'm pretty naive to this space. I didn't immediately see any performance info on that page save for this paper [0] which shows seL4 competitive with NetBSD, but far from Linux. Is there something else I should look at?

[0]: https://trustworthy.systems/publications/full_text/Elphinsto...

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#86

Earlier quoted context omitted.

should have re-written it in rust.

Rewritten what? The container runtime will need the same access regardless of what it's written in, and rewriting all of Linux (the kernel) would be... ambitious, although it is adopting rust incrementally.

The good old Strangler Pattern.

https://martinfowler.com/bliki/StranglerFigApplication.html

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#87
post #79
post #73

Earlier quoted context omitted.

Making a PoC is a great way to convince both yourself and the maintainers that the bug is actually exploitable in the wild and thus a big fucking deal. Alternatively, you might discover that there are some other things going on which turns out to make the bug unexploitable.

Let me rephrase my question: Is there actually such a thing as an "unexploitable use-after-free"? How would that look like? How would you reason that it is actually unexploitable? Context: My experience with C programming is that practically every bug that is related to memory management tends to blow up right into your face, at the most inconvenient time possible.

> How would that look like? How would you reason that it is actually unexploitable?

For use-after-free to be exploitable, by definition an attacker must be able to put arbitrary content at the memory region. This is not always easy: may require certain [mis]configuration, data layout and so on.

> practically every bug that is related to memory management tends to blow up right into your face, at the most inconvenient time possible.

I will not contest this claim, however there is a difference between "blow up" and "exploit". Malicious packet being able to segfault a server is one thing, malicious packet resulting in RCE is quite another. This may be a lost in translation moment when under colloquial use "exploit" does not include DoS.

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#88
post #86

Earlier quoted context omitted.

Rewritten what? The container runtime will need the same access regardless of what it's written in, and rewriting all of Linux (the kernel) would be... ambitious, although it is adopting rust incrementally.

The good old Strangler Pattern. https://martinfowler.com/bliki/StranglerFigApplication.html

Some of the issue though is that a monolithic kernel provides more access than necessary to many things. When they made the locks granular, those might be reasonable boundaries for permissions? At this point I'd rather figure out how to make windows drivers work in redox or something crazy like that.

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#89

Earlier quoted context omitted.

Yes, AFAIU (not an expert), iptables and nftables are two command line tools and abstractions (chains vs. tables) for interacting with the same underlying netfilter API.

I believe at one time they were two separate subsystems, but they got merged in 4.x or 5.x

I run 6.3 and the incriminated files were not compiled in my kernel thanks to CONFIG_NF_TABLES=n during make config.

Re: Linux kernel use-after-free in Netfilter, local privilege escalation

#90
post #52

Earlier quoted context omitted.

What a dumb policy. Why have the disclosure time be so soon? This thing will be in the wild before folks can upgrade if I'm understanding this correctly.

You have a few options for dealing with problems like this. You can "apt update; apt upgrade" then reboot when a new kernel is available. Oracle has also offered Ksplice for free on Ubuntu for many years, and I'm sure that patch will be available promptly. https://ksplice.oracle.com/try/desktop Otherwise, Kernelcare is available for a fee. I think Canonical also has paid kernel patches.

There is Ubuntu Pro which is free for up to five servers/desktops, after that, it requires a paid subscription.
Post reply on HN