LWN.net Logo

Security

Where are the non-root X servers?

By Jake Edge
September 8, 2010

One of the heralded features that was supposed to come with moving the graphics modesetting code into the kernel (i.e. kernel modesetting or KMS) was that it would—finally—allow systems to rid themselves of an enormous body of code running as root: the X server. KMS has made its way into distributions now, but for the most part there has been no switch to running the X server as a non-privileged user. Progress is being made, but there is another missing piece, at least for multi-user systems: some way for processes to enforce exclusive access to files they want to open.

One need only look at the recent kernel hole that was exposed by root-privileged X servers for a good reason to want an unprivileged X. It is a complicated chunk of code that is exposed to all manner of attacks, both local and, potentially, from across the network. It has been the source of vulnerabilities in the past and almost certainly will be again in the future. Reducing its privileges and possibly running it as a separate user will make any attacks against it less potent or completely ineffective—the recent exploit would have been stopped cold for example.

Prior to KMS, the X server had to do all manner of poking at the hardware to get its job done, and that required root privileges. Once that code moved into the kernel, the X server just needed to be able to access the devices provided. The graphics device driver enforces exclusive access so that other processes on the same machine cannot intercept—or interfere with—graphics commands, but there is another set of devices, /dev/input/*, that is more problematic.

In current systems, where X runs as root, it owns the files in /dev/input and the permissions only allow root to access them. If X were to run as either the logged-in user or some other separate user, overly restrictive permissions could not be used. For multi-user systems, regular users could end up with a "dangling" reference—in the form of an open file descriptor—to an input device. Once another user started X, that reference could be used for keystroke logging.

One possible solution would be to add a revoke() system call to Linux. That call would disconnect all processes from a file and allow the caller to have exclusive access. Unfortunately, no one has found an acceptable way to add revoke() capabilities to the kernel. There have been several attempts over the years (we most recently looked at one in 2007), but it is a hard problem to solve, mostly due to things like mmap()-ed files and the private copy-on-write mappings that are generated by fork().

With a working revoke(), the X server could just ensure that it is the only process that has access to the input stream. An alternative would be to have the X server run as a system user that lives in a specific group with access to the input devices, but that has flaws of its own. An exploit against the server would potentially give an attacker a means to access all users that are logged into X sessions, so a malicious local user or some remote exploit of a vulnerable X program might be able to affect all users of the system.

Keystroke logging can obviously lead to root compromise if someone types in the root password, but there are other things that users type that they don't want exposed, of course. Passwords for other systems (e.g. ssh, web applications) and all kinds of sensitive information (e.g. financial data for Gnucash or Kmoney) are input into X sessions. While it would be nice to get away from running X as root, the benefit needs to outweigh the cost—easy keystroke logging does not pass that bar.

The Moblin mobile distribution pioneered "non-root-X" and its descendant MeeGo has continued down that path, but neither of those distributions allows for multiple users. If there are no other users that could get access to the input devices, it is fairly straightforward to run the X server as the logged-in user, which is what Moblin/MeeGo do.

Ubuntu has been looking at the problem as well. There is a blueprint for the feature that is targeted for Ubuntu 10.10, but with a "Low" priority and it has not made an appearance in the recently released Beta. Unlike MeeGo, Ubuntu and other distributions will need to deal with multi-user use case, which seems to be the sticking point.

Fedora also recently discussed a non-root X server, after Mike McGrath asked about it on fedora-devel. That led to Matthew Garrett's security quote-of-the-week pointing out the problem with input devices and no revoke(). While some thought that was a good argument for PackageKit's ability to perform root-privileged actions without a password being typed in, Gregory Maxwell was quick to point out the flaw in that thinking:

This is an improvement because if Fedora removes "the need to ever type a root password" by simply allowing packagekit to give the user all the root abilities the user needs then the attacker doesn't need to wait around for the user to do something privileged, they can just ask packagekit as the user to do it for them. I'm sure this will save a lot of time.

So, at least for multi-user systems, we are still a ways out from seeing X servers running as a non-root user. The hardware access issues have been resolved—for those graphics cards that have KMS drivers—but there are still underlying plumbing issues that haven't been. For older hardware without KMS drivers, or those with proprietary-only drivers, X is always going to have to run as root.

It would be nice to limit the damage an exploit can do to only the user that got exploited, rather than the entire system or all logged-in X users. But that will require revoke() which doesn't seem to be in the pipeline. Conceptually, revoke() is a completely reasonable addition to the kernel, and it really isn't clear why we don't have it yet. It is certainly something that the security community could be working on to remove it as a barrier to a more secure X server.

Starting out by running X as a system user with various udev permission-switching rules and some kind of arbiter like ConsoleKit as Ubuntu is attempting might be the right approach. It definitely seems like Ubuntu has made the most visible progress toward the goal. Other distributions may be taking a wait-and-see approach in the interim.

Comments (29 posted)

Brief items

Security quotes of the week

Suddenly banka.com is free of fraud. Snakeoil works, they find! They happily let the Snakeoil salesman use them as a use case. So our Snakeoil salesman goes across the street to bankb.com. Bankb.com has seen a two fold increase in fraud over the last few months (all of banka.com's fraud plus their own), strangely and they're desperate to do something about it. Snakeoil salesman is happy to show them how much banka.com has decreased their fraud just by buying their shoddy product. Bankb.com is desperate so they say fine and hand over the cash.
-- Robert Hansen (aka RSnake) on the success of snake oil

The United Arab Emirates continues to wrestle with Research in Motion over government access to BlackBerry messages, threatening to ban the company's services if it doesn't severely weaken the anti-snooping protections on its smartphones. But years before the RIM battle boiled over, other Western companies handed the country a far greater power: the capability to infiltrate the secure system used by most banking, mail, and financing sites, making the most protected data on the Web available to the prying eyes of the emirates' government-connected telecommunications giant.
-- Danny O'Brien on certificate authorities in Slate

Comments (4 posted)

MWR Labs: Assessing the Tux Strength

The MWR Labs group at MWR Info Security is running a series of articles comparing Linux distributions from a security point of view. Part 1: user space memory protection looks at protection against memory corruption attacks, while Part 2 - into the kernel examines kernel security settings. "The notable exceptions in the results are Fedora and Ubuntu. Both distributions do not allow the ability to write code to a certain memory region and then execute it. This can be observed from the results of the first five tests. Fedora goes one step further and also prevents the bss, data and heap sections from being marked as executable using the 'mprotect' system call. It should be noted that there would still be numerous other memory regions where an attacker could upload their code and then use the 'mprotect' function to mark it as executable."

Comments (22 posted)

New vulnerabilities

barnowl: denial of service

Package(s):barnowl CVE #(s):CVE-2010-2725
Created:September 3, 2010 Updated:September 8, 2010
Description: From the Debian advisory:

It has been discovered that in barnowl, a curses-based instant-messaging client, the return codes of calls to the ZPending and ZReceiveNotice functions in libzephyr were not checked, allowing attackers to cause a denial of service (crash of the application), and possibly execute arbitrary code.

Alerts:
Debian DSA-2102-1 2010-09-03

Comments (none posted)

freetype: denial of service

Package(s):freetype CVE #(s):CVE-2010-3053
Created:September 8, 2010 Updated:January 20, 2011
Description: The freetype library can be forced to crash via a maliciously-crafted BDF font file.
Alerts:
MeeGo MeeGo-SA-10:31 2010-10-09
Debian DSA-2105-1 2010-09-07
SUSE SUSE-SR:2010:019 2010-10-25
openSUSE openSUSE-SU-2010:0726-1 2010-10-15
Gentoo 201201-09 2012-01-23
SUSE SUSE-SU-2012:0553-1 2012-04-23

Comments (none posted)

kernel: privilege escalation

Package(s):kernel CVE #(s):CVE-2010-3110
Created:September 8, 2010 Updated:September 8, 2010
Description: The ioctl() implementation for Novell's "novfs" /proc interface is missing several bounds checks, enabling unprivileged local users to crash the kernel or possibly execute arbitrary code in kernel mode.
Alerts:
SUSE SUSE-SA:2010:039 2010-09-08
openSUSE openSUSE-SU-2010:0592-1 2010-09-08

Comments (none posted)

Mozilla products: multiple vulnerabilities

Package(s):firefox seamonkey thunderbird xulrunner CVE #(s):CVE-2010-2760 CVE-2010-2762 CVE-2010-2764 CVE-2010-2765 CVE-2010-2766 CVE-2010-2767 CVE-2010-2768 CVE-2010-2769 CVE-2010-3166 CVE-2010-3167 CVE-2010-3168 CVE-2010-3169 CVE-2010-2763
Created:September 8, 2010 Updated:June 27, 2011
Description: Firefox 3.6.9, firefox 3.5.12, and SeaMonkey 2.0.7 have been released; they fix another long list of security issues.
Alerts:
MeeGo MeeGo-SA-10:39 2010-10-09
SUSE SUSE-SA:2010:056 2010-11-08
Debian DSA-2124-1 2010-11-01
openSUSE openSUSE-SU-2010:0906-1 2010-10-28
Fedora FEDORA-2010-15070 2010-09-22
Fedora FEDORA-2010-15070 2010-09-22
Fedora FEDORA-2010-15070 2010-09-22
Fedora FEDORA-2010-15070 2010-09-22
Fedora FEDORA-2010-15070 2010-09-22
Fedora FEDORA-2010-15070 2010-09-22
Fedora FEDORA-2010-15070 2010-09-22
openSUSE openSUSE-SU-2010:0632-2 2010-09-20
Debian DSA-2106-2 2010-09-19
Ubuntu USN-978-2 2010-09-16
Ubuntu USN-975-2 2010-09-16
openSUSE openSUSE-SU-2010:0632-1 2010-09-17
Mandriva MDVSA-2010:173 2010-09-11
CentOS CESA-2010:0682 2010-09-12
CentOS CESA-2010:0681 2010-09-12
Slackware SSA:2010-253-02 2010-09-10
Slackware SSA:2010-253-01 2010-09-10
Slackware SSA:2010-253-03 2010-09-10
Fedora FEDORA-2010-14362 2010-09-09
Fedora FEDORA-2010-14362 2010-09-09
Fedora FEDORA-2010-14362 2010-09-09
Fedora FEDORA-2010-14362 2010-09-09
Fedora FEDORA-2010-14362 2010-09-09
Fedora FEDORA-2010-14362 2010-09-09
Fedora FEDORA-2010-14362 2010-09-09
Fedora FEDORA-2010-14351 2010-09-09
Fedora FEDORA-2010-14352 2010-09-09
Fedora FEDORA-2010-14351 2010-09-09
Fedora FEDORA-2010-14352 2010-09-09
Ubuntu USN-978-1 2010-09-08
Ubuntu USN-975-1 2010-09-08
CentOS CESA-2010:0682 2010-09-09
CentOS CESA-2010:0681 2010-09-09
CentOS CESA-2010:0680 2010-09-09
CentOS CESA-2010:0680 2010-09-08
Red Hat RHSA-2010:0682-01 2010-09-07
Red Hat RHSA-2010:0680-01 2010-09-07
Debian DSA-2106-1 2010-09-08
Red Hat RHSA-2010:0681-01 2010-09-07
openSUSE openSUSE-SU-2010:0632-3 2010-10-11
SUSE SUSE-SA:2010:049 2010-10-12
Fedora FEDORA-2010-15184 2010-09-24
Fedora FEDORA-2010-15115 2010-09-23
Gentoo 201301-01 2013-01-07

Comments (none posted)

mysql: multiple vulnerabilities

Package(s):mysql-server CVE #(s):
Created:September 6, 2010 Updated:September 8, 2010
Description: From the Pardus advisory:

1) An error within the handling of DDL statements after having changed the "innodb_file_per_table" or "innodb_file_format" configuration parameters can be exploited to crash the server.

2) An error when handling joins involving a unique "SET" column can be exploited to crash the server.

3) An error when handling NULL arguments passed to "IN()" or "CASE" operations can be exploited to crash the server.

4) An error when processing certain malformed arguments passed to the "BINLOG" statement can be exploited to crash the server.

5) An error when processing "TEMPORARY" InnoDB tables featuring nullable columns can be exploited to crash the server.

6) An error when performing alternating reads from two indexes on tables using the "HANDLER" interface can be exploited to crash the server.

7) An error when handling "EXPLAIN" statements on certain queries can be exploited to crash the server.

8) An error when handling "LOAD DATA INFILE" statements can lead to the return of an "OK" packet although errors have been encountered.

Alerts:
Pardus 2010-122 2010-09-06

Comments (none posted)

quagga: denial of service

Package(s):quagga CVE #(s):CVE-2010-2948 CVE-2010-2949
Created:September 7, 2010 Updated:December 8, 2010
Description: From the Debian advisory:

When processing a crafted Route Refresh message received from a configured, authenticated BGP neighbor, Quagga may crash, leading to a denial of service. (CVE-2010-2948)

When processing certain crafted AS paths, Quagga would crash with a NULL pointer dereference, leading to a denial of service. In some configurations, such crafted AS paths could be relayed by intermediate BGP routers. (CVE-2010-2949)

Alerts:
SUSE SUSE-SU-2011:1316-1 2011-12-12
Ubuntu USN-1027-1 2010-12-07
Red Hat RHSA-2010:0945-01 2010-12-06
SUSE SUSE-SR:2010:022 2010-11-30
openSUSE openSUSE-SU-2010:0984-1 2010-11-29
Red Hat RHSA-2010:0785-01 2010-10-20
Mandriva MDVSA-2010:174 2010-09-11
Fedora FEDORA-2010-14002 2010-09-02
Fedora FEDORA-2010-14009 2010-09-02
Debian DSA-2104-1 2010-09-06
CentOS CESA-2010:0785 2010-10-25
CentOS CESA-2010:0785 2010-10-20
Gentoo 201202-02 2012-02-21
Oracle ELSA-2012-1258 2012-09-13
Oracle ELSA-2012-1259 2012-09-13

Comments (none posted)

sblim-sfcb: arbitrary code execution

Package(s):sblim-sfcb CVE #(s):CVE-2010-1937 CVE-2010-2054
Created:September 6, 2010 Updated:September 9, 2010
Description: From the Red Hat bugzilla:

Heap-based buffer overflow in httpAdapter.c in httpAdapter in SBLIM SFCB before 1.3.8 might allow remote attackers to execute arbitrary code via a Content-Length HTTP header that specifies a value too small for the amount of POST data, aka bug #3001896. (CVE-2010-1937)

Integer overflow in httpAdapter.c in httpAdapter in SBLIM SFCB 1.3.4 through 1.3.7, when the configuration sets httpMaxContentLength to a zero value, allows remote attackers to cause a denial of service (heap memory corruption) or possibly execute arbitrary code via a large integer in the Content-Length HTTP header, aka bug #3001915. NOTE: some of these details are obtained from third party information. (CVE-2010-2054)

Alerts:
Fedora FEDORA-2010-10323 2010-06-24
Fedora FEDORA-2010-12847 2010-08-17

Comments (none posted)

smbind: sql injection

Package(s):smbind CVE #(s):
Created:September 6, 2010 Updated:September 8, 2010
Description: From the Debian advisory:

It was discovered that smbind, a PHP-based tool for managing DNS zones for BIND, does not properly validating input. An unauthenticated remote attacker could execute arbitrary SQL commands or gain access to the admin account.

Alerts:
Debian DSA-2103-1 2010-09-05

Comments (none posted)

sssd: authentication bypass

Package(s):sssd CVE #(s):CVE-2010-2940
Created:September 3, 2010 Updated:January 24, 2011
Description: From the CVE entry:

The auth_send function in providers/ldap/ldap_auth.c in System Security Services Daemon (SSSD) 1.3.0, when LDAP authentication and anonymous bind are enabled, allows remote attackers to bypass the authentication requirements of pam_authenticate via an empty password.

Alerts:
Fedora FEDORA-2010-13557 2010-08-26
Fedora FEDORA-2010-13549 2010-08-26

Comments (none posted)

sudo: privilege escalation

Package(s):sudo CVE #(s):CVE-2010-2956
Created:September 7, 2010 Updated:October 27, 2010
Description: From the Gentoo advisory:

Markus Wuethrich of Swiss Post reported that sudo fails to restrict access when using Runas groups and the group (-g) command line option.

Alerts:
rPath rPSA-2010-0075-1 2010-10-27
Fedora FEDORA-2010-14996 2010-09-21
SUSE SUSE-SR:2010:017 2010-09-21
Slackware SSA:2010-258-03 2010-09-15
Slackware SSA:2010-257-02 2010-09-15
Mandriva MDVSA-2010:175 2010-09-12
CentOS CESA-2010:0675 2010-09-12
Fedora FEDORA-2010-14355 2010-09-09
openSUSE openSUSE-SU-2010:0591-1 2010-09-08
Red Hat RHSA-2010:0675-01 2010-09-07
Ubuntu USN-983-1 2010-09-07
Gentoo 201009-03 2010-09-07

Comments (none posted)

wireshark: denial of service

Package(s):wireshark CVE #(s):CVE-2010-2992 CVE-2010-2993
Created:September 3, 2010 Updated:April 19, 2011
Description: From the CVE entries:

packet-gsm_a_rr.c in the GSM A RR dissector in Wireshark 1.2.2 through 1.2.9 allows remote attackers to cause a denial of service (crash) via unknown vectors that trigger a NULL pointer dereference. (CVE-2010-2992)

The IPMI dissector in Wireshark 1.2.0 through 1.2.9 allows remote attackers to cause a denial of service (infinite loop) via unknown vectors. (CVE-2010-2993)

Alerts:
Gentoo 201110-02 2011-10-09
SUSE SUSE-SR:2011:007 2011-04-19
openSUSE openSUSE-SU-2011:0010-2 2011-01-12
SUSE SUSE-SR:2011:001 2011-01-11
SUSE SUSE-SR:2011:002 2011-01-25
openSUSE openSUSE-SU-2011:0010-1 2011-01-04
Fedora FEDORA-2010-13427 2010-08-24
Fedora FEDORA-2010-13416 2010-08-24

Comments (none posted)

Page editor: Jake Edge
Next page: Kernel development>>

Copyright © 2010, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds