-
Notifications
You must be signed in to change notification settings - Fork 743
Firewalld open sshd port #2285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firewalld open sshd port #2285
Conversation
|
Regarding your new issue: Can we simply allow ssh in remediation script that sets the default firewall zone? shared/templates/static/bash/set_firewalld_default_zone.sh |
|
|
||
| . /usr/share/scap-security-guide/remediation_functions | ||
|
|
||
| package_command install firewalld |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it was already there, but I wonder. I thought that there is a separate rule checking if package firewalld is installed? There could be also a separate remediation that just installs the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is separate Rule for firewalld installed with its own fix, but it is not selected anywhere.
Installing the package we are configuring during remediation is the way we are dealing with dependency on package_foo_installed Rules.
Not ideal, but this works around need of XCCDF requires.
|
We should check that SSH is enabled in one of the zones but not necessarily the default zone. We should never check the |
The check comes from OVAL extend_definition elements, but the fixes comes from XCCDF, and it is picked automatically by build system by looking at Rule ID.
Evaluation of Rules occurs according to their order in the Benchmark, scanner should go from top to bottom. (Note that order of selectors in Profile doesn't affect order of evaluation of Rules, this bit me while writing test for XCCDF requires PR for OpenSCAP). The problem I see is that scanner first evaluates all Rules, then remediates all Rules.
So we should check if there is at least one NIC assigned to a zone which allows SSH. |
195ac52 to
f170ad3
Compare
|
I have changed check to verify if there is any NIC assigned to a zone which allows service SSH. |
|
@openscap-ci test this please There was error during fetch of repository: |
|
@openscap-ci test this please |
|
WRT NIC assignments: How does Anaconda open up the ports? Is it anything more than |
|
@openscap-ci test this please |
|
@shawndwells In witch context? We don't have remediation for Anaconda for firewalld. |
Which I would argue more and more that we need to have.
I would do the following:
|
|
On 9/6/17 12:22 PM, Watson Yuuma Sato wrote:
@shawndwells <https://github.com/shawndwells> In witch context? We
don't have remediation for Anaconda for firewalld.
In terms of the generic installer / default rule sets.
|
|
@yuumasato I wonder if we could create some sort of way to extend remediation scripts to follow their extended definitions so that we don't have to duplicate scripts. Might not be in this PR, but it could be beneficial to prevent script duplication as well as allow us to extend scripts easier? |
|
@redhatrises What would be the benefits of an Anaconda remediation? OAA will run the post install scan and remediation. What we will need is a bash remediation that doesn't depend on So, for the remediation of this rule I will default to adding the first ethernet interface found to the public zone. About extending remediations, that could be helpful. But I'm not sure if automatically mimicking the extends done in OVAL is a good idea. |
Not true with anaconda scripts which are supposed to be evaluated pre-install using python kickstart functionality. If the anaconda scripts are not evaluated before the system acutally installs, this is a serious bug as the kickstart and build is supposed to be modified to fix packages, services, etc. By adding the kickstart firewall command functionality to OAA, this should handle setting firewall settings, and we don't have to worry about For post-install, these remediation scripts are still needed hence what you are doing in this PR.
True. Just a thought. It does seem weird to me that any remediation script associated with |
For all Profiles, except stig-rhel7-disa, select firewalld_sshd_port_enabled Rule in Profiles that select Rule set_firewalld_default_zone.
Add OVAL definition that checks if there exists a NIC assigned to a firewalld zone with service sshd enabled.
Do not evalute to true if no config that allows sshd port exists.
Fedora is not fetching Rules from shared directory.
Decouple fix for listening port from fix of SSH enabled zone. They are not mutualy exclusive. Plus, do not add SSH service to current firewalld default zone, add it to public zone.
Add iteractively tailorable value to specify which firewalld zone will have SSH service enabled by remediation.
Be sure only port in SSH service is the one configured through Value sshd_listening_port.
Check if there is a ethernet NIC bounded to a SSH enabled zone. If not, add first ethernet NIC to the SSH enabled zone.
|
I'll add some tests for this remediation. |
Ethernet interfaces can be named with previx 'en' or 'eth'.
combine-remediations.py handle fixparts in pairs. If two function calls are put after each other, the second call of the function will not be expanded, just appended as pure text. By adding newlines we workaround this issue, the newline is the second element in the pair, and is just fine being appended.
Tested scenarios: - There is no NIC assigned to a ssh enabled zone - There is no zone with ssh service enabled - There is only one zone with ssh service enabled, and NIC is assigned to zone with ssh service disabled
274eb86 to
7262205
Compare
|
Regarding Anaconda scenario, OAA doesn't support kickstart firewall option. |
Reduce dependency of firewalld_sshd_port_enabled remediation on firewall-cmd command. Manipulate configuration files whenever possible. Also do the similar changes for configure_firewalld_ports remediation. These remediations are now suitable for chrooted and non-chrooted environments.
Add all pre-defined zones of firewalld to Value firewalld_sshd_zone. Do no allow interactive change of firewalld_sshd_zone Value.
|
This should be complete now. Summary for reviewer:
Log of SSG TestSuite: |
|
ACK. Awesome stuff. |
|
Thank you, great PR! I have one possible issue with that - in real scenarios, it's more than likely that multiple network interfaces are present on the machine, and a specific one (it might be even a bond or VPN connection, not the low-level stuff) is supposed to have Can you alter the code once again to have network interface in the value? (With possible default behaviour not touching interfaces at all?). Thanks! |
Select Rule
firewalld_sshd_port_enabledin Profiles thatExcept for
stig-rhel7-disaProfile.Add remediation for
configure_firewalld_ports, used only bystig-rhel7-disaProfile.Add OVAL definition to check if current default zone allows ssh. The check fetches current set default zone from
/etc/firewalld/firewalld.confand verifies if it allows ssh service.Issue: Above check will lead us to a situation where we will need two runs of scans and remediation.
During first scan, all zones, and current zone will allow service ssh. But then remediation will change default zone to
drop. And default zonedropis not customized to allowssh, and a second run of remediation will be needed.Question: Can we compromise on this check and always check for
/etc/firewalld/zones/drop.xml?