Commit Graph

41 Commits

Author SHA1 Message Date
Alexander Larsson
905e38115c dbus-proxy: Rework to match proposed dbus filter behaviour
This reworks the dbus proxy to be more in line with the API proposed at
 https://bugs.freedesktop.org/show_bug.cgi?id=101902

In particular, it makes the filtering language more expressive. You
can now filter both calls and broadcast recieves, and filters now work
with wildcarded object paths, bus names and interfaces
(BUS_NAME_IS_SUBTREE, OBJECT_PATH_IS_SUBTREE and empty interface in
dbus API). We also more correctly track the rules for unique ids so
that filter matching work for those too (previously filters only
worked if you sent to the well known bus name, not the unique name).

In terms of implementation, things have been simplified to *only* use
Filter rules rather than tracking policies and filters separately.

Also we track all the previously known owned names for a unique id
rather than just the highest policy for it. We can then look up all
filters for it, instead of a simplified policy only check.

In terms of the CLI everything is the same, except --filter=foo has
been renamed to --call=foo, to avoid the weird conflict with the
--filter (no =..) option. We also added a similar --broadcast to
filter received broadcasts.

Closes: #1730
Approved by: alexlarsson
2018-05-29 10:23:58 +00:00
Alexander Larsson
d3d463872f dbus-proxy: Relax wildcard matching to match arg0namespace dbus behaviour
This means a rule like org.the.foo.* now also matches org.the.foo itself, and also
any sub-matches longer than one element, so for instance it now also matches
org.the.foo.bar.gazonk in addition to org.the.foo.bar which was already accepted
before.

The reason for this is that we want to be able to use the work in
 https://bugs.freedesktop.org/show_bug.cgi?id=101902
to do filter in the actual dbus daemon instead of having to use a proxy, and
we need the two to behave the same way.

This is a slight widening of the access which could technically grant
apps access to something that they did not have before. However, given
the current state of sandboxing and what is currently in use this does
not seem too problematic.

Closes: #1730
Approved by: alexlarsson
2018-05-29 10:23:58 +00:00
Alexander Larsson
6a2fe7d3e8 Revert "build: Bundle bwrap arguments when building too"
This reverts commit b0eaae2f51.
2018-05-16 16:11:55 +02:00
Alexander Larsson
b0eaae2f51 build: Bundle bwrap arguments when building too 2018-05-16 15:56:05 +02:00
Alexander Larsson
b1506e1633 dbus-proxy: Support --args=fd to specify arguments
This means we get rid of all these huge commandlines in ps

Closes: #1676
Approved by: alexlarsson
2018-05-16 09:21:51 +00:00
Alexander Larsson
52346bf187 Fix vulnerability in dbus proxy
During the authentication all client data is directly forwarded
to the dbus daemon as is, until we detect the BEGIN command after
which we start filtering the binary dbus protocol.

Unfortunately the detection of the BEGIN command in the proxy
did not exactly match the detection in the dbus daemon. A BEGIN
followed by a space or tab was considered ok in the daemon but
not by the proxy. This could be exploited to send arbitrary
dbus messages to the host, which can be used to break out of
the sandbox.

This was noticed by Gabriel Campana of The Google Security Team.

This fix makes the detection of the authentication phase end
match the dbus code. In addition we duplicate the authentication
line validation from dbus, which includes ensuring all data is
ASCII, and limiting the size of a line to 16k. In fact, we add
some extra stringent checks, disallowing ASCII control chars and
requiring that auth lines start with a capital letter.
2018-01-30 12:06:14 +01:00
Gunnar Andersson
98c21473fc Fix whitespace issues (remove TAB usage)
Signed-off-by: Gunnar Andersson <gandersson@genivi.org>

Closes: #1107
Approved by: mwleeds
2017-10-17 06:21:07 +00:00
Alexander Larsson
8a0d2d6cfa dbus-proxy: Make wildcard rules match deeply
For instance, org.my.App.* will now match org.my.App.foo.bar, and even
org.my.App, where it would previously only match org.my.App.foo.

This makes a lot of sense, because it allows you to structure the
subset of the dbus namespace you're granted how you please, and
there is no real security problem with this.

It also matches how arg0namespace works in dbus matches and how the
proposed dbus-implemented filterin works in:
https://bugs.freedesktop.org/show_bug.cgi?id=101902
2017-09-05 12:03:58 +02:00
Alexander Larsson
fa29b40fad dbus-proxy: Add sloppy-names mode
In this mode all clients get NameOwnerChanged events for all
unique names. This means you can track lifetimes of these, even if
you can't talk to them. This is useful on the a11y bus, because
we want to track when there are any listeners to a particular event,
and this is done my listing unique id:s and tracking them.
2017-09-01 15:34:40 +02:00
Alexander Larsson
ec902a08fa dbus-proxy: Add support for filtering on iface/member/path
This adds a new policy level FILTERED which is betweew SEEN
and TALK. It implies all that SEEN does, but additionally lets
you send method calls to a well known name that matches a
filter which can match against interface name, member name and
object path.

Note: To make the implementation simpler, this does not grant
similar access when sending the peer messages via the unique name,
only when using the well known name does this work.
2017-09-01 15:33:31 +02:00
Alexander Larsson
a8e2dcc1c3 dbus-proxy: Forbid old-style eavesdropping 2017-09-01 09:52:34 +02:00
Matthias Clasen
ed08538f92 Merge pull request #900 from pwithnall/lan-and-usb-preparation
LAN/USB preparation refactoring
2017-07-08 20:54:28 -04:00
Philip Withnall
81301f0ef4 general: Remove trailing \n from GLib log messages
The GLib logging framework automatically appends a \n to messages, so it
doesn’t need to be added by callers.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-07 17:18:24 +01:00
Philip Withnall
f47a696392 build: Add AM_* variables to all per-target special variables
For example, add $(AM_CFLAGS) to mumble_CFLAGS. Since $(WARN_CFLAGS) is
only added to $(AM_CFLAGS), this fixes the lack of inclusion of the
compiler warning flags in the compilation of half of flatpak.

Note that $(AM_*) variables are only used by automake if a more specific
(per-target) special variable is not defined instead. So if you define
mumble_CFLAGS, AM_CFLAGS will not be used for that target unless
explicitly included in mumble_CFLAGS.

See
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html.

Do the same for $(AM_LIBADD), $(AM_LDFLAGS), etc. These are not
currently defined, but it’s good practice to include them in
mumble_LIBADD (etc.) just in case they’re defined in future. Hopefully
their inclusions will be cargo-culted to any new targets which are
added, retaining full coverage of the code base.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 15:05:58 +01:00
Philip Withnall
548f60ebc0 general: Add missing static modifier to various local methods
The compiler warning flag which was supposed to warn about this was not
being included in the CFLAGS for these targets. That will be fixed in an
upcoming commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 14:41:21 +01:00
Simon McVittie
501399a808 dbus-proxy: Don't clear dbus_address twice
It's sufficient to g_free it, which we do further down finalize().
This is not a double-free, because we used g_clear_pointer(),
but it's redundant.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-06-30 21:17:38 +02:00
Simon McVittie
c02920f28c dbus-proxy: Make miscellaneous globals static
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-06-30 21:17:38 +02:00
Alexander Larsson
bd22ff8d42 dbus-portal: Fix return value type of filtered NameHasOwner
Fixes https://github.com/flatpak/flatpak/issues/817
2017-05-31 08:58:08 +02:00
Matthias Clasen
f15d1b78ec Remove an unused autoptr definition
This makes clang complain about an unused function.
2017-05-11 08:38:32 +02:00
Alexander Larsson
6a63a905bf dbus-proxy: Fix leak in setup phase
Sometimes we get an EAGAIN error in the due to the socket being
nonblocking. In the setup phase we just allocated the new buffer
and this causes a leak. Free it in this case.
2017-03-31 13:06:44 +02:00
Alexander Larsson
a87c15da87 dbus-proxy: Fix leak of get_arg0_string return value
In one place this was not freed. This converts both current
callers to g_autofree to make it consistent.
2017-03-31 13:06:44 +02:00
Alexander Larsson
0c05d48aca dbus: proxy fix leak in get_arg0_string
g_variant_get_child_value returns a new reference, so we have to free
it.
2017-03-31 13:06:44 +02:00
Alexander Larsson
18a45712cc dbus-proxy: Fix use-after free in header parsing
The header returned from parse_header contains references
to the buffer it was used to parse from, and in some
cases we dereference these headers after freeing the buffer.
For instance this happens when we're filtering a message, and
then we later look at the destination to figure out what
kind of error to send back.

I couldn't find any cases where this would let the client
do anything other than return a different error value, but
this is still possibly a security issue.
2017-03-31 13:06:44 +02:00
Alexander Larsson
557f9231a2 dbus-proxy: Make Buffer refcounted
This will be needed to fix some user-after-free issues.
2017-03-31 13:06:44 +02:00
Alexander Larsson
b337c95d78 dbus proxy: Tight down what is allowed to send to the bus
Make sure we can only send message calls (not e.g. unicast signals)
to the bus. Also, whitelist the list of allowed interfaces to
org.freedesktop.DBus and org.freedesktop.DBus.Introspectable

See https://github.com/flatpak/flatpak/issues/343 for the origin
discussion of this.
2016-10-17 12:19:46 +02:00
Alexander Larsson
f17390b70c Remove duplicate code 2016-10-06 12:31:54 +02:00
Christian Hergert
227da7359c dbus-proxy: alignment bit-twiddling to remove multiple and divide
Common bit-twiddling to remove the multiply and divide for realignment.
2016-09-08 14:50:15 -07:00
Matthias Clasen
75218c4a65 Fix license headers
We were referring to the nonexisting "version 2" of the
Lesser GPL. It should be "version 2.1".
2016-07-29 14:27:49 -04:00
Josh Soref
f2c22796a8 spelling: specified 2016-05-27 06:46:56 +00:00
Josh Soref
c874ea7130 spelling: incoming 2016-05-27 06:44:02 +00:00
Josh Soref
147bf4fdf0 spelling: description 2016-05-27 06:39:37 +00:00
Alexander Larsson
8abbc0186e Rename everything but the on-disk location to flatpak 2016-05-09 11:11:55 +02:00
Alexander Larsson
c24528d369 Rename source files to flatpak 2016-05-09 09:00:20 +02:00
Alexander Larsson
6a613d1fab Rename all non-autogenerated symbols to flatpak 2016-05-09 09:00:20 +02:00
Alexander Larsson
1ffdf27d92 uncruftify: Initial run, all non-problematic changes 2016-05-06 16:03:27 +02:00
Alexander Larsson
0730eb05d7 dbus-filter: Log arg0 validation failures 2016-04-19 09:44:49 +02:00
Alexander Larsson
e45d0a7d46 Fix regression is dbus proxy 2015-09-25 10:53:59 +02:00
Alexander Larsson
e5e5389bb3 dbus-proxy: Avoid clang warning 2015-08-27 16:15:35 +02:00
Alexander Larsson
53df418814 dbus-proxy: Fix incorrect check of name policy
It was checking against the wrong enum type
2015-08-27 16:14:48 +02:00
Alexander Larsson
f5aba30ade dbus-proxy: Fix flags arg passed to g_socket_receive_message
This is an out param, not an in param
2015-08-27 16:13:49 +02:00
Alexander Larsson
302f88e69d Restructure directories and build
This moves a all source code into separate subdirs per binary. The
helper and the generic stuff goes into lib/ which is then used by all
the others. For now this is a completely internal library, but at
some point we will probably clean it up and expose some subset.

Also, we move the dbus proxy to libexecdir.
2015-07-10 12:15:45 +02:00