3.1.10 Lab Harden A Linux System Answer Key
3.1.10 Lab Harden A Linux System Answer Key
Objectives
Use a security auditing tool to discover system vulnerabilities.
Implement recommended solutions to harden the system.
Background / Scenario
Auditing a system for potential misconfigurations or unprotected services is an important aspect of system
hardening. Lynis is an open source security auditing tool with an automated set of scripts developed to test a
Linux system. Lynis performs an extensive health scan of your system. It includes a detailed report of
vulnerabilities and recommended actions. In this lab, you will use Lynis to scan your VM and then implement
solutions to harden your system.
Required Resources
PC with the CSE-LABVM installed in VirtualBox
Instructions
== Lynis ==
Version : 3.0.3
Status : Up-to-date
Release date : 2021-01-07
Project page : https://cisofy.com/lynis/
Source code : https://github.com/CISOfy/lynis
Latest package : https://packages.cisofy.com/
cisco@labvm:~/Downloads/lynis$
© 2021 - 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 7
Lab - Harden a Linux System
[ Lynis 3.0.3 ]
################################################################################
Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under the terms of the GNU General Public License.
See the LICENSE file for details about using this software.
<output omitted>
[+] Boot and services
------------------------------------
- Service Manager [ systemd ]
- Checking UEFI boot [ DISABLED ]
- Checking presence GRUB2 [ FOUND ]
<output omitted>
[+] Hardening
------------------------------------
- Installed compiler(s) [ FOUND ]
- Installed malware scanner [ NOT FOUND ]
- Non-native binary formats [ NOT FOUND ]
================================================================================
© 2021 - 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 7
Lab - Harden a Linux System
Warnings (2):
----------------------------
! Found one or more vulnerable packages. [PKGS-7392]
https://cisofy.com/lynis/controls/PKGS-7392/
Suggestions (51):
----------------------------
* Set a password on GRUB boot loader to prevent altering boot configuration (e.g.
boot in single user mode without password) [BOOT-5122]
https://cisofy.com/lynis/controls/BOOT-5122/
<output omitted>
================================================================================
Lynis 3.0.3
================================================================================
cisco@labvm:~/Downloads/lynis$
Step 4: Review the results of your scan and address any warnings.
a. Scroll to the Results section in the output for your scan.
Questions:
© 2021 - 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 7
Lab - Harden a Linux System
© 2021 - 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 7
Lab - Harden a Linux System
Answer Key
Step 1: Open a terminal window in the CSE-LABVM.
Step 4: Review the results of your scan and address any warnings,
How many Warnings did you receive?
Answers will vary. During testing for this lab, there were 2 warnings.
-[ Lynis 3.0.3 Results ]-
Warnings (2):
----------------------------
! Found one or more vulnerable packages. [PKGS-7392]
https://cisofy.com/lynis/controls/PKGS-7392/
© 2021 - 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 7
Lab - Harden a Linux System
Note: You may also need to update the Linux distro if you still get a waring. Run the "sudo apt-get
dist-upgrade" command to install the latest Linux version. You will need to reboot the system before
Lynis will give you a clean report for "vulnerable packages".
To address the second issue about iptables, begin your research by visiting the recommended link
for the warning, https://cisofy.com/lynis/controls/FIRE-4512/. Notice that it says to either disable the
firewall or populate it with an appropriate firewall. This must mean that iptables has something to do
with the VM's firewall. To research further, search for "ubuntu iptables howto". The first link in the
search engine results should take you directly to a page at help.ubuntu.com. If you read through the
page, you will discover that "Ubuntu comes with ufw - a program for managing the iptables…." This
page also has some recommended rules for a basic firewall. The following is a good start on a basic
firewall.
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -j DROP
sudo iptables-save
However, if you run the "sudo ./lynis --auditor cisco" command again, you will get the same warning.
You configured the rules but they are still not active. This is probably because the firewall is not
active. Scroll back to the top of the Ubuntu page and click the link for "ufw" or search for "ubuntu
ufw". The link will take you to a page that discusses Uncomplicated Firewall (ufw), which is the default
firewall configuration tool Ubuntu uses to manage iptables. Read through the page to learn more
about ufw. If you check the ufw status, you will see that it is inactive. Might this be why you are still
getting a warning from Lynis? Enable the firewall and then run Lynis again. Under Results, you
should now see the message, "Great, no warnings".
cisco@labvm:~/Downloads/lynis$ sudo ufw status
Status: inactive
cisco@labvm:~/Downloads/lynis$ sudo ufw enable
Firewall is active and enabled on system startup
cisco@labvm:~/Downloads/lynis$ sudo ./lynis --auditor cisco
<output omitted>
© 2021 - 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 7
Lab - Harden a Linux System
================================================================================
Great, no warnings
<output omitted>
cisco@labvm:~/Downloads/lynis$
End of document
© 2021 - 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 7 of 7