Skip to contentSkip to conversation

using qemu linux-user with setuid applications (C binfmt flag)

DISCUSSION Michael Tokarev 2 participants 2 messages Aug 11, 2025

lore
Share & tools
lore
#0 lore raw

Hi!

It's been quite some time since many distributions enabled the C (credentials) flag when using qemu-user binfmt_misc emulation. This means that qemu-user executable is used to run setuid binaries, usually with elevated privileges. The binary itself might be suited well for security-sensitive and probably hostile environment, but qemu-user binary is definitely not, - it is a quite complex piece of software with a lot of possible attack vectors.

To me it looks like a Very Bad Idea (tm) to enable the C flag in this case. But maybe it's not *that* bad because the administrator is the one who controls *which* setuid binaries are present on the system.

What's the qemu project view on this?

Thanks,

/mjt

#1 lore raw
Quoted 8 lines · Michael Tokarev

It's been quite some time since many distributions enabled the C (credentials) flag when using qemu-user binfmt_misc emulation. This means that qemu-user executable is used to run setuid binaries, usually with elevated privileges. The binary itself might be suited well for security-sensitive and probably hostile environment, but qemu-user binary is definitely not, - it is a quite complex piece of software with a lot of possible attack vectors.

Quoted 6 lines

To me it looks like a Very Bad Idea (tm) to enable the C flag in this case. But maybe it's not *that* bad because the administrator is the one who controls *which* setuid binaries are present on the system.

What's the qemu project view on this?

We treat all code-emulation use cases as "not security sensitive" (i.e. there might be containment-escape bugs in parts of the codebase not used in KVM VMs; we don't have the resources to audit). For linux-user, we further assume that the executing code already has the privilege of the QEMU process -- I'm pretty sure there are things you can get it to do that will make it fall over that we don't care about on that basis (notably, all of QEMU's internals are shared with the guest process, with no memory separation, so the guest can just write x86 executable code and arrange for QEMU to jump/return to it if it likes).

Whether any of those things in QEMU would be exploitable via controlling the input to a trustworthy setuid binary I have no idea (though obviously if you could get the binary to do an "arbitrary write to memory" that would be a problem in the non-emulation case too)...

-- PMM