RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 723258 - SELinux "targeted" policy blocks web access to files in directories named "logs"
Summary: SELinux "targeted" policy blocks web access to files in directories named "logs"
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: selinux-policy
Version: 6.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Miroslav Grepl
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-19 14:39 UTC by Robert Vogelgesang
Modified: 2011-12-06 10:09 UTC (History)
2 users (show)

Fixed In Version: selinux-policy-3.7.19-104.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 760537 (view as bug list)
Environment:
Last Closed: 2011-12-06 10:09:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1511 0 normal SHIPPED_LIVE selinux-policy bug fix and enhancement update 2011-12-06 00:39:17 UTC

Description Robert Vogelgesang 2011-07-19 14:39:28 UTC
Description of problem:
The current SELinux "targeted" policy blocks web access to files in directories named "logs".  This is caused by the following entry in /etc/selinux/targeted/contexts/files/file_contexts:
/var/www(/.*)?/logs(/.*)?       system_u:object_r:httpd_log_t:s0

This means that access to parts of the normal web space is blocked, and this is without reason, because the default setup has the Apache log files in /var/log/httpd/, which does not match this rule.

An example of a web application that is partially crippled by this policy rule is AjaxPlorer, http://www.ajaxplorer.info/; the logs created by AjaxPlorer cannot be displayed.

Version-Release number of selected component (if applicable):
selinux-policy-targeted-3.7.19-93.el6_1.2.noarch

How reproducible:
Always

Steps to Reproduce:
1. Install Apache httpd and selinux-policy-targeted on RHEL-6.
2. Create directory /var/www/html/logs/ and some files in it.
3. Try to access the files with a web browser.
  
Actual results:
The access fails.

Expected results:
The files should be processed like any other content in /var/www/html/.

Additional info:
Workaround:
semanage fcontext -a -t  httpd_sys_content_t '/var/www/html(/.*)?/logs(/.*)?'
restorecon -r /var/www/html

Comment 2 Daniel Walsh 2011-07-19 14:53:04 UTC
Sounds fine with me.

Comment 3 Robert Vogelgesang 2011-07-19 15:09:41 UTC
Sorry, what's fine?

Do you mean that it is fine to block access to any directory in the standard web space named "logs", even if we ("we" as in "system developers") do not know what data our users put into these directories _they_ manage?

Or is my workaround fine?

Comment 4 Daniel Walsh 2011-07-19 15:15:31 UTC
Your workaround is fine,  I just added it to Fedora 16.  I am indicating to Miroslav, that I think he should add it to RHEL6.2 policy.

Comment 5 Robert Vogelgesang 2011-07-19 15:32:06 UTC
Ahh, OK, thanks.

But please consider not only /var/www/html/, but /var/www/ as a whole. We frequently mount additional disk space on various directories below of /var/www/, so I'd rather have the rule that causes this problem be removed from the policy.

A different solution would be to add a SELinux boolean that would switch this rule on or off.

Comment 6 Daniel Walsh 2011-07-19 15:40:17 UTC
Well this is actually not a boolean but of labeling.  If you label the logs directory as httpd_logs_t then cgi scripts will not be allowed to read them, if they are labelled httpd_sys_content_t then they will be allowed.

 sesearch -A -s httpd_t -t httpd_log_t -C
Found 5 semantic av rules:
   allow httpd_t file_type : filesystem getattr ; 
   allow daemon logfile : file { ioctl getattr lock append } ; 
   allow httpd_t httpd_log_t : file { ioctl read create getattr lock append open } ; 
   allow httpd_t httpd_log_t : dir { ioctl write getattr setattr lock add_name search open } ; 
   allow httpd_t httpd_log_t : lnk_file { read getattr }

sesearch -A -s httpd_sys_script_t -t httpd_log_t -C
Found 3 semantic av rules:
   allow httpd_sys_script_t logfile : file { ioctl getattr lock append } ; 
   allow httpd_sys_script_t httpd_log_t : file { ioctl getattr lock append open } ; 
   allow httpd_sys_script_t httpd_log_t : dir { getattr search open } ; 


Where as if the content is httpd_sys_content_t there is a lot different access.

Comment 7 Miroslav Grepl 2011-07-20 10:07:32 UTC
Fixed in selinux-policy-3.7.19-104.el6

Comment 10 errata-xmlrpc 2011-12-06 10:09:33 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.

http://rhn.redhat.com/errata/RHBA-2011-1511.html


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