CISOfy / lynis

Lynis - Security auditing tool for Linux, macOS, and UNIX-based systems. Assists with compliance testing (HIPAA/ISO27001/PCI DSS) and system hardening. Agentless, and installation optional.
https://cisofy.com/lynis/
GNU General Public License v3.0
13.5k stars 1.49k forks source link

CRYP-7931: missing detection of swap volume inside encrypted volume group #1419

Open SjoerdV opened 1 year ago

SjoerdV commented 1 year ago

Describe the bug Concerning test CRYP-7931. When a swap volume is inside a LUKS encrypted volume group, the test outputs 'Found 0 encrypted and 1 unencrypted swap devices in use.'

Version

Expected behavior I would expect the test to output 'Found 1 encrypted and 0 unencrypted swap devices in use.'

Output

Additional context relevant source code: https://github.com/CISOfy/lynis/blob/59a3c4b5368cdbd96ba7cdddf0dce5410b30163c/include/tests_crypto#L188 disk setup:

lsblk /dev/sda -o NAME,KNAME,FSTYPE,TYPE,MOUNTPOINT

NAME                 KNAME FSTYPE      TYPE  MOUNTPOINT
sda                  sda               disk  
├─sda1               sda1  vfat        part  /boot/efi
└─sda2               sda2  crypto_LUKS part  
  └─sda2_crypt       dm-0  LVM2_member crypt 
    ├─vg--1-lv--swap dm-1  swap        lvm   [SWAP]
    ├─vg--1-lv--root dm-2  ext4        lvm   /
    └─vg--1-lv--home dm-3  ext4        lvm   /home
SjoerdV commented 1 year ago

possible solution (just for inspiration):

extra check:

AfroThundr3007730 commented 1 year ago

Or for each discovered swap device, check to see if it's an LV, then check all PVs of that VG to see if they're LUKS devices.

This would not be completely robust for complex scenarios (nested PVs, etc.) but should cover most cases.