kconfig-hardened-check.git
4 months agoImprove the hackish refinement of the CONFIG_ARCH_MMAP_RND_BITS check
Alexander Popov [Sat, 30 Dec 2023 18:30:14 +0000 (21:30 +0300)]
Improve the hackish refinement of the CONFIG_ARCH_MMAP_RND_BITS check

Don't check CONFIG_ARCH_MMAP_RND_BITS if CONFIG_ARCH_MMAP_RND_BITS_MAX
was not found.

4 months agoShow the option type in print_unknown_options()
Alexander Popov [Sat, 30 Dec 2023 18:22:00 +0000 (21:22 +0300)]
Show the option type in print_unknown_options()

That improves debugging.

4 months agoUse raw strings for regular expression
Alexander Popov [Sat, 30 Dec 2023 18:15:37 +0000 (21:15 +0300)]
Use raw strings for regular expression

4 months agoFix the 'decision' for the 'AIO' check
Alexander Popov [Sat, 30 Dec 2023 16:52:01 +0000 (19:52 +0300)]
Fix the 'decision' for the 'AIO' check

4 months agoFix the 'decision' for the 'vdso32' check
Alexander Popov [Fri, 29 Dec 2023 08:22:06 +0000 (11:22 +0300)]
Fix the 'decision' for the 'vdso32' check

4 months agoImprove the comment for the 'slab_common.usercopy_fallback' check
Alexander Popov [Fri, 29 Dec 2023 08:21:17 +0000 (11:21 +0300)]
Improve the comment for the 'slab_common.usercopy_fallback' check

4 months agoFix the arch condition for the SCHED_CORE check (III)
Alexander Popov [Thu, 28 Dec 2023 13:20:47 +0000 (16:20 +0300)]
Fix the arch condition for the SCHED_CORE check (III)

SCHED_CORE is finally available for ARM64 and ARM.

SCHED_SMT was needed for that.

4 months agoUpdate the KSPP recommendations
Alexander Popov [Thu, 28 Dec 2023 12:30:56 +0000 (15:30 +0300)]
Update the KSPP recommendations

4 months agoFix the arch for the CPU_SRSO check (it's available only for x86_64)
Alexander Popov [Thu, 28 Dec 2023 11:58:11 +0000 (14:58 +0300)]
Fix the arch for the CPU_SRSO check (it's available only for x86_64)

4 months agoSplit the HW_RANDOM_TPM check (it's enabled by default on ARM and ARM64)
Alexander Popov [Thu, 28 Dec 2023 11:41:09 +0000 (14:41 +0300)]
Split the HW_RANDOM_TPM check (it's enabled by default on ARM and ARM64)

4 months agoChange the 'decision' of the INIT_STACK_ALL_ZERO check
Alexander Popov [Thu, 28 Dec 2023 11:33:10 +0000 (14:33 +0300)]
Change the 'decision' of the INIT_STACK_ALL_ZERO check

5 months agoAdd defconfigs for Linux v6.6
Alexander Popov [Sun, 17 Dec 2023 23:51:58 +0000 (02:51 +0300)]
Add defconfigs for Linux v6.6

5 months agoAdd the RANDOM_KMALLOC_CACHES check
Alexander Popov [Sat, 16 Dec 2023 23:41:40 +0000 (02:41 +0300)]
Add the RANDOM_KMALLOC_CACHES check

Refers to #83

5 months agoAdd the SECURITY_SELINUX_DEBUG check
Alexander Popov [Sat, 16 Dec 2023 23:11:53 +0000 (02:11 +0300)]
Add the SECURITY_SELINUX_DEBUG check

5 months agoFix the 'decision' for the LEGACY_TIOCSTI check
Alexander Popov [Sat, 16 Dec 2023 22:53:50 +0000 (01:53 +0300)]
Fix the 'decision' for the LEGACY_TIOCSTI check

5 months agoAdd the CONFIG_LIST_HARDENED check
Alexander Popov [Sat, 16 Dec 2023 21:21:10 +0000 (00:21 +0300)]
Add the CONFIG_LIST_HARDENED check

5 months agoAdd the gather_data_sampling check
Alexander Popov [Sat, 9 Dec 2023 19:25:38 +0000 (22:25 +0300)]
Add the gather_data_sampling check

5 months agoAdd the CPU_SRSO check
Alexander Popov [Sat, 9 Dec 2023 19:10:32 +0000 (22:10 +0300)]
Add the CPU_SRSO check

5 months agoAdd the SPECULATION_MITIGATIONS check
Alexander Popov [Sat, 9 Dec 2023 19:06:13 +0000 (22:06 +0300)]
Add the SPECULATION_MITIGATIONS check

5 months agoAdd the spec_rstack_overflow check
Alexander Popov [Sat, 9 Dec 2023 18:57:13 +0000 (21:57 +0300)]
Add the spec_rstack_overflow check

5 months agoAdd the MODULE_FORCE_LOAD check
Alexander Popov [Sat, 9 Dec 2023 05:47:55 +0000 (08:47 +0300)]
Add the MODULE_FORCE_LOAD check

Thanks to @vobst for the idea

5 months agoUpdate the README
Alexander Popov [Sat, 2 Dec 2023 19:21:13 +0000 (22:21 +0300)]
Update the README

5 months agoAdd the check for dis_ucode_ldr
Alexander Popov [Sat, 2 Dec 2023 17:46:14 +0000 (20:46 +0300)]
Add the check for dis_ucode_ldr

Thanks to @izh1979 for the idea

5 months agoAdd the MICROCODE_INTEL and MICROCODE_AMD checks
Alexander Popov [Sat, 2 Dec 2023 17:33:56 +0000 (20:33 +0300)]
Add the MICROCODE_INTEL and MICROCODE_AMD checks

Thanks to @izh1979 for the idea

5 months agoAdd a check for the 'kfence.sample_interval' boot parameter
Alexander Popov [Sat, 2 Dec 2023 10:49:42 +0000 (13:49 +0300)]
Add a check for the 'kfence.sample_interval' boot parameter

Thanks to @izh1979 for the idea

5 months agoAdd the KFENCE_SAMPLE_INTERVAL check
Alexander Popov [Sat, 2 Dec 2023 10:04:30 +0000 (13:04 +0300)]
Add the KFENCE_SAMPLE_INTERVAL check

Thanks to @izh1979 for the idea

5 months agoKeep the recommendation to disable kernel modules
Alexander Popov [Sat, 2 Dec 2023 06:28:13 +0000 (09:28 +0300)]
Keep the recommendation to disable kernel modules

Disabling kernel modules is a radical method to cut the kernel attack
surface. It may be useful for some systems.

Quoting CLIP OS recommendation:
```
Disable module loading once systemd has loaded the ones required for the
running machine according to a profile.
```

5 months agoAdd a comment about 'kernel.modules_disabled'
Alexander Popov [Sat, 11 Nov 2023 15:13:19 +0000 (18:13 +0300)]
Add a comment about 'kernel.modules_disabled'

5 months agoadd --kernel-version option (#94)
Alexander Popov [Sat, 2 Dec 2023 06:11:44 +0000 (09:11 +0300)]
add --kernel-version option (#94)

5 months agoadd --kernel-version option 94/head
Fabrice Fontaine [Wed, 29 Nov 2023 16:37:58 +0000 (17:37 +0100)]
add --kernel-version option

--kernel-version option will extract the version in /proc/version.
This is especially useful on embedded systems where config.gz doesn't
always contain the kernel version

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
7 months agoFix the reason for the 'kernel.yama.ptrace_scope' check
Alexander Popov [Wed, 18 Oct 2023 07:30:36 +0000 (10:30 +0300)]
Fix the reason for the 'kernel.yama.ptrace_scope' check

7 months agoAdd kspp-recommendations/kspp-sysctl.txt
Alexander Popov [Tue, 17 Oct 2023 20:34:14 +0000 (23:34 +0300)]
Add kspp-recommendations/kspp-sysctl.txt

7 months agoFix the reason for the nosmt check
Alexander Popov [Tue, 17 Oct 2023 20:23:31 +0000 (23:23 +0300)]
Fix the reason for the nosmt check

Use 'cut_attack_surface'.

7 months agoUpdate kspp-cmdline-x86-64.txt
Alexander Popov [Tue, 17 Oct 2023 19:57:18 +0000 (22:57 +0300)]
Update kspp-cmdline-x86-64.txt

7 months agoAdd the 'dev.tty.legacy_tiocsti' check
Alexander Popov [Tue, 17 Oct 2023 17:19:05 +0000 (20:19 +0300)]
Add the 'dev.tty.legacy_tiocsti' check

7 months agoAdd the 'kernel.randomize_va_space' check
Alexander Popov [Tue, 17 Oct 2023 16:27:37 +0000 (19:27 +0300)]
Add the 'kernel.randomize_va_space' check

7 months agoAdd the 'fs.suid_dumpable' check
Alexander Popov [Tue, 17 Oct 2023 16:24:25 +0000 (19:24 +0300)]
Add the 'fs.suid_dumpable' check

7 months agoChange the reason of the COREDUMP check
Alexander Popov [Tue, 17 Oct 2023 16:23:00 +0000 (19:23 +0300)]
Change the reason of the COREDUMP check

7 months agoAdd the 'fs.protected_regular' check
Alexander Popov [Tue, 17 Oct 2023 16:20:08 +0000 (19:20 +0300)]
Add the 'fs.protected_regular' check

7 months agoAdd the 'fs.protected_fifos' check
Alexander Popov [Tue, 17 Oct 2023 16:19:06 +0000 (19:19 +0300)]
Add the 'fs.protected_fifos' check

7 months agoAdd the 'fs.protected_hardlinks' check
Alexander Popov [Tue, 17 Oct 2023 16:07:41 +0000 (19:07 +0300)]
Add the 'fs.protected_hardlinks' check

7 months agoAdd the 'fs.protected_symlinks' check
Alexander Popov [Tue, 17 Oct 2023 16:07:00 +0000 (19:07 +0300)]
Add the 'fs.protected_symlinks' check

7 months agoAdd the 'vm.unprivileged_userfaultfd' check
Alexander Popov [Tue, 17 Oct 2023 16:02:39 +0000 (19:02 +0300)]
Add the 'vm.unprivileged_userfaultfd' check

7 months agoAdd the 'kernel.yama.ptrace_scope' check
Alexander Popov [Tue, 17 Oct 2023 15:53:32 +0000 (18:53 +0300)]
Add the 'kernel.yama.ptrace_scope' check

7 months agoAdd the 'kernel.kptr_restrict' check
Alexander Popov [Tue, 17 Oct 2023 15:52:57 +0000 (18:52 +0300)]
Add the 'kernel.kptr_restrict' check

7 months agoImprove the slab_common.usercopy_fallback check
Alexander Popov [Tue, 17 Oct 2023 05:38:51 +0000 (08:38 +0300)]
Improve the slab_common.usercopy_fallback check

Don't require slab_common.usercopy_fallback=0,
since HARDENED_USERCOPY_FALLBACK was removed in Linux v5.16

7 months agohardened_usercopy=1 is now officially recommended by KSPP
Alexander Popov [Tue, 17 Oct 2023 05:35:00 +0000 (08:35 +0300)]
hardened_usercopy=1 is now officially recommended by KSPP

7 months agoEnabling page_alloc.shuffle is now recommended by KSPP
Alexander Popov [Mon, 16 Oct 2023 20:40:15 +0000 (23:40 +0300)]
Enabling page_alloc.shuffle is now recommended by KSPP

7 months ago'mitigations=auto,nosmt' is now recommended by KSPP
Alexander Popov [Mon, 16 Oct 2023 20:22:59 +0000 (23:22 +0300)]
'mitigations=auto,nosmt' is now recommended by KSPP

7 months agoDisabling X86_VSYSCALL_EMULATION is now recommended by KSPP
Alexander Popov [Mon, 16 Oct 2023 05:13:29 +0000 (08:13 +0300)]
Disabling X86_VSYSCALL_EMULATION is now recommended by KSPP

7 months agoUse /usr/bin/env in shebangs (#90)
Alexander Popov [Mon, 16 Oct 2023 04:31:36 +0000 (07:31 +0300)]
Use /usr/bin/env in shebangs (#90)

Thanks, @SuperSandro2000

7 months agoUse /usr/bin/env in shebangs 90/head
Sandro Jäckel [Thu, 5 Oct 2023 22:41:00 +0000 (00:41 +0200)]
Use /usr/bin/env in shebangs

This is guaranteed to work everything including NixOS

7 months agoDrop ZERO_CALL_USED_REGS in favour of backward-edge CFI
Alexander Popov [Wed, 4 Oct 2023 18:21:21 +0000 (21:21 +0300)]
Drop ZERO_CALL_USED_REGS in favour of backward-edge CFI

This option isn't worth the performance impact.

Refers to #82.

7 months agoUpdate the README
Alexander Popov [Mon, 18 Sep 2023 20:56:21 +0000 (23:56 +0300)]
Update the README

7 months agoRefactor the assertion in colorize_result() to improve test coverage
Alexander Popov [Mon, 18 Sep 2023 05:58:44 +0000 (08:58 +0300)]
Refactor the assertion in colorize_result() to improve test coverage

8 months agoUpdate the backup in issues.md
Alexander Popov [Sun, 17 Sep 2023 22:56:10 +0000 (01:56 +0300)]
Update the backup in issues.md

8 months agoRename kconfig-hardened-check into kernel-hardening-checker (#85)
Alexander Popov [Sun, 17 Sep 2023 22:29:39 +0000 (01:29 +0300)]
Rename kconfig-hardened-check into kernel-hardening-checker (#85)

**kconfig-hardened-check** is a tool for checking the security hardening
options of the Linux kernel.

In addition to Kconfig options, it now can check kernel cmdline
arguments and sysctl parameters.

It's time to give this project a new name that describes it better:
**kernel-hardening-checker**.

8 months agoRenaming fixes renaming 85/head
Alexander Popov [Sun, 10 Sep 2023 11:45:03 +0000 (14:45 +0300)]
Renaming fixes

8 months agoDrop default.nix (it contains a wrong utility name anyway)
Alexander Popov [Sat, 9 Sep 2023 20:19:46 +0000 (23:19 +0300)]
Drop default.nix (it contains a wrong utility name anyway)

8 months agokconfig-hardened-check -> kernel-hardening-checker
Alexander Popov [Sat, 9 Sep 2023 20:18:12 +0000 (23:18 +0300)]
kconfig-hardened-check -> kernel-hardening-checker

8 months agotest_engine: add test_complex_nested()
Alexander Popov [Sun, 17 Sep 2023 16:46:18 +0000 (19:46 +0300)]
test_engine: add test_complex_nested()

AND(AND()), OR(OR()) are not supported intentionally.

8 months agotest_engine: improve the output
Alexander Popov [Sun, 17 Sep 2023 16:42:47 +0000 (19:42 +0300)]
test_engine: improve the output

8 months agotest_engine: improve the test_stdout()
Alexander Popov [Sat, 16 Sep 2023 18:26:33 +0000 (21:26 +0300)]
test_engine: improve the test_stdout()

(The nested AND/OR should be tested separately, stay tuned)

8 months agotest_engine: refactor test_complex_or() and test_complex_and()
Alexander Popov [Thu, 14 Sep 2023 21:31:52 +0000 (00:31 +0300)]
test_engine: refactor test_complex_or() and test_complex_and()

8 months agoDon't remove ANSI colors, adapt the testcases instead
Alexander Popov [Wed, 13 Sep 2023 22:07:47 +0000 (01:07 +0300)]
Don't remove ANSI colors, adapt the testcases instead

This rewrites the commit aa7e1bffebde9d4f1855df93819cea75a5bc4c79.

Refers to #86.

8 months agoAdd colors to output (#86)
Alexander Popov [Wed, 13 Sep 2023 22:06:19 +0000 (01:06 +0300)]
Add colors to output (#86)

Shows OK in green and FAIL in red

Thanks to @frakman1.

Refers to #81. Needs fixing `test_stdout()` in the unit-test.

8 months agoAdjust test scripts to scrub ANSI colors from output 86/head
Frak [Tue, 12 Sep 2023 15:47:28 +0000 (11:47 -0400)]
Adjust test scripts to scrub ANSI colors from output

8 months agoFix pylints and verbose/None case
Frak [Mon, 11 Sep 2023 22:46:50 +0000 (18:46 -0400)]
Fix pylints and verbose/None case

8 months agofix typo
Frak [Sun, 10 Sep 2023 20:29:51 +0000 (16:29 -0400)]
fix typo

8 months agocleanup spaces
Frak [Sun, 10 Sep 2023 17:40:59 +0000 (13:40 -0400)]
cleanup spaces

8 months agocleanup
Frak [Sat, 9 Sep 2023 21:17:54 +0000 (17:17 -0400)]
cleanup

8 months agore-factoring
Frak [Sat, 9 Sep 2023 21:09:18 +0000 (17:09 -0400)]
re-factoring

8 months agoAdd colors for OK and FAIL cases
Frak [Sat, 9 Sep 2023 18:18:39 +0000 (14:18 -0400)]
Add colors for OK and FAIL cases

8 months agoFix arch conditions for some CmdlineChecks
Alexander Popov [Sun, 3 Sep 2023 20:41:26 +0000 (23:41 +0300)]
Fix arch conditions for some CmdlineChecks

By the way, don't add `if arch` for checks that require 'is not set'
(there is nothing wrong with that).

8 months agoMake the functional tests more informative
Alexander Popov [Mon, 28 Aug 2023 11:26:17 +0000 (14:26 +0300)]
Make the functional tests more informative

Drop `> /dev/null` for non-verbose output of the tool.

8 months agoTest more wrong combinations of options
Alexander Popov [Mon, 28 Aug 2023 11:20:13 +0000 (14:20 +0300)]
Test more wrong combinations of options

8 months agoTest checking sysctl separately
Alexander Popov [Mon, 28 Aug 2023 11:02:00 +0000 (14:02 +0300)]
Test checking sysctl separately

8 months agoSupport separate sysctl checking (without kconfig)
Alexander Popov [Sun, 27 Aug 2023 20:31:55 +0000 (23:31 +0300)]
Support separate sysctl checking (without kconfig)

9 months agoImprove coverage of the functional test a bit
Alexander Popov [Mon, 14 Aug 2023 20:47:09 +0000 (23:47 +0300)]
Improve coverage of the functional test a bit

9 months agoClean .gitignore
Alexander Popov [Mon, 14 Aug 2023 18:48:07 +0000 (21:48 +0300)]
Clean .gitignore

9 months agoShow git information in the functional test
Alexander Popov [Mon, 14 Aug 2023 16:42:15 +0000 (19:42 +0300)]
Show git information in the functional test

9 months agoTest an invalid sysctl file
Alexander Popov [Mon, 14 Aug 2023 15:56:39 +0000 (18:56 +0300)]
Test an invalid sysctl file

9 months agoTest an unexpected line in the sysctl file
Alexander Popov [Mon, 14 Aug 2023 15:56:13 +0000 (18:56 +0300)]
Test an unexpected line in the sysctl file

9 months agoTest an unexpected line in the Kconfig file
Alexander Popov [Mon, 14 Aug 2023 15:53:25 +0000 (18:53 +0300)]
Test an unexpected line in the Kconfig file

9 months agoDrop `if __name__ == "__main__"` from ./bin/kconfig-hardened-check
Alexander Popov [Mon, 14 Aug 2023 15:39:18 +0000 (18:39 +0300)]
Drop `if __name__ == "__main__"` from ./bin/kconfig-hardened-check

It always runs as a main program.

9 months agoTurn the warning about unexpected line in Kconfig file into an error
Alexander Popov [Mon, 14 Aug 2023 13:02:21 +0000 (16:02 +0300)]
Turn the warning about unexpected line in Kconfig file into an error

9 months agoUpdate the README (add the --sysctl mode)
Alexander Popov [Mon, 14 Aug 2023 12:22:34 +0000 (15:22 +0300)]
Update the README (add the --sysctl mode)

9 months agoAdd the Kconfig file of Fedora 38
Alexander Popov [Sun, 13 Aug 2023 21:22:57 +0000 (00:22 +0300)]
Add the Kconfig file of Fedora 38

9 months agoUse example_sysctls.txt in the functional test
Alexander Popov [Sun, 13 Aug 2023 21:08:22 +0000 (00:08 +0300)]
Use example_sysctls.txt in the functional test

This file was made with root privileges, so it has a full list of sysctls.

9 months agoAdd an example sysctl output file
Alexander Popov [Sun, 13 Aug 2023 20:59:26 +0000 (23:59 +0300)]
Add an example sysctl output file

9 months agoAdd the / symbol to the sysctl parsing pattern
Alexander Popov [Sun, 13 Aug 2023 19:39:11 +0000 (22:39 +0300)]
Add the / symbol to the sysctl parsing pattern

The GitHub Actions virtual machine has such a sysctl:
  fs.binfmt_misc.llvm-14-runtime/binfmt = enabled

This example shows that sysctl names may contain the / symbol.

9 months agoAdd --sysctl to functional testing
Alexander Popov [Sun, 13 Aug 2023 17:37:28 +0000 (20:37 +0300)]
Add --sysctl to functional testing

Refers to #65

9 months agoImprove checking the combinations of flags in the functional test
Alexander Popov [Sun, 13 Aug 2023 17:04:32 +0000 (20:04 +0300)]
Improve checking the combinations of flags in the functional test

9 months agoFix syntax to run on the Woodpecker 1.0.0 CI (part II)
Alexander Popov [Sun, 13 Aug 2023 16:54:42 +0000 (19:54 +0300)]
Fix syntax to run on the Woodpecker 1.0.0 CI (part II)

9 months agoFix syntax to run on the Woodpecker 1.0.0 CI
Alexander Popov [Sun, 13 Aug 2023 16:50:42 +0000 (19:50 +0300)]
Fix syntax to run on the Woodpecker 1.0.0 CI

9 months agoReport that --print and --generate can't be used together
Alexander Popov [Sun, 13 Aug 2023 16:49:08 +0000 (19:49 +0300)]
Report that --print and --generate can't be used together

9 months agoEnable sysctl checking
Alexander Popov [Sun, 13 Aug 2023 16:28:05 +0000 (19:28 +0300)]
Enable sysctl checking

Refers to #65

9 months agoCheck the kernel.unprivileged_bpf_disabled sysctl
Alexander Popov [Sun, 23 Jul 2023 21:24:36 +0000 (00:24 +0300)]
Check the kernel.unprivileged_bpf_disabled sysctl

9 months agoCheck the dev.tty.ldisc_autoload sysctl
Alexander Popov [Sun, 23 Jul 2023 21:24:06 +0000 (00:24 +0300)]
Check the dev.tty.ldisc_autoload sysctl

9 months agoCheck the user.max_user_namespaces sysctl
Alexander Popov [Sun, 23 Jul 2023 21:23:38 +0000 (00:23 +0300)]
Check the user.max_user_namespaces sysctl