Bug 1928899 - Radicale SELinux policy doesn't allow hooks
Summary: Radicale SELinux policy doesn't allow hooks
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: radicale
Version: 35
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Peter Bieringer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-02-15 19:17 UTC by Georg Sauthoff
Modified: 2025-01-09 21:05 UTC (History)
3 users (show)

Fixed In Version: radicale-3.0.6-21.fc35 radicale-3.3.1-1.fc42 radicale-3.3.1-1.fc40 radicale-3.3.1-1.fc41 radicale-3.3.1-1.el9 radicale-3.3.1-1.el8 radicale-3.4.0-2.fc42
Clone Of:
Environment:
Last Closed: 2021-11-20 06:28:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Georg Sauthoff 2021-02-15 19:17:09 UTC
Description of problem:
Radicale allows to configure hooks, which is e.g. used for implementing versioning with git. The installed configuration file and the official documentation contain a git hook example.

Thus, arguably, a user is quite tempted to actually use this feature.


Version-Release number of selected component (if applicable):
python3-radicale3-3.0.6-13.fc33.noarch

How reproducible:
always

Steps to Reproduce:
1. sudo -u radicale git init /var/lib/radicale/collections
2. add to /etc/radicale/config, under `[storage]`:
hook = git add -A && (git diff --cached --quiet || git commit -m "Changes by "%(user)s)
3. journalctl -f
4. trigger some change in a cal/carddav client

Actual results:
audit[37230]: AVC avc:  denied  { setpgid } for  pid=37230
comm="radicale" scontext=system_u:system_r:radicale_t:s0
tcontext=system_u:system_r:radicale_t:s0 tclass=process permissive=0
radicale[36804]: [2021-02-15 20:02:41 +0100] [36804/Thread-24]
[ERROR] An exception occurred during PUT request on 
'/juser/dead-cafe-2323.ics': Exception occurred in preexec_fn.

And the client displays a sync error.

Expected results:
No such AVC error.


Additional info:

Comment 1 Peter Bieringer 2021-02-16 07:18:09 UTC
I have no chance to simulate this currently, can you please change to SELinux permissive mode, because potentially the displayed AVC message is not the only one.

# setenforce 0

Once SELinux permissive mode is active and external plugin execution was successful, please post

# grep radicale /var/log/audit/audit.log | audit2allow -m radicale

after review I can create a new test RPM with extended radicale.te - if not simply be enabled by setsebool (audit2allow output will show hint)

Comment 2 Georg Sauthoff 2021-07-03 20:31:17 UTC
Hm, I don't think that the audit2allow output is too useful in this case since it looks to broad.

For example, it also includes execute_no_trans:

module radicale 1.0;

require {
	type radicale_var_lib_t;
	type radicale_t;
	type radicalehook_exec_t;
	class process setpgid;
	class file { execute execute_no_trans getattr ioctl map open read };
}

#============= radicale_t ==============

#!!!! This avc can be allowed using the boolean 'domain_can_mmap_files'
allow radicale_t radicale_var_lib_t:file map;
allow radicale_t radicalehook_exec_t:file { execute execute_no_trans getattr ioctl open read };
allow radicale_t self:process setpgid;


So I moved the hook shell command to /usr/local/bin/radicale-change-hook.sh for easier testing.
And I labeled that script as radicalehook_exec_t.

Note that another hook script or command might be labeled completely different such that second last line wouldn't match.



What's perhaps more more appropriate here is to work with a domain transition for the hook.

Under this approach I'll end up with the following:


allow radicale_t self:process setpgid;

radicalehook_domtrans(radicale_t)


auth_use_nsswitch(radicalehook_t)
corecmd_exec_shell(radicalehook_t)
corecmd_exec_bin(radicalehook_t)

manage_dirs_pattern(radicalehook_t, radicale_var_lib_t, radicale_var_lib_t)
manage_files_pattern(radicalehook_t, radicale_var_lib_t, radicale_var_lib_t)
manage_lnk_files_pattern(radicalehook_t, radicale_var_lib_t, radicale_var_lib_t)

allow radicalehook_t radicale_var_lib_t:file map;


In addition to the boilerplate generated by:

sepolicy generate --application /usr/local/bin/radicale-change-hook.sh -n radicalehook

Comment 3 Ben Cotton 2021-11-04 13:51:44 UTC
This message is a reminder that Fedora 33 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 33 on 2021-11-30.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '33'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 33 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Ben Cotton 2021-11-04 14:21:10 UTC
This message is a reminder that Fedora 33 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 33 on 2021-11-30.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '33'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 33 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Ben Cotton 2021-11-04 15:18:52 UTC
This message is a reminder that Fedora 33 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 33 on 2021-11-30.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '33'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 33 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 6 Peter Bieringer 2021-11-10 21:53:46 UTC
Is it possible to add that kind of SElinux policy extension with a toogle and being off by default? Found no example so far how to manage that in custom policy extension (having e.g. a new SEbool like "radicale_hook")

Comment 7 Georg Sauthoff 2021-11-11 17:11:06 UTC
I don't have experience with adding SELinux toggles, but it sounds like it should be possible.

However, I don't know if it's worth it, though.

I mean if you choose some fixed hook script location for relabeling, then the new rules aren't effective unless somebody actively places a hook script there (and relabels it).


FWIW, my current addon policy for my git hook script is available on github:

https://github.com/gsauthof/playbook/tree/master/server/roles/radicale/files/selinux

The hook script is also available: https://github.com/gsauthof/playbook/blob/master/server/roles/radicale/files/radicale-change-hook.sh

Comment 8 Peter Bieringer 2021-11-12 06:27:25 UTC
Sounds like a generic solution is not easy to implement, can we postpone work on it until more than one run into similar issue?

Comment 9 Georg Sauthoff 2021-11-17 13:55:57 UTC
Yes, we can do that.


On the one hand, since the radicale documentation details how to write a git commit hook, people should expect that it's supported, out-of-the-box. And since Fedora has SELinux enabled, by default, it should be expected that is also works with SELinux enabled.

On the other hand, I have the feeling that 99 % of the Fedora users and developers are running Fedora with SELinux disabled, and not all radicale users are interested in commit hooks.

IOW, the intersection of Fedora users, Radicale users, users who keep SELinux enableand Radicale hook users is perhaps very small.


When you postpone, can you add a comment to the packaged `/etc/radicale/config` with a short note that the SELinux policy currently not covering hooks and a link to this bug?

Comment 10 Peter Bieringer 2021-11-20 06:26:24 UTC
Notes added to subpackage description and default config by:
https://src.fedoraproject.org/rpms/radicale/c/3f3d2ea656f0116cb35ffe0a80a89039779d02b5?branch=f35

Comment 11 Fedora Update System 2021-11-20 06:26:53 UTC
FEDORA-2021-8bfea0c937 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2021-8bfea0c937

Comment 12 Fedora Update System 2021-11-21 01:16:32 UTC
FEDORA-2021-8bfea0c937 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-8bfea0c937`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-8bfea0c937

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 13 Fedora Update System 2021-11-29 02:24:12 UTC
FEDORA-2021-8bfea0c937 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 14 Fedora Update System 2024-11-24 18:24:02 UTC
FEDORA-2024-b8ffe9d03d (radicale-3.3.1-1.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-b8ffe9d03d

Comment 15 Fedora Update System 2024-11-24 18:26:30 UTC
FEDORA-2024-b8ffe9d03d (radicale-3.3.1-1.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 16 Fedora Update System 2024-11-24 18:39:48 UTC
FEDORA-2024-54d99da1a6 (radicale-3.3.1-1.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-54d99da1a6

Comment 17 Fedora Update System 2024-11-24 19:28:28 UTC
FEDORA-2024-e60a6b12a0 (radicale-3.3.1-1.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-e60a6b12a0

Comment 18 Fedora Update System 2024-11-24 19:43:36 UTC
FEDORA-2024-5f452dbb76 (radicale-3.3.1-1.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-5f452dbb76

Comment 19 Fedora Update System 2024-11-24 20:01:17 UTC
FEDORA-EPEL-2024-70340515ea (radicale-3.3.1-1.el9) has been submitted as an update to Fedora EPEL 9.
https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2024-70340515ea

Comment 20 Fedora Update System 2024-11-24 20:11:36 UTC
FEDORA-EPEL-2024-786aa740a9 (radicale-3.3.1-1.el8) has been submitted as an update to Fedora EPEL 8.
https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2024-786aa740a9

Comment 21 Fedora Update System 2024-11-25 03:32:21 UTC
FEDORA-2024-e60a6b12a0 has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-e60a6b12a0`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-e60a6b12a0

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 22 Fedora Update System 2024-11-25 03:43:23 UTC
FEDORA-2024-54d99da1a6 has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-54d99da1a6`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-54d99da1a6

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 23 Fedora Update System 2024-11-25 04:03:36 UTC
FEDORA-EPEL-2024-786aa740a9 has been pushed to the Fedora EPEL 8 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2024-786aa740a9

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 24 Fedora Update System 2024-11-25 04:03:44 UTC
FEDORA-EPEL-2024-70340515ea has been pushed to the Fedora EPEL 9 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2024-70340515ea

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 25 Fedora Update System 2024-11-25 04:05:24 UTC
FEDORA-2024-5f452dbb76 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-5f452dbb76`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-5f452dbb76

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 26 Fedora Update System 2024-12-02 07:02:52 UTC
FEDORA-2024-e60a6b12a0 (radicale-3.3.1-1.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 27 Fedora Update System 2024-12-02 07:06:55 UTC
FEDORA-2024-54d99da1a6 (radicale-3.3.1-1.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 28 Fedora Update System 2024-12-02 07:27:49 UTC
FEDORA-EPEL-2024-70340515ea (radicale-3.3.1-1.el9) has been pushed to the Fedora EPEL 9 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 29 Fedora Update System 2024-12-02 07:30:02 UTC
FEDORA-EPEL-2024-786aa740a9 (radicale-3.3.1-1.el8) has been pushed to the Fedora EPEL 8 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 30 Fedora Update System 2025-01-09 21:02:48 UTC
FEDORA-2025-8ab77fbc65 (radicale-3.4.0-2.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-8ab77fbc65

Comment 31 Fedora Update System 2025-01-09 21:05:01 UTC
FEDORA-2025-8ab77fbc65 (radicale-3.4.0-2.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.