Commit graph

3957 commits

Author SHA1 Message Date
Simon McVittie
31489e1c4f start towards 1.8.20 2015-05-14 14:30:08 +01:00
Simon McVittie
1788e8f93d 1.8.18 2015-05-14 13:28:38 +01:00
Simon McVittie
d9ab893182 Security hardening: force EXTERNAL auth in session.conf on Unix
DBUS_COOKIE_SHA1 is dependent on unguessable strings, i.e.
indirectly dependent on high-quality pseudo-random numbers
whereas EXTERNAL authentication (credentials-passing)
is mediated by the kernel and cannot be faked.

On Windows, EXTERNAL authentication is not available,
so we continue to use the hard-coded default (all
authentication mechanisms are tried).

Users of tcp: or nonce-tcp: on Unix will have to comment
this out, but they would have had to use a special
configuration anyway (to set the listening address),
and the tcp: and nonce-tcp: transports are inherently
insecure unless special steps are taken to have them
restricted to a VPN or SSH tunnelling.

Users of obscure Unix platforms (those that trigger
the warning "Socket credentials not supported on this Unix OS"
when compiling dbus-sysdeps-unix.c) might also have to
comment this out, or preferably provide a tested patch
to enable credentials-passing on that OS.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
2015-05-12 11:54:50 +01:00
Ralf Habacker
77e1b3110a reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773).
This patch is based on the fix for 'Field reader.array_len_offset is
uninitialized'

Reported by Coverity: CID 54754, 54772, 54773: Uninitialized scalar
variable (UNINIT)

[smcv: also re-order how the class is set when we recurse, so that
the sub-reader's class doesn't end up NULL]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
2015-05-08 15:54:42 +01:00
Simon McVittie
480f0182fa Revert "reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773)."
This reverts commit 21a7873f20.

This appears to cause a segfault, presumably resulting from something
assuming that reader_init() would not reinitialize all fields:

 #0  0x00007ffff7b74777 in _dbus_type_reader_get_current_type (reader=reader@entry=0x7fffffffda50) at .../dbus/dbus-marshal-recursive.c:791
 #1  0x00007ffff7b719d0 in _dbus_header_cache_check (header=<optimized out>)
    at .../dbus/dbus-marshal-header.c:209
 #2  0x00007ffff7b719d0 in _dbus_header_cache_check (header=header@entry=0x624658, field=field@entry=6) at .../dbus/dbus-marshal-header.c:250
 #3  0x00007ffff7b72884 in _dbus_header_get_field_basic (header=header@entry=0x624658, field=field@entry=6, type=type@entry=115, value=value@entry=0x7fffffffdbd8) at .../dbus/dbus-marshal-header.c:1365
 #4  0x00007ffff7b7d8c2 in dbus_message_get_destination (message=message@entry=0x624650) at .../dbus/dbus-message.c:3457
 #5  0x00007ffff7b67be6 in _dbus_connection_send_preallocated_unlocked_no_update (connection=connection@entry=0x6236d0, preallocated=0x0,
    preallocated@entry=0x6234c0, message=message@entry=0x624650, client_serial=client_serial@entry=0x7fffffffdcbc)
    at .../dbus/dbus-connection.c:2017
2015-05-08 15:36:19 +01:00
Ralf Habacker
21a7873f20 reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773).
This patch is based on the fix for 'Field reader.array_len_offset is uninitialized'

Reported by Coverity: CID 54754, 54772, 54773: Uninitialized scalar variable (UNINIT)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:11:04 +02:00
Ralf Habacker
2e96b07e94 do_check_nonce: Fix of calling _dbus_string_append_len without checking return value (CID 54720).
Reported by Coverity: CID: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:10:59 +02:00
Ralf Habacker
cc4c2d72bc dbus_message_demarshal: Fix calling _dbus_string_append_len without checking return value (CID 54690).
Reported by Coverity: CID 54690: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:10:18 +02:00
Simon McVittie
d9d130d5fa NEWS for 1.8 branch 2015-05-05 12:43:47 +01:00
Adrian Szyndela
bbef8e4038 DBusCounter: add a mutex to protect the refcount and notify function
The overall problem here is that DBusCounter is indirectly linked
to a DBusConnection, but is not actually guaranteed to be protected by
that connection's mutex; and a DBusMessage can carry a reference to the
DBusCounter, resulting in freeing that DBusMessage having an effect on
the DBusCounter.

Making the refcount atomic would not be a sufficient fix, since it would
not protect the notify function: _dbus_counter_notify() could be called
indirectly by dbus_message_unref(), in an arbitrary thread that does not
hold the DBusConnection's lock, at the same time that the holder
of the DBusConnection lock calls _dbus_transport_set_max_message_size().

[smcv: added commit message]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89297
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-05 12:30:30 +01:00
Adrian Szyndela
bebe9ca993 extend lock's range in live_messages_notify()
The other code paths that ref or unref a transport are protected by
the DBusConnection's lock. This function already used that lock,
but for a narrower scope than the refcount manipulation.

live_messages_notify() could be triggered by unreffing messages
that originated from the same connection in a different thread.

[smcv: added commit message]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90312
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-05 12:27:15 +01:00
Ralf Habacker
08e2b81062 dbus_server_set_auth_mechanisms: Fix returning without unlocking server->mutex->lock (CID 54749).
Reported by Coverity: CID 54749: Missing unlock (LOCK)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-04-28 22:57:45 +02:00
Ralf Habacker
620ca3ebe4 Add manual tcp test case.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=87999
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
(cherry picked from commit fa1ada44ea)

Conflicts:
	cmake/test/CMakeLists.txt
	test/Makefile.am
2015-04-15 12:19:57 +02:00
Ralf Habacker
c225ff8330 Fix 'dbus connection referencing issue in test-relay'.
The watches added on connection setup should be removed on shutdown.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90005
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-04-13 15:31:28 +02:00
Ralf Habacker
96e02c5dc6 Add newline to verbose output in _dbus_trace_ref().
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90004
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-04-13 15:31:17 +02:00
Ralf Habacker
b8bb0119ef Fix 'dbus-daemon on Windows: Failed to bind socket "localhost:xxxx": Address already in use'.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=87999
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
(cherry picked from commit 795ea3007e)
2015-02-09 23:08:24 +01:00
Simon McVittie
dfc53a221f 1.8.17 2015-02-05 14:54:10 +00:00
Simon McVittie
af6e170d8e Prepare embargoed 1.8.16 release 2015-02-04 16:51:10 +00:00
Simon McVittie
6dbd09fedc CVE-2015-0245: prevent forged ActivationFailure from non-root processes
Without either this rule or better checking in dbus-daemon, non-systemd
processes can make dbus-daemon think systemd failed to activate a system
service, resulting in an error reply back to the requester.

This is redundant with the fix in the C code (which I consider to be
the real solution), but is likely to be easier to backport.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88811
Reviewed-by: Alban Crequy
Reviewed-by: David King
Reviewed-by: Philip Withnall
2015-02-04 16:45:16 +00:00
Simon McVittie
3a78d91694 NEWS for 1.8 branch 2015-02-04 16:44:31 +00:00
Simon McVittie
a559ed3508 1.8.15 2015-01-05 14:57:26 +00:00
Simon McVittie
9a8bf9d810 dbus-1.8.14
-----BEGIN PGP SIGNATURE-----
 
 iQIVAwUAVKql8U3o/ypjx8yQAQjkMRAAoFSUlMmZF52fRX/LIsLmsAU6btzYgU0A
 Bj+JbpSCLBBd+Te0WDHugSol63cAbI+SWTxkdl0K/1+Bsr4MUEcMTf+6yVHArte4
 +zUs2DAPrK7LYU6U2qiVWmIn3tBS7vf6RiGiqBZu0nm+//lc5IO7M31uVbXaiT/X
 03wQ+RPV0J715wkNZTi1t+yTStRtGbuw7rTxYPtgJOa1fuOxGGh07wPFJUc/gbU3
 kq9XSAsqDmDQjh1cufbnJOB+lsxAj8AYlz7Lb8O1nM1AwyuJa3CO4bk37XqFTxk9
 q6rocequK/MeN3f3hMAQkEF4c1nq/9ibKeE+Pn1qZ+yUSPxXqjsdvlxEdbS5wx5R
 q5A1z27o5b1KitMWSlMxzgwx2BP2oM/gDU1HuEIfFztE0HjLOc+pS1cv8iTojTVT
 rzLqcNrhDCcZT9ocC/Y428y+WwYPEcjhuVB9TYo2Q42/Czexz0394Aze1lZzDtkl
 E1Fz0o0PuYMjFh7E0VGQHGfucVJMLZE/pXwYafSU47R1htErhr/3se/CYn0SfUBN
 9wkA9/E+V/7US2qdNOEfe8dx0y610Sk5y8BOW/AGIANTQjVLbQJp2lYjUnFaKgQL
 D/pYPI9viGBYr2jAmQIarPAZjljOu+F9DD3mqStn6tuxxytl4kQtNKVonJ3hxVPV
 9riJ4ce7iNM=
 =UAl+
 -----END PGP SIGNATURE-----

Merge tag 'dbus-1.8.14' into dbus-1.8

dbus-1.8.14
2015-01-05 14:56:44 +00:00
Ralf Habacker
01af167b55 Windows cmake cross compile fix
We need to include 'test' subdir in any case not only when using glib.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88009
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-01-05 11:47:13 +01:00
Ralf Habacker
2abe9ffeb7 Fix of 'dbus-daemon can only handle 64 simultaneous connections on Windows'.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71297
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-01-05 11:47:02 +01:00
Simon McVittie
abbbf449f1 Prepare release for Monday 2015-01-01 23:42:41 +00:00
Simon McVittie
eec885de3b Hardening: only accept Stats function calls at the canonical object path
These function calls are not a privilege escalation risk like
UpdateActivationEnvironment, but they might provide sensitive
information or be enhanced to provide sensitive information
in future, so the default system.conf locks them down to root-only.
Apply the same canonical-object-path hardening as for
UpdateActivationEnvironment.

We do not apply the uid check here because they are less dangerous
than UpdateActivationEnvironment, and because the ability to unlock
these function calls for specific uids is a documented configuration
for developers.

Reviewed-by: Thiago Macieira <thiago@kde.org>
[added missing #include; extended commit message -smcv]
2015-01-01 23:33:10 +00:00
Simon McVittie
4daf4bdc92 Add a regression test for path-based UpdateActivationEnvironment hardening
Reviewed-by: Thiago Macieira <thiago@kde.org>
2015-01-01 23:32:33 +00:00
Simon McVittie
a67cb9bf1c Hardening: only allow the uid of the dbus-daemon to call UpdateActivationEnvironment
As with the previous commit, this is probably not actually privilege
escalation due to the use of an activation helper that cleans up its
environment, but let's be extra-careful here.

Reviewed-by: Thiago Macieira <thiago@kde.org>
[adjusted commit message -smcv]
2015-01-01 23:32:22 +00:00
Simon McVittie
6a3f563a4b Hardening: reject UpdateActivationEnvironment on non-canonical path
UpdateActivationEnvironment is the one dbus-daemon API call that is
obviously dangerous (it is intended for the session bus),
so the default system.conf does not allow anyone to call it.

It has recently come to the D-Bus maintainers' attention that some
system services incorrectly install D-Bus policy rules that allow
arbitrary method calls to any destination as long as they have a
"safe" object path. This is not actually safe: some system services
that use low-level D-Bus bindings like libdbus, including dbus-daemon
itself, provide the same API on all object paths.

Unauthorized calls to UpdateActivationEnvironment are probably just
resource consumption rather than privilege escalation, because on
the system bus, the modified environment is only used to execute
a setuid wrapper that avoids LD_PRELOAD etc. via normal setuid
handling, and sanitizes its own environment before executing
the real service. However, it's safest to assume the worst and
treat it as a potential privilege escalation.

Accordingly, as a hardening measure to avoid privilege escalation on
systems with these faulty services, stop allowing calls to
("/com/example/Whatever",
"org.freedesktop.DBus.UpdateActivationEnvironment")
and only allow ("/org/freedesktop/DBus",
"org.freedesktop.DBus.UpdateActivationEnvironment").

We deliberately continue to provide read-only APIs like
GetConnectionUnixUser at all object paths, for backwards compatibility.

Reviewed-by: Thiago Macieira <thiago@kde.org>
[adjusted commit message to note that this is probably only DoS -smcv]
2015-01-01 23:32:16 +00:00
Илья А. Ткаченко
bf79b97f87 Fix GetExtendedTcpTable crash on vista sp0.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77008
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2014-12-23 11:02:00 +01:00
Simon McVittie
7afacaf653 1.8.13 2014-11-24 22:52:22 +00:00
Simon McVittie
4afb7a7412 1.8.12 2014-11-24 13:01:40 +00:00
Simon McVittie
02e1ddf91e Revert "config: change default auth_timeout to 5 seconds"
This reverts commit 54d26df52b.

It appears this change may cause intermittent slow or failed boot,
more commonly on slower/older machines, in at least Mageia and
possibly also Debian. This would indicate that while the system
is under load, system services are not completing authentication
within 5 seconds.

This change was not the main part of fixing CVE-2014-3639, but does
help to mitigate that attack. As such, increasing this timeout makes
the denial of service attack described by CVE-2014-3639 somewhat
more effective: a local user connecting to the system bus repeatedly
from many parallel processes can cause other users' attempts to
connect to take longer.

If your machine boots reliably with the shorter timeout, and
resilience against local denial of service attacks is important
to you, putting this in /etc/dbus-1/system-local.conf
or a file matching /etc/dbus-1/system.d/*.conf can restore
the lower limit:

    <busconfig>
      <limit name="auth_timeout">5000</limit>
    </busconfig>

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=86431
2014-11-22 10:49:21 +00:00
Simon McVittie
29c64424d1 Log to syslog when auth_timeout drops an incomplete connection
This is a symptom of either a denial of service attack, or a
serious performance problem. Either way, sysadmins should know.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=86431
2014-11-22 10:49:21 +00:00
Simon McVittie
34e5fdee4e README, HACKING: add some brief notes on reporting security vulnerabilities
We now have a private mailing list that can be the security contact.
2014-11-14 19:14:13 +00:00
Simon McVittie
312274137b NEWS 2014-11-14 18:58:44 +00:00
Jacek Bukarewicz
8ee1a7b57c Set error when message delivery is denied due to receive rule
This makes bus_context_check_security_policy follow convention of
setting errors if function indicates failure and has error parameter.
Notable implication is that AccessDenied error will be sent if sending message
to addressed recipient is denied due to receive rule. Previously, message
was silently dropped.

This also fixes assertion failure when message is denied at addressed recipient
while sending pending auto activation messages.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=86194
2014-11-14 18:40:50 +00:00
Simon McVittie
3210bda801 next version number will be 1.8.12 2014-11-10 17:09:52 +00:00
Simon McVittie
2a148cdc1b 1.8.11 2014-11-10 17:06:44 +00:00
Simon McVittie
fc50a44527 Embargoed security release for Monday 2014-11-06 15:39:51 +00:00
Simon McVittie
4e466446d2 CVE-2014-7824: set fd rlimit to 64k for the system dbus-daemon
This ensures that our rlimit is actually high enough to avoid the
denial of service described in CVE-2014-3636 part A.
CVE-2014-7824 has been allocated for this incomplete fix.

Restore the original rlimit for activated services, to avoid
them getting undesired higher limits.

(Thanks to Alban Crequy for various adjustments which have been
included in this commit.)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=85105
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
2014-11-06 15:31:07 +00:00
Simon McVittie
8874d3a0c5 1.8.9 2014-09-16 17:47:46 +01:00
Simon McVittie
28cba65785 Prepare 1.8.8 (embargoed until tomorrow) 2014-09-15 12:43:04 +01:00
Simon McVittie
ee11ec1256 _dbus_read_socket_with_unix_fds: do not accept extra fds in cmsg padding
This addresses CVE-2014-3635.

If (*n_fds * sizeof (int) % sizeof (size_t)) is nonzero,
then CMSG_SPACE (*n_fds * sizeof (int)) > CMSG_LEN (*n_fds * sizeof (int)
because the SPACE includes padding to a size_t boundary, whereas the LEN
does not. We have to allocate the SPACE. Previously, we told the kernel
that the buffer size we wanted was the SPACE, not the LEN, which meant
it was free to fill the padding with additional fds: on a 64-bit
platform with 32-bit int, that's one extra fd, if *n_fds happens
to be odd.

This meant that a malicious sender could send exactly 1 fd too many,
which would make us fail an assertion if enabled, or overrun a buffer
by 1 fd otherwise.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83622
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
2014-09-15 12:31:14 +01:00
Simon McVittie
f70c0e98c5 Add _DBUS_GNUC_UNUSED, and use it in _DBUS_STATIC_ASSERT
This means we can use _DBUS_STATIC_ASSERT at non-global scope without
tripping -Wunused-local-typedefs.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83767
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
(cherry picked from commit 0e3d08d45c)
2014-09-15 12:31:04 +01:00
Alban Crequy
e0c9d31be3 bus: enforce pending_fd_timeout
This is one of four commits needed to address CVE-2014-3637.

The bus uses _dbus_connection_set_pending_fds_function and
_dbus_connection_get_pending_fds_count to be notified when there are pending
file descriptors. A timeout per connection is armed and disarmed when the file
descriptor list is used and emptied.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-09-15 12:30:33 +01:00
Alban Crequy
8021fd8426 DBusConnection: implements _dbus_connection_set_pending_fds_function
This is one of four commits needed to address CVE-2014-3637.

This will allow the bus to be notified whenever a file descriptor is added or
removed from a DBusConnection's DBusMessageLoader.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-09-15 12:30:30 +01:00
Alban Crequy
995734750c DBusConnection: implements _dbus_connection_get_pending_fds_count
This is one of four commits needed to address CVE-2014-3637.

This will allow the bus to know whether there are pending file descriptors in a
DBusConnection's DBusMessageLoader.

https://bugs.freedesktop.org/show_bug.cgi?id=80559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[fix compilation on platforms that do not HAVE_UNIX_FD_PASSING -smcv]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-09-15 12:30:25 +01:00
Alban Crequy
bbf11cd5f9 config: add new limit: pending_fd_timeout
This is one of four commits needed to address CVE-2014-3637.

When a file descriptor is passed to dbus-daemon, the associated D-Bus message
might not be fully sent to dbus-daemon yet. Dbus-daemon keeps the file
descriptor in the DBusMessageLoader of the connection, waiting for the rest of
the message. If the client stops sending the remaining bytes, dbus-daemon will
wait forever and keep that file descriptor.

This patch adds pending_fd_timeout (milliseconds) in the configuration to
disconnect a connection after a timeout when a file descriptor was sent but not
the remaining message.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-09-15 12:29:30 +01:00
Alban Crequy
8ad179a8da Stop listening on DBusServer sockets when reaching max_incomplete_connections
This addresses the parts of CVE-2014-3639 not already addressed by
reducing the default authentication timeout.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80851
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80919
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-09-15 12:28:37 +01:00