* updating apt is not in the scope of a libpam-passwdqc task, IMHO
---------
Signed-off-by: Eike Sauer <[email protected]>
Co-authored-by: Eike Sauer <[email protected]>
Ansible can open multiple connections and it's possible for a new socket
to open before activation is fully disabled, leaving a zombie sshd
process. At least that is the guess. Ubuntu 24.04 suffers from this.
Reload the configuration after disabling socket activation to not enable
it again.
Signed-off-by: Tatu Argillander <[email protected]>
* ci: disable injecting facts as own vars in the main namespace
Signed-off-by: Norman Ziegner <[email protected]>
* Consistently access facts via the ansible_facts.* namespace
Signed-off-by: Norman Ziegner <[email protected]>
---------
Signed-off-by: Norman Ziegner <[email protected]>
* os_hardening: disable systemd audit logging
disable audit logging via systemd-journald when enabling auditd
as this leads to duplicate logs in the journal or even /var/log/messages
depending on the configuration
Signed-off-by: Christoph Sieber <[email protected]>
* Don't disable systemd-journald-audit.socket on Suse
it seems the socket doesn't exist on this OS
Signed-off-by: Christoph Sieber <[email protected]>
---------
Signed-off-by: Christoph Sieber <[email protected]>
Co-authored-by: Christoph Sieber <[email protected]>
* Update test environments to current Ansible version
Signed-off-by: Martin Schurz <[email protected]>
* Add Workaround for vagrant
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
* Write sysctl config to separate file
Write our sysctl config to separate file, since newer distributions no longer use the global /etc/sysctl.conf file. All older distributions seem to already support reading from /etc/sysctl.d so this should be no breaking change.
* Add support for current versions of Debian and EL
Signed-off-by: Martin Schurz <[email protected]>
* Add conditions for EL8
Signed-off-by: Martin Schurz <[email protected]>
* Fix Audit in AlmaLinux
Signed-off-by: Martin Schurz <[email protected]>
* Fix broken SSH host key config in rhel/almalinux 10
Signed-off-by: Jonathan Wright <[email protected]>
* Generate SSH Keys on EL10
Signed-off-by: Martin Schurz <[email protected]>
* Generate SSH Keys for tests via Systemd
Signed-off-by: Martin Schurz <[email protected]>
* Fixup tests
Signed-off-by: Martin Schurz <[email protected]>
* Remove auditd conditions
Signed-off-by: Martin Schurz <[email protected]>
* Add path to audit handler
Signed-off-by: Martin Schurz <[email protected]>
* Install init scripts
Signed-off-by: Martin Schurz <[email protected]>
* Update main README
---------
Signed-off-by: Martin Schurz <[email protected]>
Signed-off-by: Jonathan Wright <[email protected]>
Co-authored-by: Jonathan Wright <[email protected]>
Signed-off-by: Martin Schurz <[email protected]>
Make changes portable
Signed-off-by: Martin Schurz <[email protected]>
Make changes portable
Signed-off-by: Martin Schurz <[email protected]>
Make changes portable
Signed-off-by: Martin Schurz <[email protected]>
Make changes portable
Signed-off-by: Martin Schurz <[email protected]>
Make changes portable
Signed-off-by: Martin Schurz <[email protected]>
Make changes portable
Signed-off-by: Martin Schurz <[email protected]>
Make changes portable
Signed-off-by: Martin Schurz <[email protected]>
* Provide granular noop for shh configuration
We would like to have more fine grained options on applying or not specific configurations.
This commit let the user choose to noop some configuration with a few new
boolean variables.
Motivation for theses options are we may configure ourselves some (ssh host key
regeneration in a templating system) or we are not ready for others (ssh_kex
will break dist-upgrades, letting the operator without ssh).
Signed-off-by: seven beep <[email protected]>
* Provide granula noop for ssh configuration
We would like to have more fine grained options on applying or not specific configurations.
This commit let the user choose to disable configurations for `ssh_host_key_config`,
`ssh_ciphers_config`, `ssh_host_key_config`, `ssh_macs_config` by setting them
to False.
Motivation for theses options are we may configure ourselves some (ssh host key
regeneration in a templating system) or we are not ready for others (ssh_kex
will break dist-upgrades, letting the operator without ssh).
Signed-off-by: seven beep <[email protected]>
---------
Signed-off-by: seven beep <[email protected]>
ssh_permit_tunnel needs quotes otherwise we will end up with an error:
```
TASK [devsec.hardening.ssh_hardening : Create sshd_config and set permissions to root/600] **********************************************************************************************************************
fatal: [vampdock02]: FAILED! => {"changed": false, "checksum": "fe6b74e30b1a653f83c2cbe1dd1332c14bd55833", "exit_status": 255, "msg": "failed to validate", "stderr": "/home/debian/.ansible/tmp/ansible-tmp-1728530891.493071-72386-149151737175948/source line 123: bad PermitTunnel argument True\r\n", "stderr_lines": ["/home/debian/.ansible/tmp/ansible-tmp-1728530891.493071-72386-149151737175948/source line 123: bad PermitTunnel argument True"], "stdout": "", "stdout_lines": []}
```
* disable systemd socket activation
Signed-off-by: Sebastian Gumprich <[email protected]>
* move start to after deactivation so it can start
---------
Signed-off-by: Sebastian Gumprich <[email protected]>
* do not force type of gatewayports-var
this way it can be a bool or a string. we also now test for it
Signed-off-by: Sebastian Gumprich <[email protected]>
* replace yum with dnf
Signed-off-by: Sebastian Gumprich <[email protected]>
---------
Signed-off-by: Sebastian Gumprich <[email protected]>
* centos7 is eol, remove it
Signed-off-by: Sebastian Gumprich <[email protected]>
* change workflow to update readmes when meta/main.yml is changed
Signed-off-by: Sebastian Gumprich <[email protected]>
* remove mention of centos 7 from readme
Signed-off-by: Sebastian Gumprich <[email protected]>
---------
Signed-off-by: Sebastian Gumprich <[email protected]>
The `os_unused_filesystems` was lacking sorting, making the task not
idempotent. This was especially apparent and random in Molecule tests
when this collection was added as a dependency.
Signed-off-by: Aki Kanellis <[email protected]>
* add testing and support for current versions of Fedora and FreeBSD
Signed-off-by: Martin Schurz <[email protected]>
* add waivers for FreeBSD
Signed-off-by: Martin Schurz <[email protected]>
* use original fedora images
Signed-off-by: Martin Schurz <[email protected]>
* also harden /home mount
Signed-off-by: Martin Schurz <[email protected]>
* also harden /tmp mount
Signed-off-by: Martin Schurz <[email protected]>
* test mock efi directory
Signed-off-by: Martin Schurz <[email protected]>
* remove mock
Signed-off-by: Martin Schurz <[email protected]>
* umount efi
Signed-off-by: Martin Schurz <[email protected]>
* add /tmp to special mountpoints
Signed-off-by: Martin Schurz <[email protected]>
* set options for /tmp mount
Signed-off-by: Martin Schurz <[email protected]>
* create /tmp mount
Signed-off-by: Martin Schurz <[email protected]>
* create /tmp mount and mount it ...
Signed-off-by: Martin Schurz <[email protected]>
* make fewer changes to default test run
Signed-off-by: Martin Schurz <[email protected]>
* use correct Ansible var
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
There's a new feature in mariadb 10.1 (https://mariadb.org/grant-to-public-in-mariadb/) and mysql 8 (need to verify).
MariaDB has quite a complex privilege system. Most of it is based on the SQL Standard spec; however we do have some specific MariaDB extensions. GRANT ... TO PUBLIC (MDEV-5215) is a standard feature that is now available as a preview in MariaDB 10.11.0. It is related to ROLES and DEFAULT ROLE, but it covers a different use case.
ROLES are effectively “privilege packages” that you can enable and disable as a user. One can also set which “privilege package” will be enabled at connect time by setting a DEFAULT ROLE per user. This is all quite useful, however it is missing one key feature. For a DBA, it would be quite useful to state only once that all users need to have a certain set of privileges. This is where GRANT ... TO PUBLIC comes in.
Some more information here: https://mariadb.org/wp-content/uploads/2018/07/MariaDB-Roles-Tampere-Unconference-2018.pdf
This role is shown as a user, it has however a new is_role-flag.
MariaDB [(none)]> select user, host, is_role from mysql.user;
+-----------------------+-----------+---------+
| User | Host | is_role |
+-----------------------+-----------+---------+
| mariadb.sys | localhost | N |
| root | localhost | N |
| mysql | localhost | N |
| PUBLIC | | Y |
| monitoring | % | N |
| monitoring | localhost | N |
| galera_mariadb_backup | % | N |
+-----------------------+-----------+---------+
Since this "user" does not have a password or authentication_string, the ansible-role tries to delete it but fails.
Signed-off-by: Sebastian Gumprich <[email protected]>
* Gather facts when os_hardening role is executed with tags
Signed-off-by: Martin Schurz <[email protected]>
* better when condition
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
* update links to new Ansible Galaxy
Signed-off-by: Martin Schurz <[email protected]>
* remove dead link
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
* add role argument spec for os, ssh, mysql
Signed-off-by: Sebastian Gumprich <[email protected]>
* add role argument spec for os, ssh, mysql
Signed-off-by: Sebastian Gumprich <[email protected]>
* remove variable in variable as it cannot be used in argument spec
Signed-off-by: Sebastian Gumprich <[email protected]>
* fix wrong syntax
* fix spelling errors
Signed-off-by: Sebastian Gumprich <[email protected]>
* cannot use vars before arg-spec validation
Signed-off-by: Sebastian Gumprich <[email protected]>
* yamllint the arg-spec
Signed-off-by: Sebastian Gumprich <[email protected]>
* add back variable
Signed-off-by: Sebastian Gumprich <[email protected]>
* remove redundant setting in tests
* fix descriptions in mysql hardening to betterreflect what they do
Signed-off-by: Sebastian Gumprich <[email protected]>
* remove duplicate empty line
Signed-off-by: Sebastian Gumprich <[email protected]>
* set correct defaults on to ssl options
Signed-off-by: Sebastian Gumprich <[email protected]>
* remove left-over hidepid argument spec
Signed-off-by: Sebastian Gumprich <[email protected]>
* remove license and author infos, this lives in the collection readme
Signed-off-by: Sebastian Gumprich <[email protected]>
* fix styling
Signed-off-by: Sebastian Gumprich <[email protected]>
* update some descriptions and sort them in the readme
Signed-off-by: Sebastian Gumprich <[email protected]>
* some more linting
Signed-off-by: Sebastian Gumprich <[email protected]>
---------
Signed-off-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
* add debian 12 support
Signed-off-by: Sebastian Gumprich <[email protected]>
* temp disable pam-checks
Signed-off-by: Sebastian Gumprich <[email protected]>
* remove debian12 from vagrant tests as there's no box yet
Signed-off-by: Sebastian Gumprich <[email protected]>
* use new pam-tester from pip
Signed-off-by: Sebastian Gumprich <[email protected]>
* use new pam-tester from pip
Signed-off-by: Sebastian Gumprich <[email protected]>
* add setuptoolks to pam-tester install
Signed-off-by: Sebastian Gumprich <[email protected]>
* add setuptoolks to pam-tester install
Signed-off-by: Sebastian Gumprich <[email protected]>
* add setuptoolks to pam-tester install
Signed-off-by: Sebastian Gumprich <[email protected]>
* add setuptoolks to pam-tester install
Signed-off-by: Sebastian Gumprich <[email protected]>
* install pam-tester with python3 and use full path to it
Signed-off-by: Sebastian Gumprich <[email protected]>
* install python3-setupttools in verify-tests
Signed-off-by: Sebastian Gumprich <[email protected]>
* fix path for pam-tester in all tests
Signed-off-by: Sebastian Gumprich <[email protected]>
* set python interpreter to 3 for verify-tests
Signed-off-by: Sebastian Gumprich <[email protected]>
* Revert "set python interpreter to 3 for verify-tests"
This reverts commit 00b6556e33.
* add back accidentally deleted tasks
Signed-off-by: Sebastian Gumprich <[email protected]>
---------
Signed-off-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
* make template overrideable
by referencing the auditd.conf.j2 template, a custom template can be provided to the role.
Signed-off-by: Dennis Lerch <[email protected]>
* extend auditd config
make freq and log_file configurable
implement write_logs with it's default value in order to be able to disable log writing
Signed-off-by: Dennis Lerch <[email protected]>
* Extend README.md documentation by new variables
reorder `os_auditd_log_format` to keep sequence from defaults
Signed-off-by: Dennis Lerch <[email protected]>
---------
Signed-off-by: Dennis Lerch <[email protected]>
there's probably some added value for this, but I see no reason to change so many variables and possibly break something when it still works and nobody complained
Signed-off-by: Sebastian Gumprich <[email protected]>
* add testing for OpenBSD and FreeBSD
Signed-off-by: Martin Schurz <[email protected]>
* make python work
Signed-off-by: Martin Schurz <[email protected]>
* remove jinja template ...
Signed-off-by: Martin Schurz <[email protected]>
* make verify work
Signed-off-by: Martin Schurz <[email protected]>
* correct verify
Signed-off-by: Martin Schurz <[email protected]>
* correct verify
Signed-off-by: Martin Schurz <[email protected]>
* correct verify
Signed-off-by: Martin Schurz <[email protected]>
* correct verify
Signed-off-by: Martin Schurz <[email protected]>
* use right vm name for connect
Signed-off-by: Martin Schurz <[email protected]>
* add a bit of documentation
Signed-off-by: Martin Schurz <[email protected]>
* remove sudo
Signed-off-by: Martin Schurz <[email protected]>
* add weird OpenSBD workaround
Signed-off-by: Martin Schurz <[email protected]>
* make verify playbook more consistent
Signed-off-by: Martin Schurz <[email protected]>
* rename nonlinux to BSD
Signed-off-by: Martin Schurz <[email protected]>
* use openbsd7 for testing
Signed-off-by: Martin Schurz <[email protected]>
* correct use openbsd7 everywhere
Signed-off-by: Martin Schurz <[email protected]>
* add waivers
Signed-off-by: Martin Schurz <[email protected]>
* update waiver descriptions
Signed-off-by: Martin Schurz <[email protected]>
* use docker for inspec
Signed-off-by: Martin Schurz <[email protected]>
* keep looking right ;)
Signed-off-by: Martin Schurz <[email protected]>
* correct path to waivers
Signed-off-by: Martin Schurz <[email protected]>
* use ephemeral directory in docker
Signed-off-by: Martin Schurz <[email protected]>
* use bsd inspec profile
Signed-off-by: Martin Schurz <[email protected]>
* remove openbsd workaround
Signed-off-by: Martin Schurz <[email protected]>
* re-add openbsd workaround
Signed-off-by: Martin Schurz <[email protected]>
* commit suggestions
Signed-off-by: Martin Schurz <[email protected]>
* add supportet OS to metadata
Signed-off-by: Martin Schurz <[email protected]>
* use current python
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
* add check mode to molecule tests
Signed-off-by: Martin Schurz <[email protected]>
* bail on undefined variables
Signed-off-by: Martin Schurz <[email protected]>
* bail on undefined variables
Signed-off-by: Martin Schurz <[email protected]>
* execute tasks in check mode
Signed-off-by: Martin Schurz <[email protected]>
* fix error in check mode on SuSE
Signed-off-by: Martin Schurz <[email protected]>
* use when condition on task
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
* use rowcount to determine mysql results
Signed-off-by: Martin Schurz <[email protected]>
* use correct list level
Signed-off-by: Martin Schurz <[email protected]>
* remove json_query
Signed-off-by: Martin Schurz <[email protected]>
* remove intermediate vars
Signed-off-by: Martin Schurz <[email protected]>
* add check for count
Signed-off-by: Martin Schurz <[email protected]>
* drop condition, since one result must exist
Signed-off-by: Martin Schurz <[email protected]>
* move rowcount in condition
Signed-off-by: Martin Schurz <[email protected]>
* do loop in ansible to report each deleted user
Signed-off-by: Martin Schurz <[email protected]>
* add idempotency check
Signed-off-by: Martin Schurz <[email protected]>
* additional tests to verify user deletion
Signed-off-by: Martin Schurz <[email protected]>
* actually iterate the whole user list when deleting
Signed-off-by: Martin Schurz <[email protected]>
* fix tests for SuSE
Signed-off-by: Martin Schurz <[email protected]>
* adopt suggestions
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
* allow multiple instances for os vm tests
Signed-off-by: Martin Schurz <[email protected]>
* add scheduled trigger to all test actions
Signed-off-by: Martin Schurz <[email protected]>
* use different scenario names
Signed-off-by: Martin Schurz <[email protected]>
* use different scenario names
Signed-off-by: Martin Schurz <[email protected]>
* use different scenario names
Signed-off-by: Martin Schurz <[email protected]>
* use username to create uniqe vms
Signed-off-by: Martin Schurz <[email protected]>
* use compatible name
Signed-off-by: Martin Schurz <[email protected]>
* add explaination
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
* add remaining platforms to test
Signed-off-by: Martin Schurz <[email protected]>
* remove unneccessary tasks for test
Signed-off-by: Martin Schurz <[email protected]>
* use current opensuse version
Signed-off-by: Martin Schurz <[email protected]>
* disable sysctl for missing yama in opensuse
Signed-off-by: Martin Schurz <[email protected]>
---------
Signed-off-by: Martin Schurz <[email protected]>
* rewrite user home dir hardening
* delete duplicate var that was missed in a merge conflict
Signed-off-by: Sebastian Gumprich <[email protected]>
* linting
Signed-off-by: Sebastian Gumprich <[email protected]>
* add tests for home rewrites
Signed-off-by: Sebastian Gumprich <[email protected]>
* Apply suggestions from code review
Co-authored-by: schurzi <[email protected]>
---------
Signed-off-by: Sebastian Gumprich <[email protected]>
Co-authored-by: donestefan <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
Co-authored-by: schurzi <[email protected]>
* Preserve default ownership and dir mode for /var/log on Ubuntu
Signed-off-by: stdtom <[email protected]>
* linting
Signed-off-by: stdtom <[email protected]>
* Define vars for each OS instead of using defaults.
Signed-off-by: stdtom <[email protected]>
* Fix values for os_mnt_var_log_dir_mode and os_mnt_var_log_group
Signed-off-by: stdtom <[email protected]>
Signed-off-by: stdtom <[email protected]>
* add verify-task to check if mysql is running and enabled
Signed-off-by: Sebastian Gumprich <[email protected]>
* Update molecule/mysql_hardening/verify_tasks/service.yml
Co-authored-by: schurzi <[email protected]>
Signed-off-by: Sebastian Gumprich <[email protected]>
Co-authored-by: schurzi <[email protected]>
* Update main.yml
fixes the handler file and set new syntax
Signed-off-by: Jacob Sievert <[email protected]>
* changes command module from legacy to builtin.
Signed-off-by: Jacob Sievert <[email protected]>
Signed-off-by: Jacob Sievert <[email protected]>
This role fails with `The task includes an option with an undefined variable` on OpenBSD because `distributiuon_major_version` is not set on OpenBSD.
We should either default to "" if the variable is not set, or remove `vars/OpenBSD.yml`. I would prefer the former :)
Signed-off-by: Dennis Eriksen <[email protected]>
Signed-off-by: Dennis Eriksen <[email protected]>
* 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 <[email protected]>
* fix lint errors
Signed-off-by: divialth <[email protected]>
* implemented the name suggestions
Signed-off-by: divialth <[email protected]>
Signed-off-by: divialth <[email protected]>
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 <[email protected]>
Signed-off-by: Philipp Funk <[email protected]>
Co-authored-by: Philipp Funk <[email protected]>
* Include Debian 11 into Molecule test suites (#527)
Signed-off-by: Daya Adianto <[email protected]>
* Fix Ansible Lint GitHub Action version (#527)
Signed-off-by: Daya Adianto <[email protected]>
* Update .gitignore
Signed-off-by: Daya Adianto <[email protected]>
* mysql_hardening: Use Python 3 as Ansible interpreter (#527)
Signed-off-by: Daya Adianto <[email protected]>
* Note Debian 11 support for os_hardening & nginx_hardening (#527)
Signed-off-by: Daya Adianto <[email protected]>
* Fix lint issues & Ansible Lint configuration in CI
Signed-off-by: Daya Adianto <[email protected]>
* Try to fix YAML lint issues, again
Re-ordered YAML comments at the end of `.yamllint` file.
Signed-off-by: Daya Adianto <[email protected]>
* rm debian9 from tests, add debian 11 where missing
Signed-off-by: Sebastian Gumprich <[email protected]>
* fix mysql molecule tests
Signed-off-by: Sebastian Gumprich <[email protected]>
Signed-off-by: Daya Adianto <[email protected]>
Signed-off-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
* add VM tests for ssh_hardening
Signed-off-by: Martin Schurz <[email protected]>
* remove VM tests from ssh_hardening
Signed-off-by: Martin Schurz <[email protected]>
* run ssh_hardening test as unprivileged user
Signed-off-by: Martin Schurz <[email protected]>
* add link for documentation
Signed-off-by: Martin Schurz <[email protected]>
* use different config
Signed-off-by: Martin Schurz <[email protected]>
* remove become
Signed-off-by: Martin Schurz <[email protected]>
* re-add become
Signed-off-by: Martin Schurz <[email protected]>
* move become into role
Signed-off-by: Martin Schurz <[email protected]>
* indentation
Signed-off-by: Martin Schurz <[email protected]>
* try args apply
Signed-off-by: Martin Schurz <[email protected]>
* fix linting
Signed-off-by: Martin Schurz <[email protected]>
* add documentation
Signed-off-by: Martin Schurz <[email protected]>
Signed-off-by: Martin Schurz <[email protected]>
```
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 <[email protected]>
* Only run harding if /var/log/audit exists
Signed-off-by: GitHub <[email protected]>
* Update roles/os_hardening/tasks/minimize_access.yml
* add more conditionals to when auditd show be hardened
Signed-off-by: Sebastian Gumprich <[email protected]>
* add more tests to the os-hardening vm tests
Signed-off-by: Sebastian Gumprich <[email protected]>
* Revert "add more tests to the os-hardening vm tests"
This reverts commit c05fe8b520.
Signed-off-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
* first testing with tasks and variables
Signed-off-by: Ludwig Bayerlein <[email protected]>
* update variables for dir options
Signed-off-by: Ludwig Bayerlein <[email protected]>
* updated permissions and defaults
Signed-off-by: Ludwig Bayerlein <[email protected]>
* fix home dir permissions
Signed-off-by: Ludwig Bayerlein <[email protected]>
* updated tasks with useful variables
Signed-off-by: Ludwig Bayerlein <[email protected]>
* reorder tasks. first remount, then manage fstab and fix permissions on directories. Renaming task names with mountpoints (slashes)
Signed-off-by: Ludwig Bayerlein <[email protected]>
* shorten tasks with list items
Signed-off-by: Ludwig Bayerlein <[email protected]>
* change defaults for /boot directory, because its a bad behaviour, if ansible changes boot entries with a default value
Signed-off-by: Ludwig Bayerlein <[email protected]>
* Update documentation for new parameters to manage mountpoints
Signed-off-by: Ludwig Bayerlein <[email protected]>
* Update roles/os_hardening/tasks/minimize_access.yml
Co-authored-by: Sebastian Gumprich <[email protected]>
Signed-off-by: Ludwig Bayerlein <[email protected]>
* Update roles/os_hardening/tasks/minimize_access.yml
Co-authored-by: Sebastian Gumprich <[email protected]>
Signed-off-by: Ludwig Bayerlein <[email protected]>
* Fix state on every new task
Signed-off-by: Ludwig Bayerlein <[email protected]>
* loop instead of list
Signed-off-by: Ludwig Bayerlein <[email protected]>
* testing remount with register
Signed-off-by: Ludwig Bayerlein <[email protected]>
* add remounts with loop over all changed folders
Signed-off-by: Ludwig Bayerlein <[email protected]>
* testing and solving trouble with variable names
Signed-off-by: Ludwig Bayerlein <[email protected]>
* optimize default permissions for var-log-audit
Signed-off-by: Ludwig Bayerlein <[email protected]>
* optimize default permissions for var-log-audit
Signed-off-by: Ludwig Bayerlein <[email protected]>
* change to new optimizied permissions of var-log-audit
Signed-off-by: Ludwig Bayerlein <[email protected]>
* fix some defaults in fstab to configure as mounted
Signed-off-by: Ludwig Bayerlein <[email protected]>
* add stat and check, if boot folder exists
Signed-off-by: Ludwig Bayerlein <[email protected]>
Co-authored-by: Ludwig Bayerlein <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
while this could be better solved by checking what nginx version is used, debian9 is eol'd in 4 months. if there will be again a need to check for nginx versions, we'll add it then
Signed-off-by: rndmh3ro <[email protected]>
This prevents annoying task errors (even though they are ignored)
when testing on non-Arch distributions.
Running the "prepare" command, this was always visible:
> fatal: [instance]: FAILED! => {"changed": false, "msg": "Failed to find required executable \"pacman\" in paths: /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin"}
Signed-off-by: René Scheibe <[email protected]>
Files in this whitelist should not be altered.
Currently this is only relevant for enforcing the gpg check.
Signed-off-by: René Scheibe <[email protected]>
* new function to disable ctrl-alt-del to avooid reboot virtual machines f.e.
Signed-off-by: Ludwig Bayerlein <[email protected]>
* fix variable documentation for ctrlaltdel
Signed-off-by: Ludwig Bayerlein <[email protected]>
* added ctrlaltdel variable for molecule
Signed-off-by: Ludwig Bayerlein <[email protected]>
* optimize ctrlaltdel function with a 'when' query. thanks to rndmh3ro
Signed-off-by: Ludwig Bayerlein <[email protected]>
* fix typo in new file
Co-authored-by: Ludwig Bayerlein <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
We deprecated our roles in Ansible Galaxy the deprecation link contains
a search keyword with the role name and our new collection should be
found, if someone clicks this link.
Signed-off-by: Martin Schurz <[email protected]>
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 <[email protected]>
* fix filter error in ansible.builtin.file mode parameter
* Change cinc supermarket
* fix link to baseline
* fix typo
Co-authored-by: Sebastian Gumprich <[email protected]>
* [mysql_hardening] Allow setting the mysql_distribution
On some operating systems, the package for MySQL is not `mysql-server`,
and so the default check for this will not yield the correct result.
This change adds an escape hatch by letting the user set
`mysql_distribution`. Additionally, it verifies that it is set to a
legal value if the user has set it.
Closes#472
Signed-off-by: Shawn Wilsher <[email protected]>
* Update roles/mysql_hardening/tasks/main.yml
Co-authored-by: Sebastian Gumprich <[email protected]>
* 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 <[email protected]>
* Clean up whitespaces
Signed-off-by: Paweł Krawczyk <[email protected]>
* 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 <[email protected]>
* set default for password remember back to 5
Signed-off-by: Maik Stuebner <[email protected]>
* readme default for password remember back to 5
Signed-off-by: Maik Stuebner <[email protected]>
* 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 <[email protected]>
* document SUB_UID_MIN/MAX/COUNT, etc
Signed-off-by: Leo Gallucci <[email protected]>
* use os_family instead of distribution for debian systems
Signed-off-by: rndmh3ro <[email protected]>
* remove tasks related to rhel6 or debian 6
Signed-off-by: rndmh3ro <[email protected]>
* add rocky linux 8 tests and make sure that all relevant tasks are executed
Signed-off-by: rndmh3ro <[email protected]>
* fix missing quote
Signed-off-by: rndmh3ro <[email protected]>
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 <[email protected]>
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 <[email protected]>
* galaxy.yml: Adds dependency on ansible.posix (Fixes: #414)
This is required by the OS hardening role, which uses the mount module.
* add community.general dependency
Co-authored-by: Sebastian Gumprich <[email protected]>
* added version check for MariaDB in Query
MariaDB Uses the authentication_string field since 10.4.0, added this in version check in query for users to delete
Signed-off-by: Martin Neubert <[email protected]>
* Update roles/mysql_hardening/tasks/mysql_secure_installation.yml
Co-authored-by: Sebastian Gumprich <[email protected]>
* Update roles/mysql_hardening/tasks/mysql_secure_installation.yml
Co-authored-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
* ssh: Client HostKeyAlgorithms configuration variable
Introduce a new variable ssh_client_host_key_algorithms to be able to configure
it for the client like for the server.
This fixes#441
Signed-off-by: Paul Seidler <[email protected]>
* sshd: Adapt the ssh_host_key_algorithms description
Linking to the latest version may lead to a broken config so be a bit more
dynamic
Signed-off-by: Paul Seidler <[email protected]>
Signed-off-by: Sebastian Gumprich <[email protected]>
install collection in molecule
Signed-off-by: Sebastian Gumprich <[email protected]>
remove deprecated ubuntu 16.04 from tests
Signed-off-by: Sebastian Gumprich <[email protected]>
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 <[email protected]>
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 <[email protected]>
Previously, the ssh_gssapi_support variable only toggled the GSSAPI
settings in sshd_config.
Through this change, setting ssh_gssapi_support to true also enables
support in ssh_config.
It enables both authentication and credential delegation.
Signed-off-by: Maxim Burgerhout <[email protected]>
* make wrong password fail task
Signed-off-by: Sebastian Gumprich <[email protected]>
* add name to fail task
Signed-off-by: Sebastian Gumprich <[email protected]>
* add restart handler variable for mysql role
Signed-off-by: Sebastian Gumprich <[email protected]>
* add prettierignore file to ignore CHANGELOG
Signed-off-by: Sebastian Gumprich <[email protected]>
* add ansible to requirements
Signed-off-by: Martin Schurz <[email protected]>
* trigger run
Signed-off-by: Martin Schurz <[email protected]>
* update noqa for ansible-lint 5
Signed-off-by: Martin Schurz <[email protected]>
tihis fixes a problem with Ansible 2.9 where the default openssh_keypair
is not supporting every option we need
Signed-off-by: Martin Schurz <[email protected]>
- **Describe** what is happening and what should happen
- **Explain** how to reproduce the problem
- **Add** more details and attachments
- **Follow up**, if somebody is having questions or needs more details
- type:textarea
id:description
attributes:
label:"Description"
description:Describe the bug
placeholder:A clear and concise description of what the bug is.
validations:
required:true
- type:textarea
id:reprod
attributes:
label:"Reproduction steps"
render:Shell
description:Paste an example playbook that can be used to reproduce the problem. This will be automatically formatted into code, no need for backticks.
value:|
...
validations:
required:true
- type:textarea
id:currentbehavior
attributes:
label:"Current Behavior"
description:Please describe the results you received
value:|
...
validations:
required:true
- type:textarea
id:expectedbehavior
attributes:
label:"Expected Behavior"
description:Please describe the results you expect
value:|
...
validations:
required:true
- type:textarea
id:os
attributes:
label:"OS / Environment"
value:|
Provide all relevant information below, e.g. target OS versions, network device firmware, etc.
validations:
required:true
- type:textarea
id:ansible
attributes:
label:"Ansible Version"
render:Shell
value:|
Paste verbatim output from "ansible --version" between quotes. This will be automatically formatted into code, so no need for backticks.
validations:
required:true
- type:textarea
id:collection
attributes:
label:"Collection Version"
render:Shell
value:|
Paste version of the collection. This will be automatically formatted into code, so no need for backticks.
validations:
required:true
- type:textarea
id:additional
attributes:
label:"Additional information"
description:Please add information like the used software versions, outputs of logs, OS information, screenshots, etc. to enhance the report
@@ -15,7 +15,7 @@ In order to contribute code please:
1. Fork the project on GitHub
2. Clone the project
3. Add changes (and tests)
4. Commit and push
4. Commit, sign off and push your changes
5. Create a merge-request
To have your code merged, see the expectations listed below.
@@ -28,6 +28,24 @@ Some great guidelines can be found [here](https://wiki.openstack.org/wiki/GitCom
## Expectations
## Sign off Your Work
The Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project.
[Here is the full text of the DCO](http://developercertificate.org/).
Contributors must sign-off that they adhere to these requirements by adding a `Signed-off-by` line to commit messages.
```text
This is my commit message
Signed-off-by: Random J Developer <random@developer.example.org>
```
Git even has a -s command line option to append this automatically to your commit message:
```text
git commit -s -m 'This is my commit message'
```
### Don't reinvent the wheel
This hardening project doesn't intend to reinvent the configuration stack for services. Aim to use official configuration projects first and provide hardening as a layer on top. The goal is remove the need for a user to configure all aspects of services and maintain security configuration. This way, the user can still configure a service using the interface provided by the official project.
@@ -75,6 +93,21 @@ We generally include test for coding guidelines:
Remember: Code is generally read much more often than written.
### Local testing of roles in this collection
We are using Molecule to test our roles.
If you want to execute the tests on your machine you need Docker and Molecule.
You will also need to set the `MOLECULE_DISTRO` environment variable to execute the tests.
To find valid values for the variable you can take a look at our GitHub Action workflows in `.github/workflows/`.
Example for executing tests locally:
```bash
pip install -r requirements.txt
export MOLECULE_DISTRO="debian12"
molecule test -s os_hardening
```
### Use Markdown
Wherever possible, please refrain from any other formats and stick to simple markdown.
- do not blacklist used filesystems [\#289](https://github.com/dev-sec/ansible-os-hardening/pull/289) [[patch](https://github.com/dev-sec/ansible-os-hardening/labels/patch)] ([schurzi](https://github.com/schurzi))
- move hidepid vars into defaults so theyre overwritable [\#285](https://github.com/dev-sec/ansible-os-hardening/pull/285) [[patch](https://github.com/dev-sec/ansible-os-hardening/labels/patch)] ([rndmh3ro](https://github.com/rndmh3ro))
- move hidepid vars into defaults so they're overwritable [\#285](https://github.com/dev-sec/ansible-os-hardening/pull/285) [[patch](https://github.com/dev-sec/ansible-os-hardening/labels/patch)] ([rndmh3ro](https://github.com/rndmh3ro))
- Add kernel parameter information to README [\#259](https://github.com/dev-sec/ansible-os-hardening/pull/259) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([jaredledvina](https://github.com/jaredledvina))
- Standardize the var ordering [\#251](https://github.com/dev-sec/ansible-os-hardening/pull/251) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([dustinmiller1337](https://github.com/dustinmiller1337))
- Add intial support for OpenSUSE [\#250](https://github.com/dev-sec/ansible-os-hardening/pull/250) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([dustinmiller1337](https://github.com/dustinmiller1337))
- Add initial support for OpenSUSE [\#250](https://github.com/dev-sec/ansible-os-hardening/pull/250) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([dustinmiller1337](https://github.com/dustinmiller1337))
- Make max_log_file_action for auditd configurable [\#246](https://github.com/dev-sec/ansible-os-hardening/pull/246) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([jandd](https://github.com/jandd))
- Add exception in sysctl task [\#240](https://github.com/dev-sec/ansible-os-hardening/pull/240) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([ghost](https://github.com/ghost))
- Fedora - Use new auto ansible_python_interpreter for dnf [\#239](https://github.com/dev-sec/ansible-os-hardening/pull/239) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([jaredledvina](https://github.com/jaredledvina))
@@ -165,7 +165,7 @@
**Fixed bugs:**
- auditd causing v5.0 to fail on unpriviledged LXC's [\#191](https://github.com/dev-sec/ansible-os-hardening/issues/191) [[bug](https://github.com/dev-sec/ansible-os-hardening/labels/bug)]
- auditd causing v5.0 to fail on unprivileged LXC's [\#191](https://github.com/dev-sec/ansible-os-hardening/issues/191) [[bug](https://github.com/dev-sec/ansible-os-hardening/labels/bug)]
- Setting os_security_users_allow has no effect [\#175](https://github.com/dev-sec/ansible-os-hardening/issues/175) [[bug](https://github.com/dev-sec/ansible-os-hardening/labels/bug)]
- add /usr/bin/su to suid_guid whitelist [\#199](https://github.com/dev-sec/ansible-os-hardening/pull/199) [[bug](https://github.com/dev-sec/ansible-os-hardening/labels/bug)] ([ccolic](https://github.com/ccolic))
- ensure that permissions to su-binary are not restricted to root user and group only, if os_security_users_allow contains the value change_user [\#197](https://github.com/dev-sec/ansible-os-hardening/pull/197) [[bug](https://github.com/dev-sec/ansible-os-hardening/labels/bug)] ([szEvEz](https://github.com/szEvEz))
- replace ignore_errors to failed_when to supress ugly error warnings [\#81](https://github.com/dev-sec/ansible-os-hardening/pull/81) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([fitz123](https://github.com/fitz123))
- replace ignore_errors to failed_when to suppress ugly error warnings [\#81](https://github.com/dev-sec/ansible-os-hardening/pull/81) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([fitz123](https://github.com/fitz123))
- fix bare variables usage for loops [\#79](https://github.com/dev-sec/ansible-os-hardening/pull/79) [[enhancement](https://github.com/dev-sec/ansible-os-hardening/labels/enhancement)] ([fitz123](https://github.com/fitz123))
[](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_custom_tests.yml)
Please refer to the examples in the readmes of the role.
@@ -68,8 +89,8 @@ See the [changelog](https://github.com/dev-sec/ansible-os-hardening/tree/master/
Todos:
- Work on [apache_hardening](roles/apache_hardening/) and [windows_hardening](roles/windows_hardening/).
- Add support for more operating systems,
- Work on [apache_hardening](roles/apache_hardening/) and [windows_hardening](roles/windows_hardening/)
- Add support for more operating systems
## More information
@@ -87,6 +108,6 @@ General information:
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
<http://www.apache.org/licenses/LICENSE-2.0>
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
justification:"ansible does not gather all fact-mounts (e.g. mounts with tmpfs) so we cannot change these. see https://github.com/ansible/ansible/pull/79787"
os-15:
run:false
justification:"ansible does not gather all fact-mounts (e.g. mounts with tmpfs) so we cannot change these. see https://github.com/ansible/ansible/pull/79787"
os-16:
run:false
justification:"ansible does not gather all fact-mounts (e.g. mounts with tmpfs) so we cannot change these. see https://github.com/ansible/ansible/pull/79787"
- add follow=yes to my.cnf protect task, incase its a symlink. fixes \#20 [\#21](https://github.com/dev-sec/ansible-mysql-hardening/pull/21) ([rndmh3ro](https://github.com/rndmh3ro))
- add follow=yes to my.cnf protect task, incase its a symlink. fixes \#20 [\#21](https://github.com/dev-sec/ansible-mysql-hardening/pull/21) ([rndmh3ro](https://github.com/rndmh3ro))
@@ -9,71 +9,135 @@ This role provides security configurations for MySQL and its derivates. It is in
It configures:
- Permissions for the various configuration files and folders
- Removes anonymous users, root-users without a password and test databases
- Removes anonymous users, users without a password or authentication_string and test databases
- various hardening options inside MySQL
Changes of options `log_error` or `datadir` in `mysql_hardening_options` will not be checked for correct permissions. Please change/set `log_error` or `datadir` with the installation role of MySQL before running this role, or you can run this role twice.
Further information is available at [Deutsche Telekom (German)](http://www.telekom.com/static/-/155996/7/technische-sicherheitsanforderungen-si) and [Symantec](http://www.symantec.com/connect/articles/securing-mysql-step-step)
## Requirements
- Ansible 2.9.0
- An existing MySQL installation
- An existing installation of MySQL or MariaDB.
- python-jmespath on the ansible host
### Example playbook
<!-- BEGIN_ANSIBLE_DOCS -->
```yml
- hosts: localhost
collections:
- devsec.hardening
roles:
- devsec.hardening.mysql_hardening
```
## Supported Operating Systems
This role expects an existing installation of MySQL or MariaDB. Please ensure that the following variables are set accordingly:
- `mysql_hardening_enabled: yes` role is enabled by default and can be disabled without removing it from a playbook. You can use conditional variable, for example: `mysql_hardening_enabled: "{{ true if mysql_enabled else false }}"`
- `mysql_hardening_user: 'mysql'` The user that mysql runs as.
- `mysql_datadir: '/var/lib/mysql'` The MySQL data directory
- `mysql_hardening_mysql_hardening_conf_file: '/etc/mysql/conf.d/hardening.cnf'` The path to the configuration file where the hardening will be performed
- EL
- 8, 9, 10
- Ubuntu
- focal, jammy, noble
- Debian
- trixie, bookworm, bullseye
- Amazon
- opensuse
## Role Variables
- `mysql_daemon_enabled`
- Default: `True`
- Description: Whether to enable the MySQL-service so it starts on boot
- Description: The default password. Please change or overwrite it
- Type: str
- Required: no
- `mysql_user_home`
- Default: `{{ ansible_env.HOME }}`
- Description: The path where the `.my.cnf` will be stored
- Type: str
- Required: no
Further information is available at [Deutsche Telekom (German)](http://www.telekom.com/static/-/155996/7/technische-sicherheitsanforderungen-si) and [Symantec](http://www.symantec.com/connect/articles/securing-mysql-step-step)
## Dependencies
None.
## Example Playbook
```
- hosts: all
become: true
roles:
- name: devsec.hardening.mysql_hardening
```
<!-- END_ANSIBLE_DOCS -->
Loaded 100 of 211 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.