Skip to content

Commit 49d380f

Browse files
authored
Merge pull request #138 from dev-sec/modprobe
add modprobe template, control os-10
2 parents 9fa496f + 31d7dbe commit 49d380f

File tree

9 files changed

+61
-9
lines changed

9 files changed

+61
-9
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ We remove the following packages:
7171
* rsh-server ([NSA](http://www.nsa.gov/ia/_files/os/redhat/rhel5-guide-i731.pdf), Chapter 3.2.3)
7272
* prelink ([open-scap](https://static.open-scap.org/ssg-guides/ssg-sl7-guide-ospp-rhel7-server.html#xccdf_org.ssgproject.content_rule_disable_prelink))
7373

74+
## Disabled filesystems
75+
76+
We disable the following filesystems, because they're most likely not used:
77+
78+
* "cramfs"
79+
* "freevxfs"
80+
* "jffs2"
81+
* "hfs"
82+
* "hfsplus"
83+
* "squashfs"
84+
* "udf"
85+
* "vfat"
86+
7487
## Example Playbook
7588

7689
- hosts: localhost

default.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
hosts: localhost
44
roles:
55
- ansible-os-hardening
6+
pre_tasks:
7+
- name: Run the equivalent of "apt-get update" as a separate step
8+
apt:
9+
update_cache: yes
10+
when: ansible_os_family == 'Debian'
611
vars:
712
os_security_users_allow: change_user
813
os_security_kernel_enable_core_dump: false
@@ -54,6 +59,11 @@
5459

5560
- name: wrapper playbook for kitchen testing "ansible-os-hardening"
5661
hosts: localhost
62+
pre_tasks:
63+
- name: Run the equivalent of "apt-get update" as a separate step
64+
apt:
65+
update_cache: yes
66+
when: ansible_os_family == 'Debian'
5767
roles:
5868
- ansible-os-hardening
5969

defaults/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,15 @@ sysctl_config:
182182
# Do not delete the following line or otherwise the playbook will fail
183183
# at task 'create a combined sysctl-dict if overwrites are defined'
184184
sysctl_overwrite:
185+
186+
# disable unused filesystems
187+
os_unused_filesystems:
188+
- "cramfs"
189+
- "freevxfs"
190+
- "jffs2"
191+
- "hfs"
192+
- "hfsplus"
193+
- "squashfs"
194+
- "udf"
195+
- "vfat"
196+

tasks/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
- include: minimize_access.yml
2323
tags: minimize_acces
2424

25+
- include: modprobe.yml
26+
tags: modprobe
27+
2528
- include: pam.yml
2629
tags: pam
2730

tasks/modprobe.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
---
2+
- name: install modprobe to disable filesystems | os-10
3+
package:
4+
name: '{{modprobe_package}}'
5+
state: 'installed'
6+
7+
- name: disable unused filesystems | os-10
8+
template:
9+
src: 'modprobe.j2'
10+
dest: '/etc/modprobe.d/dev-sec.conf'
11+
owner: 'root'
12+
group: 'root'
13+
mode: '0640'
214

3-
# modprobe

templates/modprobe.j2

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
install cramfs /bin/true
2-
install freevxfs /bin/true
3-
install jffs2 /bin/true
4-
install hfs /bin/true
5-
install hfsplus /bin/true
6-
install squashfs /bin/true
7-
install udf /bin/true
8-
install vfat /bin/true
1+
# {{ ansible_managed | comment }}
92

3+
{% for fs in os_unused_filesystems %}
4+
install {{fs}} /bin/true
5+
{% endfor %}

vars/Debian.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ passwdqc_path: '/usr/share/pam-configs/passwdqc'
55
tally2_path: '/usr/share/pam-configs/tally2'
66
os_nologin_shell_path: '/usr/sbin/nologin'
77

8+
modprobe_package: 'kmod'
9+
810
# Different distros use different standards for /etc/shadow perms, e.g.
911
# RHEL derivatives use root:root 0600, whereas Debian-based use root:shadow 0640.
1012
# You must provide key/value pairs for owner, group, and mode if overriding.

vars/RedHat-6.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
23
sysctl_rhel_config:
34
# ExecShield protection against buffer overflows
45
kernel.exec-shield: 1

vars/RedHat.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
3+
modprobe_package: 'module-init-tools'
4+
15
os_packages_pam_ccreds: 'pam_ccreds'
26
os_packages_pam_passwdqc: 'pam_passwdqc'
37
os_packages_pam_cracklib: 'pam_cracklib'

0 commit comments

Comments
 (0)