Bug 1210563

Summary: BUG: ip[6]tables init script does not handle the security table correctly in set_policy()
Product: Red Hat Enterprise Linux 6 Reporter: Paul Moore <pmoore>
Component: iptablesAssignee: Phil Sutter <psutter>
Status: CLOSED ERRATA QA Contact: Tomas Dolezal <todoleza>
Severity: medium Docs Contact: Ioanna Gkioka <igkioka>
Priority: medium    
Version: 6.7CC: aspurrie, atragler, igkioka, iptables-maint-list, msekara, pmoore, psutter, todoleza
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: iptables-1.4.7-17.el6 Doc Type: Bug Fix
Doc Text:
Both `iptables` and `ip6tables` services now recognize the security table in the set_policy() function Previously, when the security table was used, the `iptables` or `ip6tables` services failed to clear correctly the firewall ruleset during the shutdown. As a consequence, an error message was displayed when stopping these services. With this update, both `iptables` and `ip6tables` init scripts recognize but ignore the security table when clearing the firewall ruleset. As a result, the error message is no longer displayed in the described scenario.
Story Points: ---
Clone Of:
: 1494012 (view as bug list) Environment:
Last Closed: 2018-06-19 05:08:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1494012, 1506394    
Attachments:
Description Flags
Patch for /etc/init.d/{iptables,ip6tables}
none
Patch for /etc/init.d/{iptables,ip6tables} none

Description Paul Moore 2015-04-10 05:33:44 UTC
Created attachment 1012952 [details]
Patch for /etc/init.d/{iptables,ip6tables}

Description of problem:
When the security table is being used (e.g. secmark) the iptables and ip6tables init scripts fail in set_policy() due to not recognizing the security table.  In order to preserve the separation between the host-based firewall rules and SELinux based secmark labeling the init scripts should be made *aware* of the security table so the scripts do not fail, but the should not take any action against the security table in set_policy() .

Version-Release number of selected component (if applicable):
iptables-1.4.7-16.el6.x86_64
iptables-ipv6-1.4.7-16.el6.x86_64

How reproducible:
Every time.

Steps to Reproduce:
1. service iptables start
2. /sbin/iptables -t security -A FORWARD -p icmp -j LOG
3. service iptables stop

Actual results:
# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
# /sbin/iptables -t security -A FORWARD -p icmp -j LOG
# service iptables stop
iptables: Setting chains to policy ACCEPT: security filter [FAILED]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]

Expected results:
# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
# /sbin/iptables -t security -A FORWARD -p icmp -j LOG
# service iptables stop
iptables: Setting chains to policy ACCEPT: security filter [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]

Additional info:
The same problem applies to both the IPv4 and IPv6 init scripts.

Comment 1 Paul Moore 2015-04-10 05:36:17 UTC
Created attachment 1012954 [details]
Patch for /etc/init.d/{iptables,ip6tables}

Ooops, fix a minor typo in the patch for ip6tables.

Comment 3 Phil Sutter 2017-09-20 11:22:09 UTC
Hi Paul,

(In reply to Paul Moore from comment #0)
> Description of problem:
> When the security table is being used (e.g. secmark) the iptables and
> ip6tables init scripts fail in set_policy() due to not recognizing the
> security table.  In order to preserve the separation between the host-based
> firewall rules and SELinux based secmark labeling the init scripts should be
> made *aware* of the security table so the scripts do not fail, but the
> should not take any action against the security table in set_policy() .

I agree this is a bug in iptables.init, but I wonder about one aspect: Why should the init script ignore the security table? Assuming that a user may add custom rules to it as well, I'd handle it just like the other tables, setting policies of builtin chains to ACCEPT if iptables is stopped. What are your reasons against that?

Thanks, Phil

Comment 4 Paul Moore 2017-09-20 22:26:09 UTC
The general idea is when it comes to the SELinux iptables/netfilter rules is that they should be immune to iptables flush, and similar, commands.  The reasoning is that many sysadmins are trained to do certain things which could compromise a SELinux system using an iptables/netfilter configuration to label traffic using secmark.

Comment 17 errata-xmlrpc 2018-06-19 05:08:46 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:1859