Commit graph

187 commits

Author SHA1 Message Date
DonEstefan
16e00b02db
rewrite user home dir hardening (#584)
* rewrite user home dir hardening

* delete duplicate var that was missed in a merge conflict

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* linting

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add tests for home rewrites

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* Apply suggestions from code review

Co-authored-by: schurzi <github@drachen-server.de>

---------

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Co-authored-by: donestefan <donestefan@users.noreply.github.com>
Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
Co-authored-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Co-authored-by: schurzi <github@drachen-server.de>
2023-01-28 21:59:19 +01:00
Sebastian Gumprich
a75b339526 fix more linting errors
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2023-01-27 11:27:35 +01:00
Sebastian Gumprich
89138be4ec
Rewrite system account detection and hardening and create tests (#621)
* rewrite system account detection and hardening

* resolve failures created when resolving merge conflicts

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add tests for shell removal tasks

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* Update molecule/os_hardening/prepare.yml

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* split tasks for locking and setting shell

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* fix some more linting

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Co-authored-by: donestefan <donestefan@users.noreply.github.com>
Co-authored-by: schurzi <Martin.Schurz@t-systems.com>
2023-01-27 11:01:03 +01:00
schurzi
ee80418496
Merge pull request #618 from dev-sec/deprecate_intitramfs
deprecate rebuilding of initramfs
2023-01-25 23:56:36 +01:00
Martin Schurz
7f8e9919ee add readme
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2023-01-25 22:30:17 +01:00
Sebastian Gumprich
a1028c7504 deprecate initramfs
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2023-01-25 13:07:37 +01:00
Sebastian Gumprich
bb588bd777
linting (#603)
* linting

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* more linting

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* change line length issues

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* replace yes with true in tasks

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* use manual line-wrapping because ansible-lint does not support it correctly.

see https://github.com/ansible/ansible-lint/issues/2522

* use manual line-wrapping because ansible-lint does not support it correctly.

see https://github.com/ansible/ansible-lint/issues/2522

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* use manual line-wrapping because ansible-lint does not support it correctly.

see https://github.com/ansible/ansible-lint/issues/2522

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add exception for task

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* remove trailing whitespace

* add back deleted params

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add back deleted params

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add back tasks

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2023-01-24 12:40:27 +01:00
DonEstefan
674be6dc6f
apply password age settings to exisiting regular users (#582)
* apply password age settings to regular users

* add tests for password ageing

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add debugging vars

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add tests for password ageing

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add tests for password ageing

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* Apply suggestions from code review

Co-authored-by: schurzi <github@drachen-server.de>

* add additional condtion for regular users

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Co-authored-by: DonEstefan <donestefan@users.noreply.github.com>
Co-authored-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
Co-authored-by: schurzi <github@drachen-server.de>
2023-01-23 10:50:05 +01:00
stdtom
9d2c68ef2f
Preserve default ownership and dir mode for /var/log on Ubuntu (#615)
* Preserve default ownership and dir mode for /var/log on Ubuntu

Signed-off-by: stdtom <stdtom@gmx.net>

* linting

Signed-off-by: stdtom <stdtom@gmx.net>

* Define vars for each OS instead of using defaults.

Signed-off-by: stdtom <stdtom@gmx.net>

* Fix values for os_mnt_var_log_dir_mode and os_mnt_var_log_group

Signed-off-by: stdtom <stdtom@gmx.net>

Signed-off-by: stdtom <stdtom@gmx.net>
2023-01-23 09:34:41 +01:00
rndmh3ro
b3fbfcedbe Prettified Code! 2023-01-19 12:45:51 +00:00
Paweł Krawczyk
88ef3cf3af
Parametrize more auditd.conf options (#535)
* Parametrize more auditd.conf options

* Parametrize more auditd.conf options

* Add `os_auditd` options

* Add os_auditd_log_group

* Add os_auditd_log_group

Co-authored-by: Paweł Krawczyk <p@krvtz.net>
Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
2023-01-19 13:45:24 +01:00
richardlock
a82942a63a
Add support for /etc/auditd.conf num_logs to go with max_log_file_action. (#617)
Signed-off-by: Richard Lock <r.j.lock@derby.ac.uk>

Signed-off-by: Richard Lock <r.j.lock@derby.ac.uk>
2023-01-12 12:52:48 +01:00
DonEstefan
bb3c63e321
fix IPv6 hardening (#607)
Signed-off-by: DonEstefan <donestefan@users.noreply.github.com>

Signed-off-by: DonEstefan <donestefan@users.noreply.github.com>
Co-authored-by: donestefan <donestefan@users.noreply.github.com>
2022-11-30 16:13:25 +01:00
Jacob Sievert
ade6deeba2
Updates handlers for new ansible syntax and deprecated options for legacy commands (#602)
* Update main.yml

fixes the handler file and set new syntax

Signed-off-by: Jacob Sievert <jacob.sievert@sievert-mail.de>

* changes command module from legacy to builtin.

Signed-off-by: Jacob Sievert <jacob.sievert@sievert-mail.de>

Signed-off-by: Jacob Sievert <jacob.sievert@sievert-mail.de>
2022-11-24 08:39:05 +01:00
Diego Louzán
f8295d5248 fix(os_hardening): cast expected int types in pam tasks
Signed-off-by: Diego Louzán <diego.louzan@gmail.com>
2022-10-27 16:50:08 +02:00
Sebastian Gumprich
dac66f4a88 simplify OS-vars files
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2022-10-25 18:59:11 +02:00
schurzi
a1b80fe657
adopt all current suggestions from ansible-lint (#592) 2022-10-24 09:42:23 +02:00
donestefan
464d8df8e8
add hardening of root user account(s) (#579) 2022-10-21 11:05:43 +02:00
Sebastian Gumprich
9ac01fb358
add always-tag to include so other tags can be used (#569)
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2022-08-26 13:45:05 +02:00
Sebastian Gumprich
11d187e62e
update supported OS in meta and fix linting (#572)
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2022-08-26 13:44:51 +02:00
donestefan
38e1c3bbeb
fix misleading comment (#571)
also RHEL6 is not supported anymore
2022-08-26 09:17:54 +02:00
divialth
fb8b9142c8
rework filesystem hardening (#555)
* rework filesystem hardening

-  removed a lot duplicated code by using a loop
-  added new hardening options for /tmp
-  added new options "passno" and "dump" for every filesystem.
   currently ansible changed that values to 0 for every fs
   new default depends on fstype, can be overwriten in config
-  removed default fstype in config
   the type will now be autodetected,  can be overwriten in config
-  mount src setting is now optional
   the source will now be autodetected,  can be overwriten in config
-  it will be now checked, if it is really a mount
-  changed fs reload to handler
-  removed check os_auditd_enabled on /var/log/audit

Signed-off-by: divialth <65872926+divialth@users.noreply.github.com>

* fix lint errors

Signed-off-by: divialth <65872926+divialth@users.noreply.github.com>

* implemented the name suggestions

Signed-off-by: divialth <65872926+divialth@users.noreply.github.com>

Signed-off-by: divialth <65872926+divialth@users.noreply.github.com>
2022-08-22 11:16:57 +02:00
PhilippFunk
fd3fc1cfba
add option to bypass .netrc check function (#563)
add option to whitelist specific user that need a .netrc file in there home dirs
add test for .netrc files if option os_netrc_enabled is false

Signed-off-by: Philipp Funk <philipp.funk@t-systems.com>

Signed-off-by: Philipp Funk <philipp.funk@t-systems.com>
Co-authored-by: Philipp Funk <philipp.funk@t-systems.com>
2022-08-17 09:09:00 +02:00
Daya Adianto
eef8708918
Add full support for Debian 11 (#538)
* Include Debian 11 into Molecule test suites (#527)

Signed-off-by: Daya Adianto <dayaadianto@cs.ui.ac.id>

* Fix Ansible Lint GitHub Action version (#527)

Signed-off-by: Daya Adianto <dayaadianto@cs.ui.ac.id>

* Update .gitignore

Signed-off-by: Daya Adianto <dayaadianto@cs.ui.ac.id>

* mysql_hardening: Use Python 3 as Ansible interpreter (#527)

Signed-off-by: Daya Adianto <dayaadianto@cs.ui.ac.id>

* Note Debian 11 support for os_hardening & nginx_hardening (#527)

Signed-off-by: Daya Adianto <dayaadianto@cs.ui.ac.id>

* Fix lint issues & Ansible Lint configuration in CI

Signed-off-by: Daya Adianto <dayaadianto@cs.ui.ac.id>

* Try to fix YAML lint issues, again

Re-ordered YAML comments at the end of `.yamllint` file.

Signed-off-by: Daya Adianto <dayaadianto@cs.ui.ac.id>

* rm debian9 from tests, add debian 11 where missing

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* fix mysql molecule tests

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

Signed-off-by: Daya Adianto <dayaadianto@cs.ui.ac.id>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
Co-authored-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2022-08-16 15:02:27 +02:00
Benedikt Böhm
2265497e75
Fix broken mode for /var/log/audit (#552)
```
Unable to open /var/log/audit/audit.log (Permission denied)
```

This PR fixes the issue by using the default permission set by auditd (`0700`).

Signed-off-by: Benedikt Böhm <bb@xnull.de>
2022-07-26 15:57:39 +02:00
David James
8c82af9c98
Only run hardening if /var/log/audit exists (#550)
* Only run harding if /var/log/audit exists

Signed-off-by: GitHub <noreply@github.com>

* Update roles/os_hardening/tasks/minimize_access.yml

* add more conditionals to when auditd show be hardened

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* add more tests to the os-hardening vm tests

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

* Revert "add more tests to the os-hardening vm tests"

This reverts commit c05fe8b520.

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>

Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
Co-authored-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2022-07-15 11:41:01 +02:00
Martin Schurz
edda7075a2 add badge for tests
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2022-07-11 12:17:34 +02:00
Martin Schurz
0f631c1405 add sysctl exclude
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2022-07-11 09:39:52 +02:00
Martin Schurz
5d50b5b130 add sysctl exclude
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2022-07-11 09:32:02 +02:00
Martin Schurz
28baf0d581 add sysctl exclude
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2022-07-11 09:17:44 +02:00
Martin Schurz
4b519e8b13 add sysctl exclude
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2022-07-11 09:13:26 +02:00
Martin Schurz
92dc094022 add sysctl exclude
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2022-07-11 09:05:58 +02:00
Martin Schurz
cd45a58683 fix yum gpg-check task
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2022-07-10 20:22:39 +02:00
Martin Schurz
fa7f8597d9 fix bug in check for /boot
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2022-07-10 13:36:19 +02:00
Sebastian Gumprich
73f84ae2a9 fix wrong indentation
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2022-07-08 16:04:37 +02:00
Sebastian Gumprich
9b50392d8a fix linting
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2022-07-07 16:12:06 +02:00
rndmh3ro
e28e09cd0e Prettified Code! 2022-07-07 07:02:50 +00:00
balu
488ff6a7c3
Harden mountpoints (#531)
* first testing with tasks and variables

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* update variables for dir options

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* updated permissions and defaults

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* fix home dir permissions

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* updated tasks with useful variables

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* reorder tasks. first remount, then manage fstab and fix permissions on directories. Renaming task names with mountpoints (slashes)

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* shorten tasks with list items

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* change defaults for /boot directory, because its a bad behaviour, if ansible changes boot entries with a default value

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* Update documentation for new parameters to manage mountpoints

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* Update roles/os_hardening/tasks/minimize_access.yml

Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* Update roles/os_hardening/tasks/minimize_access.yml

Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* Fix state on every new task

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* loop instead of list

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* testing remount with register

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* add remounts with loop over all changed folders

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* testing and solving trouble with variable names

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* optimize default permissions for var-log-audit

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* optimize default permissions for var-log-audit

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* change to new optimizied permissions of var-log-audit

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* fix some defaults in fstab to configure as mounted

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* add stat and check, if boot folder exists

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

Co-authored-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>
Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
2022-07-07 09:02:25 +02:00
Sebastian Gumprich
3f50b6e94b update os-hardening readme with os_ignore_users
fixes #542

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2022-05-30 13:29:45 +02:00
abejotaR
8edd650135
change permissions of the tmout.sh file (#520)
Co-authored-by: Abraham Rebori <abraham.rebori@nexa.com.uy>
2022-02-21 14:01:19 +01:00
Sebastian Gumprich
2ba40b0891
move sysctls to debian specific vars (#524)
* fix ansible-lint issue

https://github.com/ansible-community/ansible-lint/issues/1795
Signed-off-by: rndmh3ro <github@gumpri.ch>

* move 2 sysctls to debian specific

Signed-off-by: rndmh3ro <github@gumpri.ch>

* fix ansible-lint issue

https://github.com/ansible-community/ansible-lint/issues/1795
Signed-off-by: rndmh3ro <github@gumpri.ch>

* add arch linux sysctls

* simplify sysctl settings

Signed-off-by: rndmh3ro <github@gumpri.ch>

* ove overwrite to the bottom to let it acutally overwrite something

Signed-off-by: rndmh3ro <github@gumpri.ch>

* fix typo

Signed-off-by: rndmh3ro <github@gumpri.ch>
2022-02-18 15:30:32 +01:00
lbayerlein
1a97c6cf87
new feautre tmout in a new pr (#516)
Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

Co-authored-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>
2021-12-16 11:39:24 +01:00
Sebastian Gumprich
8f22ce788c
Feature coredump (#513)
* restructure limits-tasks

* disable coredumps in tests

* use notify-task for systemd-reload

Signed-off-by: rndmh3ro <github@gumpri.ch>

* add notify to another task

Signed-off-by: rndmh3ro <github@gumpri.ch>

* rm obsolete task and rename handler

Signed-off-by: rndmh3ro <github@gumpri.ch>
2021-12-10 22:10:14 +01:00
lbayerlein
bb8e3e375e
add feature to disable coredump to limit task (#511)
Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

Co-authored-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>
2021-12-08 14:25:49 +01:00
alegrey91
8805d9c14a fix: change hidepid mount task state to mounted 2021-11-29 22:37:21 +01:00
tekicat
88893a5d4a
Fix duplicate sysctl config (#505)
Signed-off-by: tekicat <tekicat@amibee.com>
Signed-off-by: gk <ganesh.jayachandran@revolut.com>
Signed-off-by: Tekicat <tekicat@amibee.com>
2021-11-26 11:30:50 +01:00
René Scheibe
bbe4ce16a1
Add whitelist option for yum repository files (#487)
Files in this whitelist should not be altered.

Currently this is only relevant for enforcing the gpg check.

Signed-off-by: René Scheibe <rene.scheibe@gmail.com>
2021-11-07 11:56:59 +01:00
lbayerlein
1bf31a197b
disable ctrl-alt-del key combination (#496)
* new function to disable ctrl-alt-del to avooid reboot virtual machines f.e.

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* fix variable documentation for ctrlaltdel

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* added ctrlaltdel variable for molecule

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* optimize ctrlaltdel function with a 'when' query. thanks to rndmh3ro

Signed-off-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>

* fix typo in new file

Co-authored-by: Ludwig Bayerlein <bayerlein@bayerlein-networks.com>
Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
2021-10-28 10:31:58 +02:00
schurzi
08b0fd14f4
Merge pull request #494 from dev-sec/sysctl-34
implement sysctl-34 - link protection settings
2021-10-24 11:21:14 +02:00
schurzi
ff37289879
Merge pull request #493 from dev-sec/rndmh3ro-patch-1
update minimum ansible version for roles
2021-10-24 11:09:37 +02:00
Sebastian Gumprich
9f372c285c
Update roles/os_hardening/defaults/main.yml
Co-authored-by: schurzi <Martin.Schurz@t-systems.com>
2021-10-24 10:59:49 +02:00
Claudius Heine
384c097f8a
feat(os_hardening): extend file permission tasks to cover more files (#489)
The tasks `Change shadow ownership to root and mode to 0600` and `Change
passwd ownership to root and mode to 0644` only handle
`/etc/shadow` and `/etc/passwd` respectively. But there multiple
adjacent files that should be handled with these rules as well:

- `/etc/gshadow`
- `/etc/shadow-`
- `/etc/gshadow-`
- `/etc/group`
- `/etc/shadow-`
- `/etc/group-`

This change adds those files to the rules, so that permissions are
handled in the same way.

Closes: #488

Signed-off-by: Claudius Heine <ch@denx.de>
2021-10-21 09:51:20 +02:00
rndmh3ro
346b064682 implement sysctl-34 - link protection settings
Signed-off-by: rndmh3ro <github@gumpri.ch>
2021-10-20 20:59:49 +02:00
Sebastian Gumprich
be0d501bc8 update minimum ansible version for roles
fixes #407

Signed-off-by: rndmh3ro <github@gumpri.ch>
2021-10-20 20:42:05 +02:00
rndmh3ro
cf17f80374 skip linting on special task
Signed-off-by: rndmh3ro <github@gumpri.ch>
2021-08-15 20:16:56 +02:00
Paweł Krawczyk
66bd1f0aec
Add CVE-2021-33909 mitigations (#466)
* Add CVE-2021-33909 mitigations

kernel.unprivileged_bpf_disabled: 1
kernel.unprivileged_userns_clone: 0

The first one is also used by Tails.

Signed-off-by: Paweł Krawczyk <616047+kravietz@users.noreply.github.com>

* Clean up whitespaces

Signed-off-by: Paweł Krawczyk <616047+kravietz@users.noreply.github.com>
2021-07-22 16:32:41 +02:00
Maik Stübner
714a34fa55
Allow configuration of password remember in pam (#467)
* Add Configuration of password remember
and set default to 60

see Telekom 2021.07-01 SoC 3.01 Req 25 and SoC 3.65 Req46

Signed-off-by: Maik Stuebner <Maik.Stuebner@t-systems.com>

* set default for password remember back to 5

Signed-off-by: Maik Stuebner <Maik.Stuebner@t-systems.com>

* readme default for password remember back to 5

Signed-off-by: Maik Stuebner <Maik.Stuebner@t-systems.com>
2021-07-22 10:18:01 +02:00
Leo Gallucci
585f1dc227
Add SUB_UID_MIN/MAX/COUNT, SUB_GID_MIN/MAX/COUNT (#463)
* add SUB_UID_MIN/MAX/COUNT, SUB_GID_MIN/MAX/COUNT

Similar reason as #461

> If /etc/subuid exists, the commands useradd and newusers (unless the user already have subordinate user IDs)
> allocate SUB_UID_COUNT unused user IDs from the range SUB_UID_MIN to SUB_UID_MAX for each new user.
> The default values for SUB_UID_MIN, SUB_UID_MAX, SUB_UID_COUNT are respectively 100000, 600100000 and 65536.

Signed-off-by: Leo Gallucci <elgalu3@gmail.com>

* document SUB_UID_MIN/MAX/COUNT, etc

Signed-off-by: Leo Gallucci <elgalu3@gmail.com>
2021-07-16 09:41:37 +02:00
Leo Gallucci
f92d193d3d
add os_auth_uid_max, os_auth_gid_max (#461)
Signed-off-by: Leo Gallucci <elgalu3@gmail.com>
2021-07-12 15:32:02 +02:00
蚯蚓
27c6b93d04
add "when" statements in hardening.yml(#453) (#455)
* add "when" statements in hardening.yml(#453)

Signed-off-by: jqiuyin <943571574@qq.com>

* add "when" statements in hardening.yml(#453)

Signed-off-by: jqiuyin <943571574@qq.com>

* add "when" statements in hardening.yml(#453)

Signed-off-by: jqiuyin <943571574@qq.com>
2021-07-01 11:25:14 +02:00
Sebastian Gumprich
4ca4f09453
Cleanup old OS-support and simplify vars (#458)
* use os_family instead of distribution for debian systems

Signed-off-by: rndmh3ro <github@gumpri.ch>

* remove tasks related to rhel6 or debian 6

Signed-off-by: rndmh3ro <github@gumpri.ch>
2021-06-30 13:09:46 +02:00
Sebastian Gumprich
72ec118a6d
add rocky linux 8 tests and make sure that all relevant tasks are execd (#457)
* add rocky linux 8 tests and make sure that all relevant tasks are executed

Signed-off-by: rndmh3ro <github@gumpri.ch>

* fix missing quote

Signed-off-by: rndmh3ro <github@gumpri.ch>
2021-06-30 13:09:12 +02:00
Sebastian Gumprich
9cefddd949
make sha rounds configurable and increase no of rounds (#452)
* make sha rounds configurable and increase no of rounds

Fixes #365

Signed-off-by: rndmh3ro <github@gumpri.ch>

* Prettified Code!

* make password rounds configurable in pam system-auth

Signed-off-by: rndmh3ro <github@gumpri.ch>

* change wording of sha rounds documentation

Co-authored-by: schurzi <Martin.Schurz@t-systems.com>

Co-authored-by: schurzi <Martin.Schurz@t-systems.com>
2021-06-30 10:41:59 +02:00
Sherwin Daganato
350b5891d1
Add support for Rocky Linux 8 (#454)
Signed-off-by: Sherwin Daganato <sherwin@daganato.com>
2021-06-30 10:12:07 +02:00
schurzi
29e10e5c3b
add tag always to os dependent vars task (#456)
when our collection is used with tags, the os dependent variables are
not resolved. This task should run every time, so the behaviour is
correct.

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-06-29 13:07:25 +02:00
Colin Adler
8cbeeff501
Use include_tasks for os_hardening/main.yml (#451)
When `import_tasks` is used, the task `Fetch OS dependent variables`
always runs, even when excluded by an upstream tag.

When `Fetch OS dependent variables` runs while excluded via tags, it
will always fail with the following.

```
fatal: [alpha]: FAILED! => {"msg": "No file was found when using first_found. Use errors='ignore' to allow this task to be skipped if no files are found"}
```

This brings os_hardening's main.yml in line with ssh_hardening's
main.yml, which doesn't have this issue.

Signed-off-by: Colin Adler <colin@coder.com>
2021-06-23 11:28:08 +02:00
Sebastian Gumprich
41cd8485cb
enable ipv6 globally (#450)
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2021-05-26 20:13:45 +02:00
Lars Düsing
0beeb3ee03 Removed sysctl that tries to disable IPv6. #416
Signed-off-by: Lars Düsing <lars@camelotsweb.de>
2021-05-24 13:33:38 +02:00
schurzi
2882a15ee1
Merge pull request #427 from dev-sec/snoopotic-fix/add_auditd_restart_handler
add restart-auditd handler after configuration change
2021-03-29 21:15:46 +02:00
Sebastian Gumprich
812c6c5974 skip auditd restart in molecule tests
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2021-03-29 10:00:15 +02:00
Sebastian Gumprich
ae68f73965 skip auditd restart in molecule tests
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2021-03-29 09:29:37 +02:00
Farid Joubbi
7af432e1cf
Uppercased first letter of task names. (#422)
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-03-25 13:52:56 +01:00
Farid Joubbi
c90bbd2c23
Improved comments. (#436)
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-03-24 14:31:58 +01:00
Farid Joubbi
d1143a06b1
Not accepting source routing for IPv6. This was already done for IPv4. (#424)
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-03-24 07:55:29 +01:00
Farid Joubbi
240d8acc0c Changed os_auth_pam_pwquality_options type to authtok_type.
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-03-23 11:16:05 +01:00
Martin Schurz
d693a8e200 also use requisite for pwhistory
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-03-23 08:53:49 +01:00
Martin Schurz
0ac56e4c00 Merge branch 'master' into pwhistory
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-03-23 08:53:23 +01:00
schurzi
5be13e878f
Merge pull request #430 from joubbi/comment
Remove comments from PAM config file, but keep it in the template
2021-03-23 08:40:20 +01:00
Farid Joubbi
659e5ada6a Changed to pam_pwhistory.so instead of pam_unix.so for remembering old passwords.
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-03-22 22:28:25 +01:00
Farid Joubbi
0010715039 Remove comment from output file, but keep it in the template.
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-03-22 19:39:49 +01:00
rndmh3ro
369c2986c6 Prettified Code! 2021-03-22 10:23:03 +00:00
Sebastian Gumprich
02c689eaa0 fix loop for home_directories
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2021-03-22 11:18:51 +01:00
Sebastian Gumprich
bf82736787 Update roles/os_hardening/tasks/user_accounts.yml
Co-authored-by: schurzi <Martin.Schurz@t-systems.com>
2021-03-22 11:18:51 +01:00
Sebastian Gumprich
c86bdcb4c7 linting
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2021-03-22 11:18:51 +01:00
Sebastian Gumprich
b5ca78a9cd chmod /home directories to 0700
This is based on https://github.com/dev-sec/ansible-collection-hardening/pull/277
and updated to work with the new collection.

Thanks to @aardbol for this initial implementation!

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2021-03-22 11:18:51 +01:00
Sebastian Gumprich
390f7ad6cc fix linting
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
2021-03-19 14:46:42 +01:00
Felix Herzog
eca93cc80b add restart-auditd handler as after configuration change (e.g. of os_auditd_max_log_file_action) you need to restart. Sadly on rhel7 systems you cannot use systemd. And as debian derivates use service as alias and it works I kept it that simple. also adding 'auditd'-tag to make it easy only run that config change if needed.
Signed-off-by: Felix Herzog <snoopotic@gmail.com>
2021-03-19 14:42:31 +01:00
schurzi
a64838272c
Merge pull request #418 from joubbi/documentation2
Improve Documentation for sysctl defaults
2021-03-16 15:49:55 +01:00
Martin Schurz
b2dd73d27e remove unneeded tasks
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-03-15 23:53:40 +01:00
Martin Schurz
ec9d7d2cb8 cleanup and typos
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-03-15 23:39:12 +01:00
Farid Joubbi
97c55d6e55 Documented rationale for sysctl values set.
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-03-15 14:01:19 +01:00
Martin Schurz
5f97dffddf Merge branch 'master' into tally
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-03-11 19:26:37 +01:00
schurzi
103135ce9a fix task naming
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-03-11 17:21:32 +01:00
Farid Joubbi
4158e0bfb4 Created a list of files/dirs to be looped instead of two tasks per file/dir.
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-03-11 16:54:25 +01:00
Farid Joubbi
4bad4779cd Fixed copy-paste error by doing og-rwx instead of numerical.
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-02-22 22:13:18 +01:00
Martin Schurz
75fc31b80c remove cracklib
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-02-22 19:10:45 +01:00
Farid Joubbi
91a0d62305 Ensure permissions on /etc/crontab are configured. #375
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-02-19 23:19:00 +01:00
Farid Joubbi
60d24db460 Ensure permissions on /etc/crontab are configured. #375
Signed-off-by: Farid Joubbi <farid@joubbi.se>
2021-02-19 22:40:16 +01:00
schurzi
8e4c22d8d9
remove FQCN from roles in examples (#404)
Ansible does not work with FQCN and collections sepcified for including
roles. It is currently expecting to only get the role name in this
context.

Verified with Ansible 2.10.5

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-02-17 11:34:37 +01:00
Martin Schurz
dba53718cf sssd is disabled on Amazonlinus
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2021-02-16 20:44:28 +01:00