Upgrade to thud
[AGL/meta-agl.git] / meta-security / recipes-core / dbus-cynara / dbus-cynara / 0005-Perform-Cynara-runtime-policy-checks-by-default.patch
1 From 92a373a6dbb1c7cd7c9824167aac232f3e0daebd Mon Sep 17 00:00:00 2001
2 From: Jacek Bukarewicz <j.bukarewicz@samsung.com>
3 Date: Tue, 23 Jun 2015 11:08:48 +0200
4 Subject: [PATCH 5/5] Perform Cynara runtime policy checks by default
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This change introduces http://tizen.org/privilege/internal/dbus privilege
10 which is supposed to be available only to trusted system resources.
11 Checks for this privilege are used in place of certain allow rules to
12 make security policy more strict.
13
14 For system bus sending and receiving signals now requires
15 http://tizen.org/privilege/internal/dbus privilege. Requesting name
16 ownership and sending methods is still denied by default.
17
18 For session bus http://tizen.org/privilege/internal/dbus privilege
19 is now required for requesting name, calling methods, sending and receiving
20 signals.
21
22 Services are supposed to override these default settings to implement their
23 own security policy.
24
25 Change-Id: Ifb4a160bf6e0638404e0295a2e4fa3077efd881c
26 Signed-off-by: Jacek Bukarewicz <j.bukarewicz@samsung.com>
27
28 Cherry picked from e8610297cf7031e94eb314a2e8c11246f4405403 by Jose Bollo
29
30 Updated for dbus 1.12.10 by Scott Murray.
31
32 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
33 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
34
35 diff --git a/bus/session.conf.in b/bus/session.conf.in
36 index affa7f1..157dfb4 100644
37 --- a/bus/session.conf.in
38 +++ b/bus/session.conf.in
39 @@ -27,12 +27,32 @@
40    <standard_session_servicedirs />
41  
42    <policy context="default">
43 -    <!-- Allow everything to be sent -->
44 -    <allow send_destination="*" eavesdrop="true"/>
45 -    <!-- Allow everything to be received -->
46 -    <allow eavesdrop="true"/>
47 -    <!-- Allow anyone to own anything -->
48 -    <allow own="*"/>
49 +    <!-- By default clients require internal/dbus privilege to communicate
50 +         with D-Bus services and to claim name ownership. This is internal privilege that
51 +         is only accessible to trusted system services -->
52 +    <check own="*"                  privilege="http://tizen.org/privilege/internal/dbus" />
53 +    <check send_type="method_call"  privilege="http://tizen.org/privilege/internal/dbus" />
54 +    <check send_type="signal"       privilege="http://tizen.org/privilege/internal/dbus" />
55 +    <check receive_type="signal"    privilege="http://tizen.org/privilege/internal/dbus" />
56 +
57 +    <!-- Reply messages (method returns, errors) are allowed
58 +         by default -->
59 +    <allow send_requested_reply="true" send_type="method_return"/>
60 +    <allow send_requested_reply="true" send_type="error"/>
61 +
62 +    <!-- All messages but signals may be received by default -->
63 +    <allow receive_type="method_call"/>
64 +    <allow receive_type="method_return"/>
65 +    <allow receive_type="error"/>
66 +
67 +    <!-- Allow anyone to talk to the message bus -->
68 +    <allow send_destination="org.freedesktop.DBus"/>
69 +    <allow receive_sender="org.freedesktop.DBus"/>
70 +
71 +    <!-- But disallow some specific bus services -->
72 +    <deny send_destination="org.freedesktop.DBus"
73 +          send_interface="org.freedesktop.DBus"
74 +          send_member="UpdateActivationEnvironment"/>
75    </policy>
76  
77    <!-- Include legacy configuration location -->
78 diff --git a/bus/system.conf.in b/bus/system.conf.in
79 index f139b55..19d0c04 100644
80 --- a/bus/system.conf.in
81 +++ b/bus/system.conf.in
82 @@ -50,17 +50,20 @@
83      <deny own="*"/>
84      <deny send_type="method_call"/>
85  
86 -    <!-- Signals and reply messages (method returns, errors) are allowed
87 +    <!-- By default clients require internal/dbus privilege to send and receive signaks.
88 +         This is internal privilege that is only accessible to trusted system services -->
89 +    <check send_type="signal"       privilege="http://tizen.org/privilege/internal/dbus" />
90 +    <check receive_type="signal"    privilege="http://tizen.org/privilege/internal/dbus" />
91 +
92 +    <!-- Reply messages (method returns, errors) are allowed
93           by default -->
94 -    <allow send_type="signal"/>
95      <allow send_requested_reply="true" send_type="method_return"/>
96      <allow send_requested_reply="true" send_type="error"/>
97  
98 -    <!-- All messages may be received by default -->
99 +    <!-- All messages but signals may be received by default -->
100      <allow receive_type="method_call"/>
101      <allow receive_type="method_return"/>
102      <allow receive_type="error"/>
103 -    <allow receive_type="signal"/>
104  
105      <!-- Allow anyone to talk to the message bus -->
106      <allow send_destination="org.freedesktop.DBus"
107 @@ -69,6 +72,14 @@
108             send_interface="org.freedesktop.DBus.Introspectable"/>
109      <allow send_destination="org.freedesktop.DBus"
110             send_interface="org.freedesktop.DBus.Properties"/>
111 +    <!-- If there is a need specific bus services could be protected by Cynara as well.
112 +         However, this can lead to deadlock during the boot process when such check is made and
113 +         Cynara is not yet activated (systemd calls protected method synchronously,
114 +         dbus daemon tries to consult Cynara, Cynara waits for systemd activation).
115 +         Therefore it is advised to allow root processes to use bus services.
116 +         Currently anyone is allowed to talk to the message bus -->
117 +    <allow receive_sender="org.freedesktop.DBus"/>
118 +
119      <!-- But disallow some specific bus services -->
120      <deny send_destination="org.freedesktop.DBus"
121            send_interface="org.freedesktop.DBus"