Commit Graph

154 Commits

Author SHA1 Message Date
chr0mag 353cf84413 [AUTH-9252] Sudo configuration file/folder check improvements (#637)
* [AUTH-9252] Adds support for files in sudoers.d

This commit adds permission checks for files found in 'sudoers.d'.
Previously only the main 'sudoers' file is checked. Fixes #600.

* [AUTH-9252] Check drop-in directory permissions

The test case currently only checks file permissions. This adds
logic to check the drop-in directory permissions as well.

* [AUTH-9252] Check file/folder ownership

This test currently only checks file/directory permissions. This
commit adds checks to ensure sudo configuration files/folders are
owned with UID=0 and GID=0.
2019-02-28 10:15:57 +01:00
Michael Boelen 66066ae226
Changed year and preparing for new release 2019-01-31 14:47:35 +01:00
Michael Boelen bca2d00ad7
Added STATUS_WEAK 2019-01-14 18:49:49 +01:00
Michael Boelen e014e12310
Remove FIND1 variable, as we prefer FIND to limit number of variables 2018-12-17 09:58:57 +01:00
Capashenn 47e37bf058 [AUTH-9282][AUTH-9283] Add support for RedHad and clones (#609)
[AUTH-9282][AUTH-9283] Add support for Red Hat and clones
2018-12-17 09:55:41 +01:00
Michael Boelen 105befb2e9
[AUTH-9308] Made 'sulogin' more generic for systemd rescue shell 2018-04-23 11:01:18 +02:00
Michael Boelen eb8b467915
Add TODO for PAM checks on AUTH-9286 2018-01-24 19:41:15 +01:00
Michael Boelen 66f8cb2441
Changed year 2018-01-11 09:50:26 +01:00
dataking 099c3b4468 fix for issue #453; simply add RPi/Raspian path to PAM_FILE_LOCATIONS (#475) 2017-10-19 11:33:09 +02:00
Michael Boelen 70ea29483a
Code enhancements 2017-04-23 20:06:54 +02:00
pyllyukko 88f39b9540 Fix regex to disregard locked accounts (#371)
This way, accounts that have ":!!:" in shadow and have an entry in
"Password expires" field don't get flagged with "Result: password of
user XYZ has been expired" by AUTH-9288.

Fixes #362
2017-03-27 09:19:55 +02:00
hlein 62d9a18861 A bunch of Solaris compatibility tweaks (#367)
* Work around Solaris' /bin/sh not being POSIX.

If /usr/xpg4/bin/sh is present, we are (definitely?) on Solaris or
a derivative, and /bin/sh cannot be trusted to support POSIX, but
/usr/xpg4/bin/sh can be.  Exec it right away.

* Work around Solaris 'which' command oddity.

Solaris' (at least) 'which' command outputs not-found errors to STDOUT
instead of STDERR.

This makes "did we get any output from which" checks insufficient;
piping to grep -v the "no foo in ..." message should work.

Note that this patch set includes all such uses of which that I could
find, including ones that should never be reached on Solaris (i.e. only
executed on some other OS) just for consistency.

* Improved alternate-sh exec to avoid looping.

* Solaris' /usr/ucb/echo supports -n.

* Check for the best hash type that openssl supports.

When using openssl to generate hashes, do not assume it supports
sha256; try that, then sha1, then give up and use md5.

* Solaris does not support sed -i; use a tempfile.

* Use the full path for modinfo.

When running as non-root, /usr/sbin/ might not be in PATH.
include/tests_accounting already calls modinfo by full path, but
include/tests_kernel did not.

* Solaris find does not support -maxdepth.

This mirrors the logic already in tests_homedirs.

* Use PSBINARY instead of ps.

* Work around Solaris' date not supporting +%s.

Printing nawk's srand value is a bizarre but apparently once popular
workaround for there being no normal userland command to print
UNIX epoch seconds.  A perl one-liner is the other common approach,
but nawk may be more reliably present on Solaris than perl.

* Revert to using sha1 for HOSTID.

* Whitespace cleanup for openssl hash tests.
2017-03-08 16:24:24 +00:00
hlein e054e9757c Lots of cleanups (#366)
* Description fix: SafePerms works on files not dirs.

All uses of SafePerms are on files (and indeed, it would reject
directories which would have +x set).

* Lots of whitespace cleanups.

Enforce everywhere(?) the same indentations for if/fi blocks.
The standard for the Lynis codebase is 4 spaces.  But sometimes
it's 1, sometimes 3, sometimes 8.

These patches standardize all(?) if blocks but _not_ else's (which
are usually indented 2, but sometimes zero); I was too lazy to
identify those (see below).

This diff is giant, but should not change code behavior at all;
diff -w shows no changes apart from whitespace.

FWIW I identified instances to check by using:

  perl -ne 'if ($oldfile ne $ARGV) { $.=1; $oldfile=$ARGV; }; chomp; if ($spaces) { next unless /^( *)([^ ]+)/; $newspaces=length($1); $firsttok = $2; next unless defined($firsttok); $offset = ($firsttok eq "elif" ? 0 : 4); if ($newspaces != $spaces + $offset) { print "$ARGV:$ifline\n$ARGV:$.:$_\n\n" }; $ifline=""; $spaces="";  } if (/^( *)if (?!.*[; ]fi)/) { $ifline = "$.:$_"; $spaces = length($1); }' $(find . -type f -print0 | xargs -0 file | egrep shell | cut -d: -f1)

Which produced output like:

  ./extras/build-lynis.sh:217:            if [ ${VERSION_IN_SPECFILE} = "" -o ! "${VERSION_IN_SPECFILE}" = "${LYNIS_VERSION}" ]; then
  ./extras/build-lynis.sh:218:               echo "[X] Version in specfile is outdated"

  ./plugins/plugin_pam_phase1:69:        if [ -d ${PAM_DIRECTORY} ]; then
  ./plugins/plugin_pam_phase1:70:                LogText "Result: /etc/pam.d exists"

...There's probably formal shellscript-beautification tools that
I'm oblivious about.

* More whitespace standardization.

* Fix a syntax error.

This looks like an if [ foo -o bar ]; was converted to if .. elif,
but incompletely.

* Add whitespace before closing ].

Without it, the shell thinks the ] is part of the last string, and
emits warnings like:

  .../lynis/include/tests_authentication: line 1028: [: missing `]'
2017-03-07 19:23:08 +00:00
Jean Prat a53cb004fa umask can be 0027 or 0077 (#364)
* umask can be 0027 or 0077

* Readme update
2017-03-06 14:41:11 +00:00
hlein b595cc0fb5 Various cleanups (#363)
* Typo fix.

* Style change: always use $(), never ``.

The Lynis code already mostly used $(), but backticks were sprinkled
around.  Converted all of them.

* Lots of minor spelling/typo fixes.

FWIW these were found with:

  find . -type f -print0 | xargs -0 cat | aspell list | sort -u | egrep '^[a-z]+$' | less

And then reviewing the list to pick out things that looked like
misspelled words as opposed to variables, etc., and then manual
inspection of context to determine the intention.
2017-03-06 07:41:21 +00:00
Michael Boelen 9cf25723e0 [AUTH-9308] Test for tilde in inittab for Debian systems 2017-02-28 20:18:47 +01:00
ryneeverett f5d70a6889 Match for sulogin fails to detect inittab entry (#356)
A valid inittab entry was missed. Gentoo delivers an inittab
containing su1:S:wait:/sbin/sulogin
2017-02-21 14:26:32 +00:00
Michael Boelen 0209c6ce90 [AUTH-9208] Remove double logging 2017-02-14 20:18:37 +01:00
Michael Boelen a7dd733dc0 Improve logging for group checks 2017-02-11 21:25:25 +01:00
Michael Boelen 34ba1ba184 Changed date and preparing for release 2017-02-09 13:35:40 +01:00
Zach Crownover 659d3e42c5 Improve DragonFly support (#329)
* Update facter location for BSDs

BSDs tend to place third party binaries in /usr/local rather than /usr

* Add support for DragonFly boot loader detection

DragonFly BSD has the same file paths for the bootloader as FreeBSD

* Add kernel module checking for DragonFly

DragonFly BSD checks kernel modules the same way as FreeBSD

* Add DragonFly check for login shells

DragonFly's login files are the same as FreeBSD's

* Add HAMMER PFS Detection

All PFS mounts in HAMMER systems for DragonFly will be detected now
2016-11-19 12:39:57 +00:00
Justin P 50b06efd30 macOS Refactoring (#311)
* Default all macOS `OS` names as macOS. Added comments to specify `uname` outputs for better understanding.

* Refactored all `Mac` instances referring to macOS over to `macOS` formatting.

Tested on my own machine, unable to find any errors outside of normal parameters.
2016-11-05 11:53:22 +01:00
Michael Boelen e4cc0b1b9b [AUTH-9234] reversed username and uid 2016-10-27 09:40:13 +02:00
Michael Boelen db0ebcd374 Improved logging 2016-10-27 09:21:56 +02:00
Michael Boelen 5488c6fc4b Missing exclamation mark 2016-10-27 09:19:37 +02:00
Michael Boelen 0d66aec62c [AUTH-9234] style and enhanced support for macOS 2016-10-27 09:13:57 +02:00
Michael Boelen ef7a120997 [AUTH-9234] support for macOS user gathering 2016-10-27 08:56:52 +02:00
Justin P e687b20866 Updates to include/tests_authentication (#308)
* adjusted.
For test number 9234, added comments stating macOS doesn’t use
/etc/passwd for normal users. macOS uses `opendirectoryd` as the
backend for user management. So, `dscacheutil` is the recommended
program to parse that information. I input a sample line as a comment
in the test area.

* Revert "adjusted."

This reverts commit 2166e5da94.

* Test 9208 and 9234 Updated

For test number 9208, the LogText was clumsily written. Text has been adjusted.
For test number 9234, added comments stating macOS doesn’t use `/etc/passwd` for normal users. macOS uses `opendirectoryd` as the backend for user management. So, `dscacheutil` is the recommended
program to parse that information. I input a sample line as a comment in the test area.

* Test 9208 and 9234 Updated

For test number 9208, the LogText was clumsily written. Text has been adjusted.

For test number 9234, added comments stating macOS doesn’t use `/etc/passwd` for normal users. macOS uses `opendirectoryd` as the backend for user management. So, `dscacheutil` is the recommended
program to parse that information. I input a sample line as a comment in the test area.
2016-10-27 08:46:23 +02:00
Michael Boelen 82ededed31 Style improvements and command replacements 2016-09-08 21:04:17 +02:00
Michael Boelen 8de53d87be Added missing dollar sign 2016-08-26 11:59:51 +02:00
Michael Boelen 679e8c628e Use detected binaries 2016-08-25 15:31:33 +02:00
Michael Boelen 2f4d65b831 Style changes 2016-08-25 15:25:51 +02:00
Michael Boelen dfb025a863 [AUTH-9204] style changes and add data to report 2016-08-25 15:18:44 +02:00
Michael Boelen f9b2993f35 Removed unneeded field 2016-08-10 07:24:10 +02:00
Michael Boelen 387df54859 Removed unneeded field for warnings and suggestions 2016-08-10 07:12:22 +02:00
Michael Boelen f434432954 [AUTH-9328] Test /etc/profile.d first for customizations of umask 2016-08-06 10:13:33 +02:00
Michael Boelen 290252b764 [AUTH-9212] Added prerequisite to log 2016-07-31 21:15:31 +02:00
Michael Boelen 5e2f6d256b Removed word 'checking' from several tests' and style improvements 2016-07-31 13:53:26 +02:00
Michael Boelen 6426ce68c0 [AUTH-9216] Simplified test and make it more efficient 2016-07-31 13:45:21 +02:00
Michael Boelen 2b4d7a1e85 [AUTH-9218] Clean ups and improve readability 2016-07-31 13:34:17 +02:00
Michael Boelen 23e400ea9e More style and text changes, and removed warning 2016-07-31 13:29:23 +02:00
Michael Boelen 1b3cdb9883 [AUTH-9226] Style, text, and removed warning 2016-07-31 13:25:35 +02:00
Michael Boelen aad8d89bf8 [AUTH-9228] Provide just an suggestion instead of warning 2016-07-31 13:23:09 +02:00
Michael Boelen d776c30b06 [AUTH-9406] - Readability and code style changes 2016-07-30 16:08:45 +02:00
Michael Boelen 0ec7f45f05 [AUTH-9268] Improve readability of test 2016-07-30 13:54:04 +02:00
Michael Boelen 2f4c854ba7 Rename of categories, introduction of groups 2016-07-24 17:22:00 +02:00
Michael Boelen 72ca2b926d [AUTH-9254] Only let root use this test, due to permissions 2016-07-05 12:10:32 +02:00
Michael Boelen c181a5745f [AUTH-9288] Only check for accounts which have a maximum password age set 2016-07-05 10:51:59 +02:00
Michael Boelen 114d95c475 [AUTH-9234] Test for minimal UID number via /etc/login.defs 2016-06-30 11:30:58 +02:00
Michael Boelen 983e293eb1 Replaced text strings to allow translations 2016-06-18 11:14:01 +02:00
mboelen 42607ceaf5 Replaced old function names with new ones 2016-04-28 12:31:57 +02:00
mboelen 9e312f5a5f Replaced functions and minor cleanups 2016-04-28 09:15:54 +02:00
mboelen 0e9b63a6ed Adjusted variable to properly check systemd directory 2016-03-24 17:28:53 +01:00
mboelen 0779005b46 [AUTH-9308] Skip testing some files when systemd is used 2016-03-24 17:16:14 +01:00
mboelen 0d2be381f9 [AUTH-9308] Test systemd targets 2016-03-24 16:46:54 +01:00
mboelen 45f6bcc601 Minor text changes 2016-03-24 11:11:40 +01:00
Eric Light fad4dfc0cc Modified AUTH-9262
Added pwquality (default in some Ubuntu variants) to accepted password-quality modules.  Reworked test so that full points are possible (passwdqc and cracklib incompatible).
2016-03-22 16:30:47 +13:00
mboelen b9dba2f3be Don't show umask exception, as it will trigger on Debian 8 2016-03-17 20:54:28 +01:00
mboelen 8cc47819b4 Removed copyright line, added description 2016-03-13 16:03:46 +01:00
mboelen 6197ac08e7 Added link to website, blog, github 2016-03-13 16:00:39 +01:00
mboelen 7f34f9dece AUTH-9288: ignore add include/tests_authentication 2016-03-08 12:01:11 +01:00
mboelen 09193d8ba9 Add support for FreeBSD to detect PAM files 2016-03-03 12:48:42 +01:00
pyllyukko 71aa47cbf4
Fix "/etc/inittab" -> "/etc/sysconfig/init" 2016-01-16 21:14:38 +02:00
mboelen 6bab259a5e [AUTH-9234] Gather users on AIX, and rewriting of tests 2016-01-11 01:31:08 +01:00
mboelen 6520400ca4 [AUTH-9288] New test to determine expired passwords 2015-12-22 16:00:51 +01:00
mboelen d16b38eff8 Rename of logtext and report functions, upcoming year change 2015-12-21 21:17:15 +01:00
mboelen 9451e633da [AUTH-9308] Test for respawn option on SUSE-based systems 2015-12-21 15:17:25 +01:00
Michael Boelen c96e9f079e Merge pull request #83 from alobodzinski/auth-openbsd
Authentication fixes for OpenBSD
2015-12-09 22:51:00 +01:00
mboelen 7b3299fcb9 Changes to AUTH-9286 to check for minimum age as well 2015-10-27 12:42:41 +01:00
Alexander Lobodzinski 34eb749636 Authentication fixes for OpenBSD 2015-10-16 11:24:23 +02:00
SiemKorteweg 0c48fc3880 Optimized use of cat, grep and awk.
Detection of duplicate entries in /etc/hosts is now more robust.
On CentOS7 the SERVICE_MANAGER is detected correctly.
2015-10-10 13:25:14 +02:00
SiemKorteweg b7d24c3413 Make sure that the input of "uniq -d" is sorted to avoid that duplicate UID's and hosts entries are missed. 2015-10-06 20:02:33 +02:00
mboelen 5dfb031e4d Removed bracket 2015-09-24 21:26:55 +02:00
mboelen 84821a4ed0 Removed [AUTH-9230] and merged it into [AUTH-9228] 2015-09-24 20:24:46 +02:00
mboelen 32226d145f Merged patch to properly log umask value 2015-09-16 17:03:13 +02:00
mboelen 91c9760598 Add hardening points properly to umask tests 2015-09-16 17:01:17 +02:00
Alexander Lobodzinski 37f9dcb8cc Bugfix for BSD: unrelated variable got logged instead of umask 2015-09-14 19:38:00 +02:00
mboelen 6fbe0e95c5 Changes to comments only 2015-09-12 15:19:21 +02:00
mboelen 78f32c2f28 Added screen output for /etc/login.conf 2015-09-10 21:46:23 +02:00
mboelen 7d0759297e Corrected case function 2015-09-10 21:42:30 +02:00
mboelen 21d305b689 Add support for testing umask value in /etc/login.conf like FreeBSD systems 2015-09-10 21:07:06 +02:00
mboelen 84baf688c8 Renumber test and search for explicit yes value, log status 2015-09-07 11:26:09 +02:00
Michael Boelen f471bf9d96 Merge pull request #70 from kboratynski/auth-9407
Wrote 'AUTH-9407' - logging failed login attempts.
2015-09-07 11:19:40 +02:00
mboelen 5165e57b86 Added report option to store logging status of failed logins 2015-09-07 11:17:38 +02:00
Kamil Boratyński 0e97f7936f Wrote 'AUTH-9407' - logging failed login attempts. 2015-09-07 04:12:58 +02:00
mboelen 401bf26c91 NIS improvement for test 2015-09-01 13:37:55 +02:00
mboelen 210ba41a3c Improved umask detection and logging 2015-08-20 18:46:06 +02:00
mboelen 66fb369593 Copyright line changes and cleanups 2015-07-22 16:28:11 +02:00
mboelen afaecd9512 Removing deprecated strings and cleaning up 2015-07-22 12:21:36 +02:00
mboelen 6857f01500 Added LDAP configuration file location to report, and code cleanups 2015-07-16 17:02:15 +02:00
mboelen 2f0e9f0981 Changed last line 2015-05-25 23:17:21 +02:00
mboelen 3bce5191ef Apply group check on all groups when using AIX 2015-04-16 19:00:03 +02:00
mboelen 6521ced36f Remove suggestion 2015-02-25 20:33:21 +01:00
mboelen ef531081bc Only show suggestion when shell does not exist [AUTH-9218] 2015-01-15 23:21:17 +01:00
mboelen 8efbb80497 Starting user ID 1000 for Linux systems 2014-12-05 20:08:10 +01:00
mboelen 3609da194a Properly parse PAM lines and add them to report [AUTH-9264] 2014-11-04 00:42:37 +01:00
mboelen ebe29bc148 Log discovered pam_modules to report 2014-10-06 11:29:31 +02:00
mboelen 2530256d85 Small textual replacements for logging purposes 2014-09-19 02:02:22 +02:00
mboelen a145b0091a Code cleanup 2014-09-19 00:35:24 +02:00
mboelen 1ed24265e3 Adjusted normal user ID detection and added exception for currently unsupported operating systems 2014-09-18 23:56:16 +02:00