Bug 476560 (CVE-2008-5086)

Summary: CVE-2008-5086 libvirt: missing checks for read-only connection
Product: [Other] Security Response Reporter: Tomas Hoger <thoger>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: berrange, kreilly, meyering, rjones, security-response-team, veillard
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-03-20 07:36:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 479688, 479689    
Bug Blocks:    
Attachments:
Description Flags
Upstream patch against 0.5.1 none

Description Tomas Hoger 2008-12-15 16:56:05 UTC
Daniel Berrange discovered that libvirt fails to check whether connection to libvirtd is in read-only or read-write mode, possibly allowing non-privileged users with access to the host machine to perform certain actions that should be restricted to administrative users only.

The following methods in libvirt.c are missing a check against the read-only connection flag:

    virDomainMigrate
    virDomainMigratePrepare
    virDomainMigratePerform
    virDomainMigrateFinish
    virDomainMigratePrepare2
    virDomainMigrateFinish2
    virDomainBlockPeek
    virDomainMemoryPeek
    virDomainSetAutostart
    virNetworkSetAutostart
    virConnectFindStoragePoolSources
    virStoragePoolSetAutostart

In recent versions, libvirt uses PolicyKit to authorize connections from users.  Default policy allows any local user to connect in the read-only mode.

Older versions of libvirt, or version not compiled with PolicyKit or with PolicyKit authorization disabled, default to allow read-only connections to all local users.

Thus out of the box unprivileged local users may be able to migrate  VMs, set or unset the autostart flag for domains, networks & storage pools, and access privileged data in the VM memory, or disks.

All TCP remote connections are read-write, and fully authenticated, thus not impacted.

Comment 1 Tomas Hoger 2008-12-15 16:56:55 UTC
Created attachment 326995 [details]
Upstream patch against 0.5.1

Comment 2 Tomas Hoger 2008-12-15 17:00:38 UTC
In version of libvirt as shipped in Red Hat Enterprise Linux 5, only following APIs are affected:

    virDomainSetAutostart
    virDomainMigrate*

Additionally, Xen hypervisor does not allow libvirt to set autostart flag for Xen domains.

Comment 4 Tomas Hoger 2008-12-17 17:16:08 UTC
Public now via:
  https://www.redhat.com/archives/libvir-list/2008-December/msg00522.html

Comment 5 Tomas Hoger 2008-12-18 13:38:25 UTC
As mentioned in the upstream announcement, it is possible to use a work-around to block exploitation of this flaw by changing default setting that allow read-only access to any local user.  Steps how to to that depend on what authentication is configured to be used for connections on local unix sockets.

libvirt versions built with support for PolicyKit default to PolicyKit authentication and authorization.  PolicyKit action org.libvirt.unix.monitor is used as an authorization for read-only access, and is granted to all local users by default.  By changing the policy (e.g. using polkit-gnome-authorization), you can restrict this action by default, and only grant it to selected local users (optionally requiring authentication).  Alternatively, you can disable PolicyKit authorization by setting auth_unix_ro / auth_unix_rw to none in /etc/libvirt/libvirtd.conf and following instructions below.

libvirt versions built without support for PolicyKit (e.g. as used in Red Hat Enterprise Linux 5) use socket file system permissions to control which local users can establish read-only and read-write connections.  Two separate sockets are used - libvirt-sock (read-write connections) and libvirt-sock-ro (read-only connections), located in /var/run/libvirt/.  Default permissions of those sockets on Red Hat Enterprise Linux 5 are 700 and 777 respectively, orwned by root:root.  Those default permissions can be changed by adding following configuration directives to the /etc/libvirt/libvirtd.conf configuration file.

If you only want root user to be able to make read-only connections to libvirtd, add:
  unix_sock_ro_perms = "0700"

If you want to allow read-only access to some trusted group of unprivileged users, create new unix group (e.g. virtro) containing all those users and add following to libvirtd.conf:
  unix_sock_group = "virtro"
  unix_sock_ro_perms = "0770"

You have to restart libvirtd after changing its configuration file for changes to take effect.

Comment 6 Fedora Update System 2008-12-21 08:17:57 UTC
libvirt-0.5.1-2.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 Fedora Update System 2008-12-21 08:30:36 UTC
libvirt-0.5.1-2.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 errata-xmlrpc 2009-03-19 16:10:06 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2009:0382 https://rhn.redhat.com/errata/RHSA-2009-0382.html

Comment 12 errata-xmlrpc 2011-05-05 08:44:49 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2009:0382 https://rhn.redhat.com/errata/RHSA-2009-0382.html