Skip to content
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

Introduce Fedora and Firefox CaC profiles for common workstation users #10506

Merged
merged 46 commits into from
May 10, 2023

Conversation

j-ode
Copy link
Collaborator

@j-ode j-ode commented Apr 27, 2023

Description:

  • In my bachelor's thesis, I created a new security policy for common Fedora workstation users. To implement this policy, I introduce two new Common User Security Profiles: cusp_fedora and cusp_firefox. During the implementation of the policy in CaC, many issues were encountered. Most notably, the cusp_firefox profile is a temporary measure til an issue with CaC buildsystem Cannot use firefox rules in a fedora profile with additional_content_directories #10462 about inclusion of multiple products in one profile is resolved. The goal is to only have cusp_fedora in the future that would incorporate all cusp_firefox rules.
  • I also introduce two new CaC rules, firefox_policy-content_blocker and package_gnome_software_installed, both of which are templated. The former ensures that a content blocker called uBlock Origin is installed in Firefox, while the latter ensures that the GNOME Software package is installed in Fedora.
  • The rest of the changes are just fixing prodtypes and platforms to make rules applicable to Fedora, as well as fixing issues with a Firefox OVAL template.
  • Even though many issues discovered during the implementation remain unresolved, the profiles work in the current state, and the aim is to ideally get them into the June CaC release, so that it could be presented during my thesis defense.

Rationale:

  • Currently, the Fedora profiles in CaC are largely unmaintained and not useful for common workstation users. The RHEL8/9 profiles and the standards they are based on are not practical for common users due to a variety of issues. The new profile is based on a security policy that is based on the CIS RHEL 8 - workstation level 1 benchmark, and incorporates rules from ANSSI and STIG as well. Unlike those standards however, the focus was on balancing usability with security with common users of Fedora workstation in mind.
  • The inclusion of a maintained Fedora profile in CaC would also open the door for activation of OAA in Fedora, which could lead to A) larger adoption of this profile and of CaC/OpenSCAP as a whole, and B) would enable us to test OAA in Fedora as well as in RHEL.

@j-ode j-ode requested a review from jan-cerny April 27, 2023 16:23
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Apr 27, 2023
@openshift-ci
Copy link

openshift-ci bot commented Apr 27, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@j-ode
Copy link
Collaborator Author

j-ode commented Apr 27, 2023

/test all

@github-actions
Copy link

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
New datastream adds bash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_umask_etc_login_defs'.
New datastream adds bash remediation for rule 'xccdf_org.ssgproject.content_rule_chronyd_or_ntpd_set_maxpoll'.
New datastream adds ansible remediation for rule 'xccdf_org.ssgproject.content_rule_chronyd_or_ntpd_set_maxpoll'.

@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

fedora (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Mab879
Mab879 previously requested changes Apr 27, 2023
Copy link
Member

@Mab879 Mab879 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I think will be good addition to the project. I have a couple of nitpicks on top of the CI findings.

controls/cusp_fedora.yml Outdated Show resolved Hide resolved
controls/cusp_fedora.yml Outdated Show resolved Hide resolved
@marcusburghardt marcusburghardt added the Fedora Fedora product related. label Apr 28, 2023
Copy link
Member

@ggbecker ggbecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two gating items I can already see that will need to be addressed,

  • the order in which the prodtype fedora has been put. It needs to be in the alphabetical order
  • I noticed at least one file without the new line at then end controls/cusp_firefox.yml, but there is more. If you used vscode, I suggest enabling the option to add newline at the end whenever a file is saved. You can press Ctrl+, (Control + Comma), it will open the preferences window, then type Insert Final Newline and make sure it is ticked.

@ggbecker
Copy link
Member

Two gating items I can already see that will need to be addressed,

* the order in which the `prodtype` `fedora` has been put. It needs to be in the alphabetical order

* I noticed at least one file without the new line at then end `controls/cusp_firefox.yml`, but there is more. If you used vscode, I suggest enabling the option to add newline at the end whenever a file is saved. You can press `Ctrl+,` (Control + Comma), it will open the preferences window, then type `Insert Final Newline` and make sure it is ticked.

@j-ode I remember we have this: https://github.com/ComplianceAsCode/content/blob/master/utils/autoprodtyper.py please use it.

Comment on lines 433 to 434
- sysctl_net_ipv4_ip_forward
- sysctl_net_ipv6_conf_all_forwarding
Copy link
Member

@yuumasato yuumasato Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the use of VMs a supported use case for the profiles?

Once IP forwarding is disabled in a host the guest VMs will lose access to the external world.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out, I suppose this profile should be VM-friendly as well. I looked at the two rules, and the ipv4 one has a jinja macro in the platform: https://github.com/ComplianceAsCode/content/blob/f31f13744364d29489e2a414a6a3fd43957ca3bd/shared/macros/01-general.jinja#LL972C1-L977C17 that disables the rule if rhel8 product uses oVirt. I could create a new macro that would apply the machine platform for fedora product only, but I wonder if that could have adverse effect on other potential fedora profiles that do not consider the VM usecase. What are your thoughts on such a solution @yuumasato?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may be able to use CPE applicability language here. Something like package[libvirtd] as a platform on Fedora might do it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I am finalizing the source code attachment for my thesis, I just removed the rules in question for now, but I like the idea of using the CPE applicability language

Copy link
Member

@yuumasato yuumasato May 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess making the rules for IP forwarding not applicable when an VM hypervisor is installed makes sense.

But could there be usecases that expect VMs to not have access to the external world?
I.e. I have VMS which I don't want to access the outside networks, they only need to talk to their host and other VMs in the same virtual network.
I think this is unlikely, but I don't have any data on this.

In case of oVirt and RHV4 product, we expect that VMs have access to the external world.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that libvirt is installed by default on Fedora 38 Workstation:
image
The purpose of this profile is to increase security but at the same time maintain usability, so I believe that users should be able to run VMs on their machines without connectivity problems (most users probably want networking inside their VMs). I am not sure there is a way to include these rules in the profile.

@j-ode j-ode force-pushed the fedora_common_user_profile branch from 17a0028 to ffde5ac Compare April 28, 2023 16:28
@Mab879
Copy link
Member

Mab879 commented Apr 28, 2023

Two gating items I can already see that will need to be addressed,

* the order in which the `prodtype` `fedora` has been put. It needs to be in the alphabetical order

* I noticed at least one file without the new line at then end `controls/cusp_firefox.yml`, but there is more. If you used vscode, I suggest enabling the option to add newline at the end whenever a file is saved. You can press `Ctrl+,` (Control + Comma), it will open the preferences window, then type `Insert Final Newline` and make sure it is ticked.

@j-ode I remember we have this: https://github.com/ComplianceAsCode/content/blob/master/utils/autoprodtyper.py please use it.

In this case ./utils/fix_rules.py sort_prodtypes might be more useful.

Copy link
Member

@Mab879 Mab879 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure the all descriptions are in sentence case (first letter of sentence is capitalized). The title keys should be title case.

Also, my original comments from my first review still stand, it seems that one of the rebases must have gotten rid of your changes.

Comment on lines 433 to 434
- sysctl_net_ipv4_ip_forward
- sysctl_net_ipv6_conf_all_forwarding
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may be able to use CPE applicability language here. Something like package[libvirtd] as a platform on Fedora might do it.

title: Disk partitioning
description: >-
Users should put the /home, /tmp, /var, /var/tmp and /var/log directories on separate partitions.
status: manual
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rules from linux_os/guide/system/software/disk_partitioning might be useful here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the issue is that the respective Anaconda remediations block the installation when the disk is not correctly partitioned which is not ideal, I talk about this in the thesis and created an issue in OAA OpenSCAP/oscap-anaconda-addon#236

@j-ode j-ode force-pushed the fedora_common_user_profile branch from ffde5ac to aed07b4 Compare May 3, 2023 13:55
@j-ode j-ode force-pushed the fedora_common_user_profile branch from 600ba48 to 9518bf2 Compare May 3, 2023 16:42
@j-ode
Copy link
Collaborator Author

j-ode commented May 6, 2023

The Automatus CS8/CS9 CI fails are expected, as package_gnome_software_installed is a fedora-only rule and therefore cannot be present in the RHEL8/9 benchmarks as the errors suggest

@jan-cerny jan-cerny marked this pull request as ready for review May 9, 2023 09:35
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label May 9, 2023
@jan-cerny jan-cerny added this to the 0.1.68 milestone May 9, 2023
@jan-cerny jan-cerny added Update Profile Issues or pull requests related to Profiles updates. Highlight This PR/Issue should make it to the featured changelog. labels May 9, 2023
j-ode added 3 commits May 9, 2023 14:33
Source of the controls file will be my thesis on the Fedora Common User Profile, source will be added later
@j-ode j-ode force-pushed the fedora_common_user_profile branch from 9518bf2 to 4bd2e87 Compare May 9, 2023 12:44
@codeclimate
Copy link

codeclimate bot commented May 9, 2023

Code Climate has analyzed commit 4bd2e87 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 52.4% (0.0% change).

View more on Code Climate.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fail in centos8 testing farm job is related to rule rsyslog_files_permissions and will be fixed by #10540, therefore it isn't related to the contents of this PR.

@jan-cerny jan-cerny dismissed stale reviews from ggbecker and Mab879 May 10, 2023 11:26

feedback has been addressed

@jan-cerny jan-cerny merged commit 8b2c5b9 into ComplianceAsCode:master May 10, 2023
@Mab879 Mab879 added New Profile Issues or pull requests related to new Profiles. and removed Update Profile Issues or pull requests related to Profiles updates. labels May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fedora Fedora product related. Highlight This PR/Issue should make it to the featured changelog. New Profile Issues or pull requests related to new Profiles.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants