forked from mondoohq/cnspec-policies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mondoo-linux-security.mql.yaml
3121 lines (2627 loc) · 138 KB
/
mondoo-linux-security.mql.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (c) Mondoo, Inc.
# SPDX-License-Identifier: BUSL-1.1
policies:
- uid: mondoo-linux-security
name: Linux Security
version: 2.4.1
license: BUSL-1.1
tags:
mondoo.com/category: security
mondoo.com/platform: linux
authors:
- name: Mondoo, Inc
email: [email protected]
docs:
desc: |-
## Overview
The Linux Security by Mondoo provides guidance for establishing a secure baseline configuration for Linux systems running on x86 and x64 platforms.
This policy includes queries to help harden Linux systems by:
- Identifying problematic services that may be running
- Identifying loose permissions on sensitive system configuration files
- Ensuring logging and auditing services are properly configured and running
- Hardening SSH configurations
- Ensure users and groups are securely configured
- Identifying misconfigured Kernel networking configurations
This policy has been developed for Red Hat (RHEL), Debian, Ubuntu, and SUSE (SLES) derivative distributions running on x86 and x64 architectures.
Some queries may be skipped depending on your particular distribution, installation type, or underlying infrastructure.
The overall guidance within this policy broadly assumes that operations are being performed as the root user.
Operations performed using sudo instead of the root user may produce unexpected results or fail to make the intended changes to the system.
Non-root users may not be able to access certain areas of the system, especially after remediation has been performed. It is advisable to verify
root users path integrity and the integrity of any programs being run prior to execution of commands and scripts included in this benchmark.
### Intended Audience
This benchmark is intended for system and application administrators, security specialists, auditors, help desk, and platform deployment personnel
who plan to develop, deploy, assess, or secure solutions that incorporate Linux on x86 or x64 platforms.
## Local scan
Local scan refer to scans of files and operating systems where cnspec is installed.
To scan the `localhost` against this policy:
```bash
cnspec scan local
```
## Remote scan
Remote scans use cnspec providers to retrieve on-demand scan results without having to install any agents.
For a complete list of providers run:
```bash
cnspec scan --help
```
### Prerequisites
Remote scans of Linux hosts requires authentication such as SSH keys.
### Scan a remote Linux host (SSH authentication)
```bash
cnspec scan ssh <user>@<IP_ADDRESS> -i /path/to/ssh_key
```
## Join the community!
Our goal is to build policies that are simple to deploy, accurate, and actionable.
If you have any suggestions for how to improve this policy, or if you need support, [join the community](https://github.com/orgs/mondoohq/discussions) in GitHub Discussions.
groups:
- title: Core
filters: |
asset.family.contains('linux')
checks:
- uid: mondoo-linux-security--window-system-is-not-installed
- uid: mondoo-linux-security-address-space-layout-randomization-aslr-is-enabled
- uid: mondoo-linux-security-aide-is-installed
- uid: mondoo-linux-security-avahi-server-is-not-enabled
- uid: mondoo-linux-security-bogus-icmp-responses-are-ignored
- uid: mondoo-linux-security-broadcast-icmp-requests-are-ignored
- uid: mondoo-linux-security-core-dumps-are-restricted
- uid: mondoo-linux-security-cups-is-not-enabled
- uid: mondoo-linux-security-dhcp-server-is-not-enabled
- uid: mondoo-linux-security-dns-server-is-not-enabled
- uid: mondoo-linux-security-filesystem-integrity-is-regularly-checked
- uid: mondoo-linux-security-ftp-server-is-not-enabled
- uid: mondoo-linux-security-http-proxy-server-is-not-enabled
- uid: mondoo-linux-security-http-server-is-not-enabled
- uid: mondoo-linux-security-icmp-redirects-are-not-accepted
- uid: mondoo-linux-security-imap-and-pop3-server-is-not-enabled
- uid: mondoo-linux-security-ip-forwarding-is-disabled
- uid: mondoo-linux-security-ipv6-router-advertisements-are-not-accepted
- uid: mondoo-linux-security-ldap-server-is-not-enabled
- uid: mondoo-linux-security-mail-transfer-agent-is-configured-for-local-only-mode
- uid: mondoo-linux-security-nfs-and-rpc-are-not-enabled
- uid: mondoo-linux-security-nis-server-is-not-enabled
- uid: mondoo-linux-security-packet-redirect-sending-is-disabled
- uid: mondoo-linux-security-permissions-on-etcgroup--are-configured
- uid: mondoo-linux-security-permissions-on-etcgroup-are-configured
- uid: mondoo-linux-security-permissions-on-etcgshadow--are-configured
- uid: mondoo-linux-security-permissions-on-etcgshadow-are-configured
- uid: mondoo-linux-security-permissions-on-etcpasswd--are-configured
- uid: mondoo-linux-security-permissions-on-etcpasswd-are-configured
- uid: mondoo-linux-security-permissions-on-etcshadow--are-configured
- uid: mondoo-linux-security-permissions-on-etcshadow-are-configured
- uid: mondoo-linux-security-prelink-is-disabled
- uid: mondoo-linux-security-reverse-path-filtering-is-enabled
- uid: mondoo-linux-security-rsh-server-is-not-enabled
- uid: mondoo-linux-security-rsync-service-is-not-enabled
- uid: mondoo-linux-security-samba-is-not-enabled
- uid: mondoo-linux-security-secure-icmp-redirects-are-not-accepted
- uid: mondoo-linux-security-snmp-server-is-not-enabled
- uid: mondoo-linux-security-source-routed-packets-are-not-accepted
- uid: mondoo-linux-security-suspicious-packets-are-logged
- uid: mondoo-linux-security-talk-server-is-not-enabled
- uid: mondoo-linux-security-tcp-syn-cookies-is-enabled
- uid: mondoo-linux-security-telnet-server-is-not-enabled
- uid: mondoo-linux-security-tftp-server-is-not-enabled
- title: Configure SSH Server
filters: |
asset.family.contains('linux')
package('openssh-server').installed
checks:
- uid: mondoo-linux-security-only-strong-ciphers-are-used
- uid: mondoo-linux-security-only-strong-kex-algorithms-are-used
- uid: mondoo-linux-security-only-strong-mac-algorithms-are-used
- uid: mondoo-linux-security-permissions-on-etcsshsshd-config-are-configured
- uid: mondoo-linux-security-permissions-on-ssh-private-host-key-files-are-configured
- uid: mondoo-linux-security-permissions-on-ssh-public-host-key-files-are-configured
- uid: mondoo-linux-security-ssh-access-is-limited
- uid: mondoo-linux-security-ssh-hostbasedauthentication-is-disabled
- uid: mondoo-linux-security-ssh-idle-timeout-interval-is-configured
- uid: mondoo-linux-security-ssh-ignorerhosts-is-enabled
- uid: mondoo-linux-security-ssh-logingracetime-is-set-to-one-minute-or-less
- uid: mondoo-linux-security-ssh-loglevel-is-appropriate
- uid: mondoo-linux-security-ssh-maxauthtries-is-set-to-4-or-less
- uid: mondoo-linux-security-ssh-permitemptypasswords-is-disabled
- uid: mondoo-linux-security-ssh-permituserenvironment-is-disabled
- uid: mondoo-linux-security-ssh-protocol-is-set-to-2
- uid: mondoo-linux-security-ssh-root-login-is-disabled
- uid: mondoo-linux-security-ssh-warning-banner-is-configured
- uid: mondoo-linux-security-ssh-x11-forwarding-is-disabled
- title: Logging
filters: |
asset.family.contains('linux')
asset.kind != "container-image"
checks:
- uid: mondoo-linux-security-audit-log-storage-size-is-configured
- uid: mondoo-linux-security-audit-logs-are-not-automatically-deleted
- uid: mondoo-linux-security-auditd-is-installed
- uid: mondoo-linux-security-auditd-service-is-enabled
- uid: mondoo-linux-security-auditing-for-processes-that-start-prior-to-auditd-is-enabled
- uid: mondoo-linux-security-changes-to-system-administration-scope-sudoers-is-collected
- uid: mondoo-linux-security-discretionary-access-control-permission-modification-events-are-collected
- uid: mondoo-linux-security-events-that-modify-date-and-time-information-are-collected
- uid: mondoo-linux-security-events-that-modify-the-systems-mandatory-access-controls-are-collected
- uid: mondoo-linux-security-events-that-modify-the-systems-network-environment-are-collected
- uid: mondoo-linux-security-events-that-modify-usergroup-information-are-collected
- uid: mondoo-linux-security-file-deletion-events-by-users-are-collected
- uid: mondoo-linux-security-journald-is-configured-to-compress-large-log-files
- uid: mondoo-linux-security-journald-is-configured-to-send-logs-to-rsyslog
- uid: mondoo-linux-security-journald-is-configured-to-write-logfiles-to-persistent-disk
- uid: mondoo-linux-security-kernel-module-loading-and-unloading-is-collected
- uid: mondoo-linux-security-login-and-logout-events-are-collected
- uid: mondoo-linux-security-permissions-on-all-logfiles-are-configured
- uid: mondoo-linux-security-rsyslog-default-file-permissions-configured
- uid: mondoo-linux-security-rsyslog-is-installed
- uid: mondoo-linux-security-rsyslog-service-is-enabled
- uid: mondoo-linux-security-session-initiation-information-is-collected
- uid: mondoo-linux-security-successful-file-system-mounts-are-collected
- uid: mondoo-linux-security-sudo-logging-is-enabled
- uid: mondoo-linux-security-system-administrator-actions-sudolog-are-collected
- uid: mondoo-linux-security-system-is-disabled-when-audit-logs-are-full
- uid: mondoo-linux-security-the-audit-configuration-is-immutable
- uid: mondoo-linux-security-unsuccessful-unauthorized-file-access-attempts-are-collected
- title: Users and groups
filters: |
asset.family.contains('linux')
checks:
- uid: mondoo-linux-security-access-to-the-su-command-is-restricted
- uid: mondoo-linux-security-default-group-for-the-root-account-is-gid-0
- uid: mondoo-linux-security-each-user-member-of-a-group
- uid: mondoo-linux-security-gid-in-passwd-exists-in-group
- uid: mondoo-linux-security-no-duplicate-gids-exist
- uid: mondoo-linux-security-no-duplicate-group-names-exist
- uid: mondoo-linux-security-no-duplicate-uids-exist
- uid: mondoo-linux-security-no-duplicate-user-names-exist
- uid: mondoo-linux-security-root-group-is-empty
- uid: mondoo-linux-security-shadow-group-is-empty
- uid: mondoo-linux-security-system-accounts-are-non-login
- uid: mondoo-linux-security-uid-min-is-set-to-1000
scoring_system: highest impact
queries:
- uid: mondoo-linux-security-aide-is-installed
title: Ensure Advanced Intrusion Detection Environment (AIDE) is installed
impact: 60
filters: |
asset.kind != "container-image"
mql: |
package("aide").installed
docs:
desc: Advanced Intrusion Detection Environment (AIDE) takes a snapshot of the filesystem state, including modification times, permissions, and file hashes. Administrators can then use this to compare against the current state of the filesystem to detect modifications to the system.
remediation: |-
Run this command to install `aide` :
# RHEL/Fedora/Amazon Linux and derivatives
```
yum install aide
```
# Ubuntu
```
apt-get install aide
```
# Debian
```
apt install aide
```
# SLES and openSUSE
```
zypper install aide
```
Configure AIDE as appropriate for your environment. Consult the AIDE documentation for options.
Initialize AIDE:
```
aide --init
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
```
- uid: mondoo-linux-security-filesystem-integrity-is-regularly-checked
title: Ensure filesystem integrity is regularly checked
impact: 50
filters: |
asset.kind != "container-image"
mql: |
file("/etc/default/aide").exists && ["/etc/default/aide"].where(file(_).exists).all(parse.ini(_).params["CRON_DAILY_RUN"] == "yes") ||
command("crontab -u root -l | grep aide").stdout.lines.where(/^[^#]/).any(_.contains("aide --check")) ||
command("crontab -u root -l | grep aide").stdout.lines.where(/^[^#]/).any(_.contains("aide.conf --check")) ||
service('aidecheck').enabled
docs:
desc: Periodic checking of the filesystem integrity is needed to detect changes to the filesystem.
remediation: |-
_If cron will be used to schedule and run aide check_
Run this command:
```
crontab -u root -e
```
Add the following line to the crontab:
```
0 5 * * * /usr/sbin/aide --check
```
_OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:_
Create or edit the file `/etc/systemd/system/aidecheck.service` and add the following lines:
```
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
```
Create or edit the file `/etc/systemd/system/aidecheck.timer` and add the following lines:
```
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
```
Run these commands:
```
chown root:root /etc/systemd/system/aidecheck.*
chmod 0644 /etc/systemd/system/aidecheck.*
systemctl daemon-reload
systemctl enable aidecheck.service
systemctl --now enable aidecheck.timer
```
- uid: mondoo-linux-security-core-dumps-are-restricted
title: Ensure core dumps are restricted
filters: |
asset.kind != "container-image"
asset.runtime != "docker-container"
impact: 75
mql: |
file("/etc/security/limits.conf").content.lines.where( _ == /^[^#]/ ).where( _.contains("core") ) {
_ == /\*\s+hard\s+core\s+0/
}
kernel.parameters['fs.suid_dumpable'] == 0
if(service("coredump").enabled || service("coredump").running) {
parse.ini("/etc/systemd/coredump.conf").sections['Coredump']['ProcessSizeMax'] == 0
parse.ini("/etc/systemd/coredump.conf").sections['Coredump']['Storage'] == 'none'
}
docs:
desc: A core dump is the memory of an executable program. It is generally used to determine why a program aborted. It can also be used to glean confidential information from a core file. The system provides the ability to set a soft limit for core dumps, but this can be overridden by the user.
remediation: |-
Add the following line to `/etc/security/limits.conf` or a `/etc/security/limits.d/\*` file:
```
* hard core 0
```
Set the following parameter in `/etc/sysctl.conf` or a `/etc/sysctl.d/\*` file:
```
fs.suid_dumpable = 0
```
Run this command to set the active kernel parameter:
```
sysctl -w fs.suid_dumpable=0
```
If systemd-coredump is installed:
edit `/etc/systemd/coredump.conf` and add/modify the following lines:
```
Storage=none
ProcessSizeMax=0
```
Run the command:
```
systemctl daemon-reload
```
- uid: mondoo-linux-security-address-space-layout-randomization-aslr-is-enabled
title: Ensure address space layout randomization (ASLR) is enabled
impact: 90
filters: |
asset.kind != "container-image"
asset.runtime != "docker-container"
mql: |
kernel.parameters["kernel.randomize_va_space"] == 2
docs:
desc: Address space layout randomization (ASLR) is an exploit mitigation technique which randomly arranges the address space of key data areas of a process.
remediation: |-
Set the following parameter in `/etc/sysctl.conf` or a `/etc/sysctl.d/\*` file:
```
kernel.randomize_va_space = 2
```
Run this command to set the active kernel parameter:
```
sysctl -w kernel.randomize_va_space=2
```
- uid: mondoo-linux-security-prelink-is-disabled
title: Ensure prelink is disabled
impact: 70
mql: |
package("prelink").installed == false
docs:
desc: The `prelink` command changes binaries in an attempt to decrease their startup time. Prelinking can interfere with the operation of AIDE, because it changes binaries. Prelinking can also increase the vulnerability of the system if a malicious user is able to compromise a common library such as libc.
remediation: |-
Run these commands to restore binaries to normal and uninstall `prelink`:
### RHEL/Fedora/Amazon Linux and derivatives
```
prelink -ua
yum remove prelink
```
### Ubuntu/Debian
```
prelink -ua
apt-get purge prelink
```
- uid: mondoo-linux-security--window-system-is-not-installed
title: Ensure X Window System is not installed
impact: 100
mql: |
packages.none(name == /^xserver-xorg.*/ || name == /^xorg-x11/ || name == /^xserver/)
docs:
desc: The X Window System provides a Graphical User Interface (GUI) where users can have multiple windows to run programs and various add-ons. The X Windows system is typically used on workstations where users login, but not on servers where users typically do not login.
remediation: |-
Run this command to remove the X Windows System packages:
### RHEL/Fedora/Amazon Linux and derivatives
```
yum remove xorg-x11*
```
### Debian/Ubuntu and derivatives
```
apt-get purge xserver-xorg
```
- uid: mondoo-linux-security-avahi-server-is-not-enabled
title: Ensure Avahi server is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("avahi-daemon").enabled == false
service("avahi-daemon").running == false
docs:
desc: Avahi is a free zeroconf implementation, including a system for multicast DNS/DNS-SD service discovery. Avahi allows programs to publish and discover services and hosts running on a local network with no specific configuration. For example, a user can plug a computer into a network and Avahi automatically finds printers to print to, files to look at and people to talk to, as well as network services running on the machine.
remediation: |-
Run this command to stop and disable `avahi-daemon` :
```
systemctl stop avahi-daemon
systemctl disable avahi-daemon
```
Note: Since the `avahi-daemon` service is often interdependent with other services, it might not be enough to disable the service because other services will likely restart the service automatically.
To make the service `avahi-daemon` invisible to other services run this command :
`systemctl mask avahi-daemon`
- uid: mondoo-linux-security-cups-is-not-enabled
title: Ensure CUPS is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("cups").enabled == false
service("cups").running == false
docs:
desc: The Common Unix Print System (CUPS) provides the ability to print to both local and network printers. A system running CUPS can also accept print jobs from remote systems and print them to local printers. It also provides a web based remote administration capability.
remediation: |-
Run this command to stop and disable `cups` :
```
systemctl stop cups
systemctl disable cups
```
Note: Since the `cups` service is often interdependent with other services, it might not be enough to disable the service because other services such as `cups-browsed` will likely restart the service automatically.
To make the service `cups` invisible to other services run this command :
`systemctl mask cups`
**Impact:**
Disabling CUPS will prevent printing from the system, a common task for workstation systems.
- uid: mondoo-linux-security-dhcp-server-is-not-enabled
title: Ensure DHCP server is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("dhcpd").enabled == false
service("dhcpd").running == false
docs:
desc: The Dynamic Host Configuration Protocol (DHCP) is a service that allows machines to be dynamically assigned IP addresses.
remediation: |-
Run this command to stop and disable `dhcpd` :
```
systemctl stop dhcpd
systemctl disable dhcpd
```
- uid: mondoo-linux-security-ldap-server-is-not-enabled
title: Ensure LDAP server is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("slapd").enabled == false
service("slapd").running == false
docs:
desc: The Lightweight Directory Access Protocol (LDAP) was introduced as a replacement for NIS/YP. It is a service that provides a method for looking up information from a central database.
remediation: |-
Run this command to stop and disable `slapd` :
```
systemctl stop slapd
systemctl disable slapd
```
- uid: mondoo-linux-security-nfs-and-rpc-are-not-enabled
title: Ensure NFS and RPC are stopped and not enabled
impact: 60
filters: |
asset.kind != "container-image"
mql: |
service("nfs").enabled == false
service("nfs").running == false
service("rpcbind").enabled == false
service("rpcbind").running == false
docs:
desc: The Network File System (NFS) is one of the first and most widely distributed file systems in the UNIX environment. It provides the ability for systems to mount file systems of other servers through the network.
remediation: |-
Run these commands to stop and disable `nfs`, `nfs-server`, and `rpcbind`:
```
systemctl stop nfs
systemctl stop rpcbind
systemctl disable nfs
systemctl disable rpcbind
```
- uid: mondoo-linux-security-dns-server-is-not-enabled
title: Ensure DNS server is stopped and not enabled
impact: 60
filters: |
asset.kind != "container-image"
mql: |
service("named").enabled == false
service("named").running == false
docs:
desc: The Domain Name System (DNS) is a hierarchical naming system that maps names to IP addresses for computers, services and other resources connected to a network.
remediation: |-
Run this command to stop and disable `named` :
```
systemctl stop named
systemctl disable named
```
- uid: mondoo-linux-security-ftp-server-is-not-enabled
title: Ensure FTP server is stopped and not enabled
impact: 60
filters: |
asset.kind != "container-image"
mql: |
service("vsftpd").enabled == false
service("vsftpd").running == false
docs:
desc: The File Transfer Protocol (FTP) provides networked computers with the ability to transfer files.
remediation: |-
Run this command to stop and disable `vsftpd` :
```
systemctl stop vsftpd
systemctl disable vsftpd
```
- uid: mondoo-linux-security-http-server-is-not-enabled
title: Ensure HTTP servers are stopped and not enabled
impact: 60
filters: |
asset.kind != "container-image"
mql: |
service("httpd").enabled == false
service("httpd").running == false
service("apache2").enabled == false
service("apache2").running == false
service("nginx").enabled == false
service("nginx").running == false
docs:
desc: HTTP or web servers provide the ability to host web site content.
remediation: |-
Run these commands to stop and disable web servers:
```
systemctl stop httpd
systemctl disable httpd
systemctl stop apache2
systemctl disable apache2
systemctl stop nginx
systemctl disable nginx
```
- uid: mondoo-linux-security-imap-and-pop3-server-is-not-enabled
title: Ensure IMAP and POP3 server is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("dovecot").enabled == false
service("dovecot").running == false
docs:
desc: '`dovecot` is an open source IMAP and POP3 server for Linux based systems.'
remediation: |-
Run this command to stop and disable `dovecot` :
```
systemctl stop dovecot
systemctl disable dovecot
```
- uid: mondoo-linux-security-samba-is-not-enabled
title: Ensure Samba is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("smb").enabled == false
service("smbd").enabled == false
service("smb").running == false
service("smbd").running == false
docs:
desc: The Samba daemon allows system administrators to configure their Linux systems to share file systems and directories with Windows desktops. Samba will advertise the file systems and directories via the Small Message Block (SMB) protocol. Windows desktop users can mount these directories and file systems as letter drives on their systems.
remediation: |-
Run this command to stop and disable `smb` and `smbd` services :
```
systemctl stop smb
systemctl stop smbd
systemctl disable smb
systemctl disable smbd
```
- uid: mondoo-linux-security-http-proxy-server-is-not-enabled
title: Ensure HTTP Proxy server is stopped and not enabled
impact: 60
filters: |
asset.kind != "container-image"
mql: |
service("squid").enabled == false
service("squid").running == false
service("tinyproxy").enabled == false
service("tinyproxy").running == false
docs:
desc: Squid and Tinyproxy are HTTP proxy servers used to proxy and potentially anonymize HTTP traffic through other hosts.
remediation: |-
Run this command to stop and disable `squid` and `tinyproxy`:
```
systemctl stop squid
systemctl stop tinyproxy
systemctl disable squid
systemctl disable tinyproxy
```
- uid: mondoo-linux-security-snmp-server-is-not-enabled
title: Ensure SNMP server is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("snmpd").enabled == false
service("snmpd").running == false
docs:
desc: The Simple Network Management Protocol (SNMP) server is used to listen for SNMP commands from an SNMP management system, execute the commands or collect the information and then send results back to the requesting system.
remediation: |-
Run this command to stop and disable `snmpd`:
```
systemctl stop snmpd
systemctl disable snmpd
```
- uid: mondoo-linux-security-mail-transfer-agent-is-configured-for-local-only-mode
title: Ensure mail transfer agent is configured for local-only mode
impact: 85
filters: |
asset.kind != "container-image"
mql: |
if( package("postfix").installed && service('postfix').running ) {
parse.ini("/etc/postfix/main.cf").params["inet_interfaces"] == "localhost" || parse.ini("/etc/postfix/main.cf").params["inet_interfaces"] == "loopback-only"
}
if( package("exim4").installed && service('exim4').running ) {
parse.ini("/etc/exim4/update-exim4.conf.conf").params["dc_local_interfaces"] == "'127.0.0.1 ; ::1'"
}
ports.listening.where(address != "127.0.0.1" && address != "::1").none(port == 25)
docs:
desc: Mail Transfer Agents (MTA), such as Sendmail and Postfix, listen for incoming mail and transfer the messages to the appropriate user or mail server. If the system is not intended to be a mail server, it is recommended that the MTA be configured to only process local mail.
remediation: |-
Edit `/etc/postfix/main.cf` and add the following line to the RECEIVING MAIL section. If the line already exists, change it to look like the line below:
```
inet_interfaces = loopback-only
```
Restart postfix:
```
systemctl restart postfix
```
- uid: mondoo-linux-security-nis-server-is-not-enabled
title: Ensure NIS server is stopped and not enabled
impact: 75
filters: |
asset.kind != "container-image"
mql: |
service("ypserv").enabled == false
service("ypserv").running == false
docs:
desc: The Network Information Service (NIS) (formally known as Yellow Pages) is a client-server directory service protocol for distributing system configuration files. The NIS server is a collection of programs that allow for the distribution of configuration files.
remediation: |-
Run this command to stop and disable `ypserv` :
```
systemctl stop ypserv
systemctl disable ypserv
```
- uid: mondoo-linux-security-rsh-server-is-not-enabled
title: Ensure rsh server is stopped and not enabled
impact: 75
filters: |
asset.kind != "container-image"
mql: |
service("rsh.socket").enabled == false
service("rlogin.socket").enabled == false
service("rexec.socket").enabled == false
service("rsh.socket").running == false
service("rlogin.socket").running == false
service("rexec.socket").running == false
docs:
desc: The Berkeley `rsh-server` ( `rsh`, `rlogin`, `rexec` ) package contains legacy services that exchange credentials in clear-text.
remediation: |-
Run these commands to stop and disable `rsh`, `rlogin`, and `rexec` :
```
systemctl stop rsh.socket
systemctl stop rlogin.socket
systemctl stop rexec.socket
systemctl disable rsh.socket
systemctl disable rlogin.socket
systemctl disable rexec.socket
```
- uid: mondoo-linux-security-telnet-server-is-not-enabled
title: Ensure telnet server is stopped and not enabled
impact: 90
filters: |
asset.kind != "container-image"
mql: |
service("telnet.socket").enabled == false
service("telnet.socket").running == false
docs:
desc: The `telnet-server` package contains the `telnet` daemon, which accepts connections from users from other systems via the `telnet` protocol.
remediation: |-
Run this command to stop and disable telnet:
```
systemctl stop telnet.socket
systemctl disable telnet.socket
```
- uid: mondoo-linux-security-tftp-server-is-not-enabled
title: Ensure tftp server is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("tftp.socket").enabled == false
service("tftp.socket").running == false
docs:
desc: Trivial File Transfer Protocol (TFTP) is a simple file transfer protocol, typically used to automatically transfer configuration or boot machines from a boot server. The package `tftp-server` is used to define and support a TFTP server.
remediation: |-
Run this command to stop and disable tftp:
```
systemctl stop tftp.socket
systemctl disable tftp.socket
```
- uid: mondoo-linux-security-rsync-service-is-not-enabled
title: Ensure rsync service is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("rsyncd").enabled == false
service("rsyncd").running == false
docs:
desc: The `rsyncd` service can be used to synchronize files between systems over network links.
remediation: |-
Run this command to stop and disable `rsync` :
```
systemctl stop rsyncd
systemctl disable rsyncd
```
- uid: mondoo-linux-security-talk-server-is-not-enabled
title: Ensure talk server is stopped and not enabled
impact: 100
filters: |
asset.kind != "container-image"
mql: |
service("ntalk").enabled == false
service("ntalk").running == false
docs:
desc: The talk software allows users to send and receive messages across systems through a terminal session. The talk client (allows initiate of talk sessions) is installed by default.
remediation: |-
Run this command to stop and disable talk:
```
systemctl stop ntalk
systemctl disable ntalk
```
- uid: mondoo-linux-security-ip-forwarding-is-disabled
title: Ensure IP forwarding is disabled
impact: 75
filters: |
asset.kind != "container-image"
asset.runtime != "docker-container"
mql: |
kernel.parameters['net.ipv4.ip_forward'] == 0
|| kernel.parameters['net.ipv4.ip_forward'] == null
kernel.parameters['net.ipv6.conf.all.forwarding'] == 0
|| kernel.parameters['net.ipv6.conf.all.forwarding'] == null
docs:
desc: The `net.ipv4.ip_forward` and `net.ipv6.conf.all.forwarding` flags are used to tell the system whether it can forward packets or not.
remediation: |-
Set the following parameter in `/etc/sysctl.conf` or a `/etc/sysctl.d/\*` file:
```
net.ipv4.ip_forward = 0
net.ipv6.conf.all.forwarding = 0
```
Run these commands to set the active kernel parameters:
```
sysctl -w net.ipv4.ip_forward=0
sysctl -w net.ipv6.conf.all.forwarding=0
sysctl -w net.ipv4.route.flush=1
sysctl -w net.ipv6.route.flush=1
```
- uid: mondoo-linux-security-packet-redirect-sending-is-disabled
title: Ensure packet redirect sending is disabled
impact: 75
filters: |
asset.kind != "container-image"
asset.runtime != "docker-container"
mql: |
kernel.parameters['net.ipv4.conf.all.send_redirects'] == 0
|| kernel.parameters['net.ipv4.conf.all.send_redirects'] == null
kernel.parameters['net.ipv4.conf.default.send_redirects'] == 0
|| kernel.parameters['net.ipv4.conf.default.send_redirects'] == null
docs:
desc: ICMP Redirects are used to send routing information to other hosts. As a host itself does not act as a router (in a host-only configuration), there is no need to send redirects.
remediation: |-
Set the following parameters in `/etc/sysctl.conf` or a `/etc/sysctl.d/\*` file:
```
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
```
Run these commands to set the active kernel parameters:
```
sysctl -w net.ipv4.conf.all.send_redirects=0
sysctl -w net.ipv4.conf.default.send_redirects=0
sysctl -w net.ipv4.route.flush=1
```
- uid: mondoo-linux-security-source-routed-packets-are-not-accepted
title: Ensure source routed packets are not accepted
impact: 75
filters: |
asset.kind != "container-image"
asset.runtime != "docker-container"
mql: |
kernel.parameters['net.ipv4.conf.all.accept_source_route'] == 0
|| kernel.parameters['net.ipv4.conf.all.accept_source_route'] == null
kernel.parameters['net.ipv4.conf.default.accept_source_route'] == 0
|| kernel.parameters['net.ipv4.conf.default.accept_source_route'] == null
kernel.parameters['net.ipv6.conf.all.accept_source_route'] == 0
|| kernel.parameters['net.ipv6.conf.all.accept_source_route'] == null
kernel.parameters['net.ipv6.conf.default.accept_source_route'] == 0
|| kernel.parameters['net.ipv6.conf.default.accept_source_route'] == null
docs:
desc: In networking, source routing allows a sender to partially or fully specify the route packets take through a network. In contrast, non-source routed packets travel a path determined by routers in the network. In some cases, systems may not be routable or reachable from some locations (e.g. private addresses vs. Internet routable), and so source routed packets would need to be used.
remediation: |-
Set the following parameters in `/etc/sysctl.conf` or a `/etc/sysctl.d/\*` file:
```
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
```
Run these commands to set the active kernel parameters:
```
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.ipv6.conf.all.accept_source_route=0
sysctl -w net.ipv6.conf.default.accept_source_route=0
sysctl -w net.ipv4.route.flush=1
sysctl -w net.ipv6.route.flush=1
```
- uid: mondoo-linux-security-icmp-redirects-are-not-accepted
title: Ensure ICMP redirects are not accepted
impact: 75
filters: |
asset.kind != "container-image"
asset.runtime != "docker-container"
mql: |
kernel.parameters['net.ipv4.conf.all.accept_redirects'] == 0
|| kernel.parameters['net.ipv4.conf.all.accept_redirects'] == null
kernel.parameters['net.ipv4.conf.default.accept_redirects'] == 0
|| kernel.parameters['net.ipv4.conf.default.accept_redirects'] == null
kernel.parameters['net.ipv6.conf.all.accept_redirects'] == 0
|| kernel.parameters['net.ipv6.conf.all.accept_redirects'] == null
kernel.parameters['net.ipv6.conf.default.accept_redirects'] == 0
|| kernel.parameters['net.ipv6.conf.default.accept_redirects'] == null
docs:
desc: ICMP redirect messages are packets that convey routing information and tell your host (acting as a router) to send packets via an alternate path. It is a way of allowing an outside routing device to update your system routing tables. By setting `net.ipv4.conf.all.accept_redirects` and `net.ipv6.conf.all.accept_redirects` to 0, the system will not accept any ICMP redirect messages, and therefore, won't allow outsiders to update the system's routing tables.
remediation: |-
Set the following parameters in `/etc/sysctl.conf` or a `/etc/sysctl.d/\*` file:
```
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
```
Run these commands to set the active kernel parameters:
```
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv6.conf.all.accept_redirects=0
sysctl -w net.ipv6.conf.default.accept_redirects=0
sysctl -w net.ipv4.route.flush=1
sysctl -w net.ipv6.route.flush=1
```
- uid: mondoo-linux-security-secure-icmp-redirects-are-not-accepted
title: Ensure secure ICMP redirects are not accepted
impact: 75
filters: |
asset.kind != "container-image"
asset.runtime != "docker-container"
mql: |
kernel.parameters['net.ipv4.conf.all.secure_redirects'] == 0
|| kernel.parameters['net.ipv4.conf.all.secure_redirects'] == null
kernel.parameters['net.ipv4.conf.default.secure_redirects'] == 0
|| kernel.parameters['net.ipv4.conf.default.secure_redirects'] == null
docs:
desc: Secure ICMP redirects are the same as ICMP redirects, except they come from gateways listed on the default gateway list. It is assumed that these gateways are known to your system and are likely to be secure.
remediation: |-
Set the following parameters in `/etc/sysctl.conf` or a `/etc/sysctl.d/\*` file:
```
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
```
Run these commands to set the active kernel parameters:
```
sysctl -w net.ipv4.conf.all.secure_redirects=0
sysctl -w net.ipv4.conf.default.secure_redirects=0
sysctl -w net.ipv4.route.flush=1
```
- uid: mondoo-linux-security-suspicious-packets-are-logged
title: Ensure suspicious packets are logged
impact: 60
filters: |
asset.kind != "container-image"
asset.runtime != "docker-container"
mql: |
kernel.parameters['net.ipv4.conf.all.log_martians'] == 1
kernel.parameters['net.ipv4.conf.default.log_martians'] == 1
docs:
desc: When enabled, this feature logs packets with un-routable source addresses to the kernel log.
remediation: |-
Set the following parameters in `/etc/sysctl.conf` or a `/etc/sysctl.d/\*` or in /etc/ufw/sysctl.conf file: