qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [Bug 807893] [NEW] qemu privilege escalation
@ 2011-07-09  8:14 Andrew Griffiths
  2011-07-09  9:14 ` [Qemu-devel] [Bug 807893] " Stefan Hajnoczi
                   ` (16 more replies)
  0 siblings, 17 replies; 28+ messages in thread
From: Andrew Griffiths @ 2011-07-09  8:14 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

If qemu is started as root, with -runas, the extra groups is not dropped
correctly

/proc/`pidof qemu`/status
..
Uid:    100     100     100     100
Gid:    100     100     100     100
FDSize: 32
Groups: 0 1 2 3 4 6 10 11 26 27 
...

The fix is to add initgroups() or setgroups(1, [gid]) where appropriate
to os-posix.c.

The extra gid's allow read or write access to other files (such as /dev
etc).

Emulating the qemu code:

# python
...
>>> import os
>>> os.setgid(100)
>>> os.setuid(100)
>>> os.execve("/bin/sh", [ "/bin/sh" ], os.environ)
sh-4.1$ xxd /dev/sda | head -n2
0000000: eb48 9000 0000 0000 0000 0000 0000 0000  .H..............
0000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
sh-4.1$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 Jul  8 11:54 /dev/sda
sh-4.1$ id
uid=100(qemu00) gid=100(users) groups=100(users),0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),26(tape),27(video)

** Affects: qemu
     Importance: Undecided
         Status: New


** Tags: escalation groups privilege security

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/807893

Title:
  qemu privilege escalation

Status in QEMU:
  New

Bug description:
  If qemu is started as root, with -runas, the extra groups is not
  dropped correctly

  /proc/`pidof qemu`/status
  ..
  Uid:    100     100     100     100
  Gid:    100     100     100     100
  FDSize: 32
  Groups: 0 1 2 3 4 6 10 11 26 27 
  ...

  The fix is to add initgroups() or setgroups(1, [gid]) where
  appropriate to os-posix.c.

  The extra gid's allow read or write access to other files (such as
  /dev etc).

  Emulating the qemu code:

  # python
  ...
  >>> import os
  >>> os.setgid(100)
  >>> os.setuid(100)
  >>> os.execve("/bin/sh", [ "/bin/sh" ], os.environ)
  sh-4.1$ xxd /dev/sda | head -n2
  0000000: eb48 9000 0000 0000 0000 0000 0000 0000  .H..............
  0000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
  sh-4.1$ ls -l /dev/sda
  brw-rw---- 1 root disk 8, 0 Jul  8 11:54 /dev/sda
  sh-4.1$ id
  uid=100(qemu00) gid=100(users) groups=100(users),0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),26(tape),27(video)

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/807893/+subscriptions

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2016-08-12 15:36 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-09  8:14 [Qemu-devel] [Bug 807893] [NEW] qemu privilege escalation Andrew Griffiths
2011-07-09  9:14 ` [Qemu-devel] [Bug 807893] " Stefan Hajnoczi
2011-07-09  9:22 ` [Qemu-devel] [PATCH] os-posix: set groups properly for -runas Stefan Hajnoczi
2011-07-12 15:59   ` Stefan Hajnoczi
2011-07-12 18:10   ` [Qemu-devel] [Bug 807893] " Chris Wright
2011-07-12 19:18     ` [Qemu-devel] " Chris Wright
2011-07-12 21:44   ` Blue Swirl
2011-07-12 15:21 ` [Qemu-devel] [Bug 807893] Re: qemu privilege escalation Andrew Griffiths
2011-07-12 15:21 ` Andrew Griffiths
2011-07-12 16:43 ` Chris Wright
2011-07-12 17:39 ` Chris Wright
2011-07-13 10:00 ` Andrew Griffiths
2011-07-13 10:12 ` Andrew Griffiths
2011-07-13 10:43   ` Stefan Hajnoczi
2011-07-13 10:13 ` Andrew Griffiths
2011-07-13 10:50 ` Andrew Griffiths
2011-07-13 11:08   ` Stefan Hajnoczi
2011-07-14 10:37 ` Andrew Griffiths
2011-07-14 11:19   ` Stefan Hajnoczi
2011-07-14 11:46 ` Andrew Griffiths
2011-07-14 12:44   ` Stefan Hajnoczi
2011-07-14 12:51 ` Andrew Griffiths
2011-07-14 13:00 ` Andrew Griffiths
2011-07-14 15:59   ` Stefan Hajnoczi
2011-07-18  5:43 ` Mike Cao
2011-07-18  6:29   ` Stefan Hajnoczi
2011-07-18 10:15 ` Andrew Griffiths
2016-08-12 10:54 ` T. Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).