Bug 1540711 - selinux policy stops tor from starting if configured to host a hidden service
Summary: selinux policy stops tor from starting if configured to host a hidden service
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.4
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Lukas Vrabec
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-01-31 20:14 UTC by Billy Crook
Modified: 2018-10-30 10:02 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-30 10:02:20 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3111 None None None 2018-10-30 10:02:49 UTC

Description Billy Crook 2018-01-31 20:14:48 UTC
I'm not entirely sure which product I should file this in.  Please correct me if  am wrong.

Description of problem:
SELinux policy is blocking the tor daemon from accessing the hidden service directory specified by the user in /etc/tor/torrc.
Tor needs to be able to write to this directory once, and read from it on every startup for its 'hidden service' feature to work. aka .onion services.

Version-Release number of selected component (if applicable):
tor-0.2.9.14-1.el7.x86_64
selinux-policy-targeted-3.13.1-166.el7_4.7.noarch

How reproducible:
Consistently

Steps to Reproduce:
1. install Tor from EPEL
2. start tor (successfully)
3. stop tor
4. Add "HiddenServiceDir /var/lib/tor/hs/" to your /etc/tor/torrc
5. mkdir /var/lib/tor/hs
6. chown toranon:toranon /var/lib/tor/hs
7. chmod go-rwx /var/lib/tor/hs
8. Start tor (Watch it fail to start)

Actual results:
Tor fails to start because it is unable to fully access /var/lib/tor/hs/

Expected results:
Selinux permits tor to access /var/lib/tor/hs/, and tor starts successfully.

Additional info:
https://bugzilla.redhat.com/show_bug.cgi?id=1375369 resolved the issue in Fedora last year.  They added a new boolean that when switched on, permits tor to access the hidden services directory.

Comment 2 Milos Malik 2018-02-01 08:07:15 UTC
The reproducer triggered following SELinux denials (multiple times) in enforcing mode:
----
type=PROCTITLE msg=audit(02/01/2018 03:02:58.371:303) : proctitle=/usr/bin/tor --runasdaemon 0 --defaults-torrc /usr/share/tor/defaults-torrc -f /etc/tor/torrc --verify-config 
type=SYSCALL msg=audit(02/01/2018 03:02:58.371:303) : arch=x86_64 syscall=open success=no exit=EACCES(Permission denied) a0=0x55f566418340 a1=O_RDONLY|O_NOFOLLOW a2=0x0 a3=0x9 items=0 ppid=1 pid=8270 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=tor exe=/usr/bin/tor subj=system_u:system_r:tor_t:s0 key=(null) 
type=AVC msg=audit(02/01/2018 03:02:58.371:303) : avc:  denied  { dac_override } for  pid=8270 comm=tor capability=dac_override  scontext=system_u:system_r:tor_t:s0 tcontext=system_u:system_r:tor_t:s0 tclass=capability permissive=0 
type=AVC msg=audit(02/01/2018 03:02:58.371:303) : avc:  denied  { dac_read_search } for  pid=8270 comm=tor capability=dac_read_search  scontext=system_u:system_r:tor_t:s0 tcontext=system_u:system_r:tor_t:s0 tclass=capability permissive=0 
----

# ls -ld /var/lib/tor/hs
drwx------. 2 toranon toranon 6 Feb  1 03:02 /var/lib/tor/hs
#

Comment 6 errata-xmlrpc 2018-10-30 10:02:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3111


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