PageRenderTime 91ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 1ms

/spec/stig/stig_spec.rb

https://github.com/TheRealLoris/security-audit
Ruby | 3764 lines | 1106 code | 265 blank | 2393 comment | 110 complexity | 20fb34174896b8481f082ea129578e91 MD5 | raw file
  1. require 'spec_helper'
  2. describe "Red Hat Enterprise Linux 6 Security Technical Implementation Guide Audit for #{ENV['TARGET_HOST']}" do
  3. # STIG Viewer Link: http://www.stigviewer.com/check/V-38437
  4. it "V-38437 Automated file system mounting tools must not be enabled unless needed." do
  5. # Check: To verify the "autofs" service is disabled, run the following command:
  6. # chkconfig --list autofs
  7. # If properly configured, the output should be the following:
  8. # autofs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  9. # Verify the "autofs" service is not running:
  10. # # service autofs status
  11. # If the autofs service is enabled or running, this is a finding.
  12. expect( package('autofs')).not_to be_installed
  13. expect( service('autofs')).not_to be_enabled
  14. expect( service('autofs')).not_to be_running
  15. # Fix: If the "autofs" service is not needed to dynamically mount NFS filesystems or removable media,
  16. # disable the service for all runlevels:
  17. # # chkconfig --level 0123456 autofs off
  18. # Stop the service if it is already running:
  19. # # service autofs stop
  20. end
  21. # STIG Viewer Link: http://www.stigviewer.com/check/V-38438
  22. it "V-38438 Auditing must be enabled at boot by setting a kernel parameter." do
  23. # Check: Inspect the kernel boot arguments (which follow the word "kernel") in "/etc/grub.conf". If they include "audit=1",
  24. # then auditing is enabled at boot time.
  25. # If auditing is not enabled at boot time, this is a finding.
  26. expect( command('grep audit=1 /etc/grub.conf') ).not_to return_stdout ""
  27. # Fix: To ensure all processes can be audited, even those which start prior to the audit daemon, add the argument "audit=1"
  28. # to the kernel line in "/etc/grub.conf", in the manner below:
  29. # kernel /vmlinuz-version ro vga=ext root=/dev/VolGroup00/LogVol00 rhgb quiet audit=1
  30. end
  31. # STIG Viewer Link: http://www.stigviewer.com/check/V-38439
  32. it "V-38439 The system must provide automated support for account management functions." do
  33. # Check: Interview the SA to determine if there is an automated system for managing user accounts, preferably integrated with
  34. # an existing enterprise user management system.
  35. # If there is not, this is a finding.
  36. pending( "Manual step" )
  37. # Fix: Implement an automated system for managing user accounts that minimizes the risk of errors, either intentional or deliberate.
  38. # If possible, this system should integrate with an existing enterprise user management system, such as, one based Active
  39. # Directory or Kerberos.
  40. end
  41. # STIG Viewer Link: http://www.stigviewer.com/check/V-38443
  42. it "V-38443 The /etc/gshadow file must be owned by root." do
  43. # Check: To check the ownership of "/etc/gshadow", run the command:
  44. # $ ls -l /etc/gshadow
  45. # If properly configured, the output should indicate the following owner: "root"
  46. # If it does not, this is a finding.
  47. expect( file('/etc/gshadow')).to be_owned_by 'root'
  48. # Fix: To properly set the owner of "/etc/gshadow", run the command:
  49. # # chown root /etc/gshadow
  50. end
  51. # STIG Viewer Link: http://www.stigviewer.com/check/V-38444
  52. it "V-38444 The systems local IPv6 firewall must implement a deny-all, allow-by-exception policy for inbound packets." do
  53. # Check: Inspect the file "/etc/sysconfig/ip6tables" to determine the default policy for the INPUT chain. It should be set to DROP.
  54. # # grep ":INPUT" /etc/sysconfig/ip6tables
  55. # If the default policy for the INPUT chain is not set to DROP, this is a finding.
  56. if $environment['ipv6Enabled']
  57. expect( command('grep \':INPUT ACCEPT [0:0]\' /etc/sysconfig/ip6tables') ).not_to return_stdout ""
  58. else
  59. pending("Not applicable")
  60. end
  61. # Fix: To set the default policy to DROP (instead of ACCEPT) for the built-in INPUT chain which processes incoming packets, add or correct the following line in "/etc/sysconfig/ip6tables":
  62. # :INPUT DROP [0:0]
  63. end
  64. # STIG Viewer Link: http://www.stigviewer.com/check/V-38445
  65. it "V-38445 Audit log files must be group-owned by root." do
  66. # Check: Run the following command to check the group owner of the system audit logs:
  67. # grep "^log_file" /etc/audit/auditd.conf|sed s/^[^\/]*//|xargs stat -c %G:%n
  68. # Audit logs must be group-owned by root.
  69. # If they are not, this is a finding.
  70. expect( file('/etc/audit/auditd.conf')).to be_grouped_into 'root'
  71. # Fix: Change the group owner of the audit log files with the following command:
  72. # # chgrp root [audit_file]
  73. end
  74. # STIG Viewer Link: http://www.stigviewer.com/check/V-38446
  75. it "V-38446 The mail system must forward all mail for root to one or more system administrators." do
  76. # Check: Find the list of alias maps used by the Postfix mail server:
  77. # # postconf alias_maps
  78. # Query the Postfix alias maps for an alias for "root":
  79. # # postmap -q root <alias_map>
  80. # If there are no aliases configured for root that forward to a monitored email address, this is a finding.
  81. expect( mail_alias('root')).to be_aliased_to $environment['rootEmailAddress']
  82. # Fix: Set up an alias for root that forwards to a monitored email address:
  83. # # echo "root: <system.administrator>@mail.mil" >> /etc/aliases
  84. # # newaliases
  85. end
  86. # STIG Viewer Link: http://www.stigviewer.com/check/V-38447
  87. it "V-38447 The system package management tool must verify contents of all files associated with packages.", :slow => true do
  88. # Check: The following command will list which files on the system have file hashes different from what is expected
  89. # by the RPM database.
  90. # # rpm -Va | grep '$1 ~ /..5/ && $2 != "c"'
  91. # If there is output, this is a finding.
  92. expect( command('rpm -Va | grep \'$1 ~ /..5/ && $2 != "c"\'') ).to return_stdout ""
  93. # Fix: The RPM package management system can check the hashes of installed software packages, including many that are important
  94. # to system security. Run the following command to list which files on the system have hashes that differ from what is expected
  95. # by the RPM database:
  96. # # rpm -Va | grep '^..5'
  97. # A "c" in the second column indicates that a file is a configuration file, which may appropriately be expected to change. If
  98. # the file that has changed was not expected to then refresh from distribution media or online repositories.
  99. # rpm -Uvh [affected_package]
  100. # OR
  101. # yum reinstall [affected_package]
  102. end
  103. # STIG Viewer Link: http://www.stigviewer.com/check/V-38448
  104. it "V-38448 The /etc/gshadow file must be group-owned by root." do
  105. # Check: To check the group ownership of "/etc/gshadow", run the command:
  106. # $ ls -l /etc/gshadow
  107. # If properly configured, the output should indicate the following group-owner. "root"
  108. # If it does not, this is a finding.
  109. expect( file('/etc/gshadow')).to be_grouped_into 'root'
  110. # Fix: To properly set the group owner of "/etc/gshadow", run the command:
  111. # # chgrp root /etc/gshadow
  112. end
  113. # STIG Viewer Link: http://www.stigviewer.com/check/V-38449
  114. it "V-38449 The /etc/gshadow file must have mode 0000." do
  115. # Check: To check the permissions of "/etc/gshadow", run the command:
  116. # $ ls -l /etc/gshadow
  117. # If properly configured, the output should indicate the following permissions: "----------"
  118. # If it does not, this is a finding.
  119. expect( file('/etc/shadow')).to be_mode 000
  120. # Fix: To properly set the permissions of "/etc/gshadow", run the command:
  121. # # chmod 0000 /etc/gshadow
  122. end
  123. # STIG Viewer Link: http://www.stigviewer.com/check/V-38450
  124. it "V-38450 The /etc/passwd file must be owned by root." do
  125. # Check: To check the ownership of "/etc/passwd", run the command:
  126. # $ ls -l /etc/passwd
  127. # If properly configured, the output should indicate the following owner: "root"
  128. # If it does not, this is a finding.
  129. expect( file('/etc/passwd')).to be_owned_by 'root'
  130. # Fix: To properly set the owner of "/etc/passwd", run the command:
  131. # # chown root /etc/passwd
  132. end
  133. # STIG Viewer Link: http://www.stigviewer.com/check/V-38451
  134. it "V-38451 The /etc/passwd file must be group-owned by root." do
  135. # Check: To check the group ownership of "/etc/passwd", run the command:
  136. # $ ls -l /etc/passwd
  137. # If properly configured, the output should indicate the following group-owner. "root"
  138. # If it does not, this is a finding.
  139. expect( file('/etc/passwd')).to be_grouped_into 'root'
  140. # Fix: To properly set the group owner of "/etc/passwd", run the command:
  141. # # chgrp root /etc/passwd
  142. end
  143. # STIG Viewer Link: http://www.stigviewer.com/check/V-38452
  144. it "V-38452 The system package management tool must verify permissions on all files and directories associated with packages.", :slow => true do
  145. # Check: The following command will list which files and directories on the system have
  146. # permissions different from what is expected by the RPM database: # rpm -Va
  147. # | grep '^.M' If there is any output, for each file or directory found, find the
  148. # associated RPM package and compare the RPM-expected permissions with the actual
  149. # permissions on the file or directory: # rpm -qf [file or directory name] # rpm
  150. # -q --queryformat "[%{FILENAMES} %{FILEMODES:perms}\n]" [package] | grep [filename]
  151. # # ls -lL [filename] If the existing permissions are more permissive than those
  152. # expected by RPM, this is a finding.
  153. expect( command('rpm -Va | grep \'^.M\'') ).to return_stdout ""
  154. # Fix: The RPM package management system can restore file access permissions of package files and directories. The following
  155. # command will update permissions on files and directories with permissions different from what is expected by the RPM database:
  156. # # rpm --setperms [package]
  157. end
  158. # STIG Viewer Link: http://www.stigviewer.com/check/V-38453
  159. it "V-38453 The system package management tool must verify group-ownership on all files and directories associated with packages.", :slow => true do
  160. # Check: The following command will list which files on the system have group-ownership different from what is expected by the
  161. # RPM database:
  162. # # rpm -Va | grep '^......G'
  163. # If there is output, this is a finding.
  164. expect( command('rpm -Va | grep \'^......G\'') ).to return_stdout ""
  165. # Fix: The RPM package management system can restore group-ownership of the package files and directories. The following command will
  166. # update files and directories with group-ownership different from what is expected by the RPM database:
  167. # # rpm -qf [file or directory name]
  168. # # rpm --setugids [package]
  169. end
  170. # STIG Viewer Link: http://www.stigviewer.com/check/V-38454
  171. it "V-38454 The system package management tool must verify ownership on all files and directories associated with packages.", :slow => true do
  172. # Check: The following command will list which files on the system have ownership different from what is expected by the RPM database:
  173. # # rpm -Va | grep '^.....U'
  174. # If there is output, this is a finding.
  175. expect( command('rpm -Va | grep \'^.....U\'') ).to return_stdout ""
  176. # Fix: The RPM package management system can restore ownership of package files and directories. The following command will update files and directories with ownership different from what is expected by the RPM database:
  177. # # rpm -qf [file or directory name]
  178. # # rpm --setugids [package]
  179. end
  180. # STIG Viewer Link: http://www.stigviewer.com/check/V-38455
  181. it "V-38455 The system must use a separate file system for /tmp." do
  182. # Check: Run the following command to determine if "/tmp" is on its own partition or logical volume:
  183. # $ mount | grep "on /tmp "
  184. # If "/tmp" has its own partition or volume group, a line will be returned.
  185. # If no line is returned, this is a finding.
  186. expect( command('grep "[[:space:]]/tmp[[:space:]]" /etc/fstab') ).not_to return_stdout ""
  187. # Fix: The "/tmp" directory is a world-writable directory used for temporary file storage. Ensure it has its own partition or logical volume at installation time, or migrate it using LVM.
  188. end
  189. # STIG Viewer Link: http://www.stigviewer.com/check/V-38456
  190. it "V-38456 The system must use a separate file system for /var." do
  191. # Check: Run the following command to determine if "/var" is on its own partition or logical volume:
  192. # $ mount | grep "on /var "
  193. # If "/var" has its own partition or volume group, a line will be returned.
  194. # If no line is returned, this is a finding.
  195. expect( command('grep "[[:space:]]/var[[:space:]]" /etc/fstab') ).not_to return_stdout ""
  196. # Fix: The "/var" directory is used by daemons and other system services to store frequently-changing data. Ensure that "/var" has its own partition or logical volume at installation time, or migrate it using LVM.
  197. end
  198. # STIG Viewer Link: http://www.stigviewer.com/check/V-38457
  199. it "V-38457 The /etc/passwd file must have mode 0644 or less permissive." do
  200. # Check: To check the permissions of "/etc/passwd", run the command:
  201. # $ ls -l /etc/passwd
  202. # If properly configured, the output should indicate the following permissions: "-rw-r--r--"
  203. # If it does not, this is a finding.
  204. expect( file('/etc/passwd')).to be_mode 644
  205. # Fix: To properly set the permissions of "/etc/passwd", run the command:
  206. # # chmod 0644 /etc/passwd
  207. end
  208. # STIG Viewer Link: http://www.stigviewer.com/check/V-38458
  209. it "V-38458 The /etc/group file must be owned by root." do
  210. # Check: To check the ownership of "/etc/group", run the command:
  211. # $ ls -l /etc/group
  212. # If properly configured, the output should indicate the following owner: "root"
  213. # If it does not, this is a finding.
  214. expect( file('/etc/group')).to be_owned_by 'root'
  215. # Fix: To properly set the owner of "/etc/group", run the command:
  216. # # chown root /etc/group
  217. end
  218. # STIG Viewer Link: http://www.stigviewer.com/check/V-38459
  219. it "V-38459 The /etc/group file must be group-owned by root." do
  220. # Check: To check the group ownership of "/etc/group", run the command:
  221. # $ ls -l /etc/group
  222. # If properly configured, the output should indicate the following group-owner. "root"
  223. # If it does not, this is a finding.
  224. expect( file('/etc/group')).to be_grouped_into 'root'
  225. # Fix: To properly set the group owner of "/etc/group", run the command:
  226. # # chgrp root /etc/group
  227. end
  228. # STIG Viewer Link: http://www.stigviewer.com/check/V-38460
  229. it "V-38460 The NFS server must not have the all_squash option enabled." do
  230. # Check: If the NFS server is read-only, in support of unrestricted access to organizational content, this is not applicable.
  231. # The related "root_squash" option provides protection against remote administrator-level access to NFS server content. Its use is not a finding.
  232. # To verify the "all_squash" option has been disabled, run the following command:
  233. # # grep all_squash /etc/exports
  234. # If there is output, this is a finding.
  235. if property[:roles].include? 'nfsServer'
  236. expect( command('grep all_squash /etc/exports') ).to return_stdout ""
  237. else
  238. pending("Not applicable")
  239. end
  240. # Fix: Remove any instances of the "all_squash" option from the file "/etc/exports". Restart the NFS daemon for the changes to take effect.
  241. # # service nfs restart
  242. end
  243. # STIG Viewer Link: http://www.stigviewer.com/check/V-38461
  244. it "V-38461 The /etc/group file must have mode 0644 or less permissive." do
  245. # Check: To check the permissions of "/etc/group", run the command:
  246. # $ ls -l /etc/group
  247. # If properly configured, the output should indicate the following permissions: "-rw-r--r--"
  248. # If it does not, this is a finding.
  249. expect( file('/etc/group')).to be_mode 644
  250. # Fix: To properly set the permissions of "/etc/group", run the command:
  251. # # chmod 644 /etc/group
  252. end
  253. # STIG Viewer Link: http://www.stigviewer.com/check/V-38462
  254. it "V-38462 The RPM package management tool must cryptographically verify the authenticity of all software packages during installation." do
  255. # Check: Verify RPM signature validation is not disabled:
  256. # # grep nosignature /etc/rpmrc /usr/lib/rpm/rpmrc /usr/lib/rpm/redhat/rpmrc ~root/.rpmrc
  257. # If any configuration is found, this is a finding.
  258. expect( file('/etc/rpmrc')).not_to be_file
  259. expect( file('/root/.rpmrc')).not_to be_file
  260. expect( command('grep nosignature /usr/lib/rpm/rpmrc') ).to return_stdout ""
  261. # Fix: Edit the RPM configuration files containing the "nosignature" option and remove the option.
  262. end
  263. # STIG Viewer Link: http://www.stigviewer.com/check/V-38463
  264. it "V-38463 The system must use a separate file system for /var/log." do
  265. # Check: Run the following command to determine if "/var/log" is on its own partition or logical volume:
  266. # $ mount | grep "on /var/log "
  267. # If "/var/log" has its own partition or volume group, a line will be returned.
  268. # If no line is returned, this is a finding.
  269. expect( command('grep "[[:space:]]/var/log[[:space:]]" /etc/fstab') ).not_to return_stdout ""
  270. # Fix: System logs are stored in the "/var/log" directory. Ensure that it has its own partition or logical volume at installation time, or migrate it using LVM.
  271. end
  272. # STIG Viewer Link: http://www.stigviewer.com/check/V-38464
  273. it "V-38464 The audit system must take appropriate action when there are disk errors on the audit storage volume." do
  274. # Check: Inspect "/etc/audit/auditd.conf" and locate the following line to determine if the system is configured to take appropriate action when disk errors occur:
  275. # # grep disk_error_action /etc/audit/auditd.conf
  276. # disk_error_action = [ACTION]
  277. # If the system is configured to "suspend" when disk errors occur or "ignore" them, this is a finding.
  278. expect( command('grep --ignore-case \'disk_error_action = SUSPEND\' /etc/audit/auditd.conf') ).to return_stdout ""
  279. expect( command('grep --ignore-case \'disk_error_action = IGNORE\' /etc/audit/auditd.conf') ).to return_stdout ""
  280. # Fix: Edit the file "/etc/audit/auditd.conf". Modify the following line, substituting [ACTION] appropriately:
  281. # disk_error_action = [ACTION]
  282. # Possible values for [ACTION] are described in the "auditd.conf" man page. These include:
  283. # "ignore"
  284. # "syslog"
  285. # "exec"
  286. # "suspend"
  287. # "single"
  288. # "halt"
  289. # Set this to "syslog", "exec", "single", or "halt".
  290. end
  291. # STIG Viewer Link: http://www.stigviewer.com/check/V-38465
  292. it "V-38465 Library files must have mode 0755 or less permissive." do
  293. # Check: System-wide shared library files, which are linked to executables during process load time or run time, are stored in the following directories by default:
  294. # /lib
  295. # /lib64
  296. # /usr/lib
  297. # /usr/lib64
  298. # Kernel modules, which can be added to the kernel during runtime, are stored in "/lib/modules". All files in these directories should not be group-writable or world-writable. To find shared libraries that are group-writable or world-writable, run the following command for each directory [DIR] which contains shared libraries:
  299. # $ find -L [DIR] -perm /022
  300. # If any of these files are group-writable or world-writable, this is a finding.
  301. expect( file('/lib')).to be_mode 555
  302. expect( file('/lib64')).to be_mode 555
  303. expect( file('/usr/lib')).to be_mode 555
  304. expect( file('/usr/lib64')).to be_mode 555
  305. # Fix: System-wide shared library files, which are linked to executables during process load time or run time, are stored in the following directories by default:
  306. # /lib
  307. # /lib64
  308. # /usr/lib
  309. # /usr/lib64
  310. # If any file in these directories is found to be group-writable or world-writeable correct its permission with the following command:
  311. # # chmod go-w [FILE]
  312. end
  313. # STIG Viewer Link: http://www.stigviewer.com/check/V-38466
  314. it "V-38466 Library files must be owned by root." do
  315. # Check: System-wide shared library files, which are linked to executables during process load time or run time, are stored in the following directories by default:
  316. # /lib
  317. # /lib64
  318. # /usr/lib
  319. # /usr/lib64
  320. # Kernel modules, which can be added to the kernel during runtime, are stored in "/lib/modules". All files in these directories should not be group-writable or world-writable. To find shared libraries that are not owned by "root", run the following command for each directory [DIR] which contains shared libraries:
  321. # $ find -L [DIR] \! -user root
  322. # If any of these files are not owned by root, this is a finding.
  323. expect( file('/lib')).to be_owned_by 'root'
  324. expect( file('/lib64')).to be_owned_by 'root'
  325. expect( file('/usr/lib')).to be_owned_by 'root'
  326. expect( file('/usr/lib64')).to be_owned_by 'root'
  327. # Fix: System-wide shared library files, which are linked to executables during process load time or run time, are stored in the following directories by default:
  328. # /lib
  329. # /lib64
  330. # /usr/lib
  331. # /usr/lib64
  332. # If any file in these directories is found to be owned by a user other than root, correct its ownership with the following command:
  333. # # chown root [FILE]
  334. end
  335. # STIG Viewer Link: http://www.stigviewer.com/check/V-38467
  336. it "V-38467 The system must use a separate file system for the system audit data path." do
  337. # Check: Run the following command to determine if "/var/log/audit" is on its own partition or logical volume:
  338. # $ mount | grep "on /var/log/audit "
  339. # If "/var/log/audit" has its own partition or volume group, a line will be returned.
  340. # If no line is returned, this is a finding.
  341. expect( command('grep "[[:space:]]/var/log/audit[[:space:]]" /etc/fstab') ).not_to return_stdout ""
  342. # Fix: Audit logs are stored in the "/var/log/audit" directory. Ensure that it has its own partition or logical volume at installation time, or migrate it later using LVM. Make absolutely certain that it is large enough to store all audit logs that will be created by the auditing daemon.
  343. end
  344. # STIG Viewer Link: http://www.stigviewer.com/check/V-38468
  345. it "V-38468 The audit system must take appropriate action when the audit storage volume is full." do
  346. # Check: Inspect "/etc/audit/auditd.conf" and locate the following line to determine if the system is configured to take appropriate action when the audit storage volume is full:
  347. # # grep disk_full_action /etc/audit/auditd.conf
  348. # disk_full_action = [ACTION]
  349. # If the system is configured to "suspend" when the volume is full or "ignore" that it is full, this is a finding.
  350. expect( command('grep --ignore-case \'disk_full_action = SUSPEND\' /etc/audit/auditd.conf') ).to return_stdout ""
  351. expect( command('grep --ignore-case \'disk_full_action = IGNORE\' /etc/audit/auditd.conf') ).to return_stdout ""
  352. # Fix: The "auditd" service can be configured to take an action when disk space starts to run low. Edit the file "/etc/audit/auditd.conf". Modify the following line, substituting [ACTION] appropriately:
  353. # disk_full_action = [ACTION]
  354. # Possible values for [ACTION] are described in the "auditd.conf" man page. These include:
  355. # "ignore"
  356. # "syslog"
  357. # "exec"
  358. # "suspend"
  359. # "single"
  360. # "halt"
  361. # Set this to "syslog", "exec", "single", or "halt".
  362. end
  363. # STIG Viewer Link: http://www.stigviewer.com/check/V-38469
  364. it "V-38469 All system command files must have mode 0755 or less permissive." do
  365. # Check: System executables are stored in the following directories by default:
  366. # /bin
  367. # /usr/bin
  368. # /usr/local/bin
  369. # /sbin
  370. # /usr/sbin
  371. # /usr/local/sbin
  372. # All files in these directories should not be group-writable or world-writable. To find system executables that are group-writable or world-writable, run the following command for each directory [DIR] which contains system executables:
  373. # $ find -L [DIR] -perm /022
  374. # If any system executables are found to be group-writable or world-writable, this is a finding.
  375. expect( file('/bin')).to be_mode 555
  376. expect( file('/usr/bin')).to be_mode 555
  377. expect( file('/usr/local/bin')).to be_mode 555
  378. expect( file('/sbin')).to be_mode 555
  379. expect( file('/usr/sbin')).to be_mode 555
  380. expect( file('/usr/local/sbin')).to be_mode 555
  381. # Fix: System executables are stored in the following directories by default:
  382. # /bin
  383. # /usr/bin
  384. # /usr/local/bin
  385. # /sbin
  386. # /usr/sbin
  387. # /usr/local/sbin
  388. # If any file in these directories is found to be group-writable or world-writable, correct its permission with the following command:
  389. # # chmod go-w [FILE]
  390. end
  391. # STIG Viewer Link: http://www.stigviewer.com/check/V-38470
  392. it "V-38470 The audit system must alert designated staff members when the audit storage volume approaches capacity." do
  393. # Check: Inspect "/etc/audit/auditd.conf" and locate the following line to determine if the system is configured to email the administrator when disk space is starting to run low:
  394. # # grep space_left_action /etc/audit/auditd.conf
  395. # space_left_action = email
  396. # If the system is not configured to send an email to the system administrator when disk space is starting to run low, this is a finding.
  397. expect( command('grep --ignore-case "^space_left_action = email" /etc/audit/auditd.conf') ).not_to return_stdout ""
  398. # Fix: The "auditd" service can be configured to take an action when disk space starts to run low. Edit the file "/etc/audit/auditd.conf". Modify the following line, substituting [ACTION] appropriately:
  399. # space_left_action = [ACTION]
  400. # Possible values for [ACTION] are described in the "auditd.conf" man page. These include:
  401. # "ignore"
  402. # "syslog"
  403. # "email"
  404. # "exec"
  405. # "suspend"
  406. # "single"
  407. # "halt"
  408. # Set this to "email" (instead of the default, which is "suspend") as it is more likely to get prompt attention.
  409. # RHEL-06-000521 ensures that the email generated through the operation "space_left_action" will be sent to an administrator.
  410. end
  411. # STIG Viewer Link: http://www.stigviewer.com/check/V-38471
  412. it "V-38471 The system must forward audit records to the syslog service." do
  413. # Check: Verify the audispd plugin is active:
  414. # # grep active /etc/audisp/plugins.d/syslog.conf
  415. # If the "active" setting is missing or set to "no", this is a finding.
  416. expect( command('grep "^active = yes" /etc/audisp/plugins.d/syslog.conf')).not_to return_stdout ""
  417. # Fix: Set the "active" line in "/etc/audisp/plugins.d/syslog.conf" to "yes". Restart the auditd process.
  418. # # service auditd restart
  419. end
  420. # STIG Viewer Link: http://www.stigviewer.com/check/V-38472
  421. it "V-38472 All system command files must be owned by root." do
  422. # Check: System executables are stored in the following directories by default:
  423. # /bin
  424. # /usr/bin
  425. # /usr/local/bin
  426. # /sbin
  427. # /usr/sbin
  428. # /usr/local/sbin
  429. # All files in these directories should not be group-writable or world-writable. To find system executables that are not owned by "root", run the following command for each directory [DIR] which contains system executables:
  430. # $ find -L [DIR] \! -user root
  431. # If any system executables are found to not be owned by root, this is a finding.
  432. expect( file('/bin')).to be_owned_by 'root'
  433. expect( file('/usr/bin')).to be_owned_by 'root'
  434. expect( file('/usr/local/bin')).to be_owned_by 'root'
  435. expect( file('/sbin')).to be_owned_by 'root'
  436. expect( file('/usr/sbin')).to be_owned_by 'root'
  437. expect( file('/usr/local/sbin')).to be_owned_by 'root'
  438. # Fix: System executables are stored in the following directories by default:
  439. # /bin
  440. # /usr/bin
  441. # /usr/local/bin
  442. # /sbin
  443. # /usr/sbin
  444. # /usr/local/sbin
  445. # If any file [FILE] in these directories is found to be owned by a user other than root, correct its ownership with the following command:
  446. # # chown root [FILE]
  447. end
  448. # STIG Viewer Link: http://www.stigviewer.com/check/V-38473
  449. it "V-38473 The system must use a separate file system for user home directories." do
  450. # Check: Run the following command to determine if "/home" is on its own partition or logical volume:
  451. # $ mount | grep "on /home "
  452. # If "/home" has its own partition or volume group, a line will be returned.
  453. # If no line is returned, this is a finding.
  454. expect( command('grep "[[:space:]]/home[[:space:]]" /etc/fstab') ).not_to return_stdout ""
  455. # Fix: If user home directories will be stored locally, create a separate partition for "/home" at installation time (or migrate it later using LVM). If "/home" will be mounted from another system such as an NFS server, then creating a separate partition is not necessary at installation time, and the mountpoint can instead be configured later.
  456. end
  457. # STIG Viewer Link: http://www.stigviewer.com/check/V-38474
  458. it "V-38474 The system must allow locking of graphical desktop sessions." do
  459. # Check: Verify the keybindings for the Gnome screensaver:
  460. # # gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --get /apps/gnome_settings_daemon/keybindings/screensaver
  461. # If no output is visible, this is a finding.
  462. if property[:gnomeInstalled]
  463. expect( command('gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --get /apps/gnome_settings_daemon/keybindings/screensaver') ).not_to return_stdout ""
  464. else
  465. pending( "Not Applicable" )
  466. end
  467. # Fix: Run the following command to set the Gnome desktop keybinding for locking the screen:
  468. # # gconftool-2
  469. # --direct \
  470. # --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
  471. # --type string \
  472. # --set /apps/gnome_settings_daemon/keybindings/screensaver "<Control><Alt>l"
  473. # Another keyboard sequence may be substituted for "<Control><Alt>l", which is the default for the Gnome desktop.
  474. end
  475. # STIG Viewer Link: http://www.stigviewer.com/check/V-38475
  476. it "V-38475 The system must require passwords to contain a minimum of 14 characters." do
  477. # Check: To check the minimum password length, run the command:
  478. # $ grep PASS_MIN_LEN /etc/login.defs
  479. # The DoD requirement is "14".
  480. # If it is not set to the required value, this is a finding.
  481. expect( file('/etc/login.defs')).to contain /^PASS_MIN_LEN 14/
  482. # Fix: To specify password length requirements for new accounts, edit the file "/etc/login.defs" and add or correct the following lines:
  483. # PASS_MIN_LEN 14
  484. # The DoD requirement is "14". If a program consults "/etc/login.defs" and also another PAM module (such as "pam_cracklib") during a password change operation, then the most restrictive must be satisfied.
  485. end
  486. # STIG Viewer Link: http://www.stigviewer.com/check/V-38476
  487. it "V-38476 Vendor-provided cryptographic certificates must be installed to verify the integrity of system software." do
  488. # Check: To ensure that the GPG key is installed, run:
  489. # $ rpm -q --queryformat "%{SUMMARY}\n" gpg-pubkey
  490. # The command should return the string below:
  491. # gpg(Red Hat, Inc. (release key <security@redhat.com>)
  492. # If the Red Hat GPG Key is not installed, this is a finding.
  493. if $environment['linuxFlavor'] == 'centos'
  494. expect( command('gpg --quiet --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6| grep fingerprint') ).to return_stdout "Key fingerprint = C1DA C52D 1664 E8A4 386D BA43 0946 FCA2 C105 B9DE"
  495. expect( command('rpm -q --queryformat "%{SUMMARY}\n" gpg-pubkey| grep "gpg(CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>)"') ).not_to return_stdout ""
  496. elsif $environment['linuxFlavor'] == 'redhat'
  497. expect( command('rpm -q --queryformat "%{SUMMARY}\n" gpg-pubkey| grep "gpg(Red Hat, Inc. (release key <security@redhat.com>)"') ).not_to return_stdout ""
  498. elsif $environment['linuxFlavor'] == 'oracle'
  499. expect( command('rpm -q --queryformat "%{SUMMARY}\n" gpg-pubkey| grep "gpg(Oracle OSS group (Open Source Software group) <build@oss.oracle.com>)"') ).not_to return_stdout ""
  500. else
  501. fail("linuxFlavor set to unknown value")
  502. end
  503. # Fix: To ensure the system can cryptographically verify base software packages come from Red Hat (and to connect to the Red Hat Network to receive them if desired), the Red Hat GPG key must properly be installed. To ensure the GPG key is installed, run:
  504. # # rhn_register
  505. end
  506. # STIG Viewer Link: http://www.stigviewer.com/check/V-38477
  507. it "V-38477 Users must not be able to change passwords more than once every 24 hours." do
  508. # Check: To check the minimum password age, run the command:
  509. # $ grep PASS_MIN_DAYS /etc/login.defs
  510. # The DoD requirement is 1.
  511. # If it is not set to the required value, this is a finding.
  512. expect( file('/etc/login.defs')).to contain /^PASS_MIN_DAYS 1/
  513. # Fix: To specify password minimum age for new accounts, edit the file "/etc/login.defs" and add or correct the following line, replacing [DAYS] appropriately:
  514. # PASS_MIN_DAYS [DAYS]
  515. # A value of 1 day is considered sufficient for many environments. The DoD requirement is 1.
  516. end
  517. # STIG Viewer Link: http://www.stigviewer.com/check/V-38478
  518. it "V-38478 The Red Hat Network Service (rhnsd) service must not be running, unless using RHN or an RHN Satellite." do
  519. # Check: If the system uses RHN or is an RHN Satellite, this is not applicable.
  520. # To check that the "rhnsd" service is disabled in system boot configuration, run the following command:
  521. # # chkconfig "rhnsd" --list
  522. # Output should indicate the "rhnsd" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  523. # # chkconfig "rhnsd" --list
  524. # "rhnsd" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  525. # Run the following command to verify "rhnsd" is disabled through current runtime configuration:
  526. # # service rhnsd status
  527. # If the service is disabled the command will return the following output:
  528. # rhnsd is stopped
  529. # If the service is running, this is a finding.
  530. if $environment['linuxFlavor'] == 'centos'
  531. pending("Not applicable")
  532. elsif $environment['linuxFlavor'] == 'redhat'
  533. if property[:roles].include? 'redHatNetworkService'
  534. pending("Not applicable")
  535. else
  536. expect( service('rhnsd')).not_to be_enabled
  537. expect( service('rhnsd')).not_to be_running
  538. end
  539. elsif $environment['linuxFlavor'] == 'oracle'
  540. pending("Not applicable")
  541. else
  542. fail("linuxFlavor set to unknown value")
  543. end
  544. # Fix: The Red Hat Network service automatically queries Red Hat Network servers to determine whether there are any actions that should be executed, such as package updates. This only occurs if the system was registered to an RHN server or satellite and managed as such. The "rhnsd" service can be disabled with the following command:
  545. # # chkconfig rhnsd off
  546. end
  547. # STIG Viewer Link: http://www.stigviewer.com/check/V-38479
  548. it "V-38479 User passwords must be changed at least every 60 days." do
  549. # Check: To check the maximum password age, run the command:
  550. # $ grep PASS_MAX_DAYS /etc/login.defs
  551. # The DoD requirement is 60.
  552. # If it is not set to the required value, this is a finding.
  553. expect( file('/etc/login.defs')).to contain /^PASS_MAX_DAYS 60/
  554. # Fix: To specify password maximum age for new accounts, edit the file "/etc/login.defs" and add or correct the following line, replacing [DAYS] appropriately:
  555. # PASS_MAX_DAYS [DAYS]
  556. # The DoD requirement is 60.
  557. end
  558. # STIG Viewer Link: http://www.stigviewer.com/check/V-38480
  559. it "V-38480 Users must be warned 7 days in advance of password expiration." do
  560. # Check: To check the password warning age, run the command:
  561. # $ grep PASS_WARN_AGE /etc/login.defs
  562. # The DoD requirement is 7.
  563. # If it is not set to the required value, this is a finding.
  564. expect( file('/etc/login.defs')).to contain /^PASS_WARN_AGE 7/
  565. # Fix: To specify how many days prior to password expiration that a warning will be issued to users, edit the file "/etc/login.defs" and add or correct the following line, replacing [DAYS] appropriately:
  566. # PASS_WARN_AGE [DAYS]
  567. # The DoD requirement is 7.
  568. end
  569. # STIG Viewer Link: http://www.stigviewer.com/check/V-38481
  570. it "V-38481 System security patches and updates must be installed and up-to-date." do
  571. # Check: If the system is joined to the Red Hat Network, a Red Hat Satellite Server, or a yum server which provides updates, invoking the following command will indicate if updates are available:
  572. # # yum check-update
  573. # If the system is not configured to update from one of these sources, run the following command to list when each package was last updated:
  574. # $ rpm -qa -last
  575. # Compare this to Red Hat Security Advisories (RHSA) listed at https://access.redhat.com/security/updates/active/ to determine whether the system is missing applicable security and bugfix updates.
  576. # If updates are not installed, this is a finding.
  577. expect( command('yum check-update') ).to return_exit_status 0
  578. # Fix: If the system is joined to the Red Hat Network, a Red Hat Satellite Server, or a yum server, run the following command to install updates:
  579. # # yum update
  580. # If the system is not configured to use one of these sources, updates (in the form of RPM packages) can be manually downloaded from the Red Hat Network and installed using "rpm".
  581. end
  582. # STIG Viewer Link: http://www.stigviewer.com/check/V-38482
  583. it "V-38482 The system must require passwords to contain at least one numeric character." do
  584. # Check: To check how many digits are required in a password, run the following command:
  585. # $ grep pam_cracklib /etc/pam.d/system-auth
  586. # The "dcredit" parameter (as a negative number) will indicate how many digits are required. The DoD requires at least one digit in a password. This would appear as "dcredit=-1".
  587. # If dcredit is not found or not set to the required value, this is a finding.
  588. expect( file('/etc/pam.d/system-auth-ac')).to contain "dcredit=-1"
  589. # Fix: The pam_cracklib module's "dcredit" parameter controls requirements for usage of digits in a password. When set to a negative number, any password will be required to contain that many digits. When set to a positive number, pam_cracklib will grant +1 additional length credit for each digit. Add "dcredit=-1" after pam_cracklib.so to require use of a digit in passwords.
  590. end
  591. # STIG Viewer Link: http://www.stigviewer.com/check/V-38483
  592. it "V-38483 The system package management tool must cryptographically verify the authenticity of system software packages during installation." do
  593. # Check: To determine whether "yum" is configured to use "gpgcheck", inspect "/etc/yum.conf" and ensure the following appears in the "[main]" section:
  594. # gpgcheck=1
  595. # A value of "1" indicates that "gpgcheck" is enabled. Absence of a "gpgcheck" line or a setting of "0" indicates that it is disabled.
  596. # If GPG checking is not enabled, this is a finding.
  597. # If the "yum" system package management tool is not used to update the system, verify with the SA that installed packages are cryptographically signed.
  598. expect( command('grep "^gpgcheck=1" /etc/yum.conf') ).not_to return_stdout ""
  599. # Fix: The "gpgcheck" option should be used to ensure checking of an RPM package's signature always occurs prior to its installation. To configure yum to check package signatures before installing them, ensure the following line appears in "/etc/yum.conf" in the "[main]" section:
  600. # gpgcheck=1
  601. end
  602. # STIG Viewer Link: http://www.stigviewer.com/check/V-38484
  603. it "V-38484 The operating system, upon successful logon, must display to the user the date and time of the last logon or access via ssh." do
  604. # Check: Verify the value associated with the "PrintLastLog" keyword in /etc/ssh/sshd_config:
  605. # # grep -i PrintLastLog /etc/ssh/sshd_config
  606. # If the value is not set to "yes", this is a finding. If the "PrintLastLog" keyword is not present, this is not a finding.
  607. expect( file('/etc/ssh/sshd_config')).to contain /^PrintLastLog yes/
  608. # Fix: Update the "PrintLastLog" keyword to "yes" in /etc/ssh/sshd_config:
  609. # PrintLastLog yes
  610. # While it is acceptable to remove the keyword entirely since the default action for the SSH daemon is to print the last login date and time, it is preferred to have the value explicitly documented.
  611. end
  612. # STIG Viewer Link: http://www.stigviewer.com/check/V-38485
  613. it "V-38485 The operating system, upon successful logon, must display to the user the date and time of the last logon or access via a local console or tty." do
  614. # Check: Verify there are no "hushlogin" files active on the system:
  615. # # ls -l /etc/hushlogins
  616. # For each home directory stored in "/etc/passwd":
  617. # # ls ~<userid>/.hushlogin
  618. # If there are any "hushlogin" files on the system, this is a finding.
  619. expect( file('/etc/hushlogins')).not_to be_file
  620. expect( command('find /home -name \'.hushlogin\'') ).to return_stdout ""
  621. # Fix: Remove any "hushlogin" files from the system:
  622. # # rm /etc/hushlogins
  623. # # rm ~<userid>/.hushlogin
  624. end
  625. # STIG Viewer Link: http://www.stigviewer.com/check/V-38486
  626. it "V-38486 The operating system must conduct backups of system-level information contained in the information system per organization defined frequency to conduct backups that are consistent with recovery time and recovery point objectives." do
  627. # Check: Ask an administrator if a process exists to back up OS data from the system, including configuration data.
  628. # If such a process does not exist, this is a finding.
  629. pending( "Manual step" )
  630. # Fix: Procedures to back up OS data from the system must be established and executed. The Red Hat operating system provides utilities for automating such a process. Commercial and open-source products are also available.
  631. # Implement a process whereby OS data is backed up from the system in accordance with local policies.
  632. end
  633. # STIG Viewer Link: http://www.stigviewer.com/check/V-38487
  634. it "V-38487 The system package management tool must cryptographically verify the authenticity of all software packages during installation." do
  635. # Check: To determine whether "yum" has been configured to disable "gpgcheck" for any repos, inspect all files in "/etc/yum.repos.d" and ensure the following does not appear in any sections:
  636. # gpgcheck=0
  637. # A value of "0" indicates that "gpgcheck" has been disabled for that repo.
  638. # If GPG checking is disabled, this is a finding.
  639. # If the "yum" system package management tool is not used to update the system, verify with the SA that installed packages are cryptographically signed.
  640. expect( command('grep ^gpgcheck=0 /etc/yum.repos.d/*.repo') ).to return_stdout ""
  641. # Fix: To ensure signature checking is not disabled for any repos, remove any lines from files in "/etc/yum.repos.d" of the form:
  642. # gpgcheck=0
  643. end
  644. # STIG Viewer Link: http://www.stigviewer.com/check/V-38488
  645. it "V-38488 The operating system must conduct backups of user-level information contained in the operating system per organization defined frequency to conduct backups consistent with recovery time and recovery point objectives." do
  646. # Check: Ask an administrator if a process exists to back up user data from the system.
  647. # If such a process does not exist, this is a finding.
  648. pending( "Manual step" )
  649. # Fix: Procedures to back up user data from the system must be established and executed. The Red Hat operating system provides utilities for automating such a process. Commercial and open-source products are also available.
  650. # Implement a process whereby user data is backed up from the system in accordance with local policies.
  651. end
  652. # STIG Viewer Link: http://www.stigviewer.com/check/V-38489
  653. it "V-38489 A file integrity tool must be installed." do
  654. # Check: If another file integrity tool is installed, this is not a finding.
  655. # Run the following command to determine if the "aide" package is installed:
  656. # # rpm -q aide
  657. # If the package is not installed, this is a finding.
  658. if $environment['ids'] == 'ossec'
  659. expect( package('ossec-hids') ).to be_installed
  660. elsif $environment['ids'] == 'aide'
  661. expect( package('aide') ).to be_installed
  662. else
  663. fail("IDS variable set to unknown value")
  664. end
  665. # Fix: Install the AIDE package with the command:
  666. # # yum install aide
  667. end
  668. # STIG Viewer Link: http://www.stigviewer.com/check/V-38490
  669. it "V-38490 The operating system must enforce requirements for the connection of mobile devices to operating systems." do
  670. # Check: If the system is configured to prevent the loading of the "usb-storage" kernel module, it will contain lines inside any file in "/etc/modprobe.d" or the deprecated"/etc/modprobe.conf". These lines instruct the module loading system to run another program (such as "/bin/true") upon a module "install" event. Run the following command to search for such lines in all files in "/etc/modprobe.d" and the deprecated "/etc/modprobe.conf":
  671. # $ grep -r usb-storage /etc/modprobe.conf /etc/modprobe.d
  672. # If no line is returned, this is a finding.
  673. expect( command('grep -r usb-storage /etc/modprobe.d') ).not_to return_stdout ""
  674. # Fix: To prevent USB storage devices from being used, configure the kernel module loading system to prevent automatic loading of the USB storage driver. To configure the system to prevent the "usb-storage" kernel module from being loaded, add the following line to a file in the directory "/etc/modprobe.d":
  675. # install usb-storage /bin/true
  676. # This will prevent the "modprobe" program from loading the "usb-storage" module, but will not prevent an administrator (or another program) from using the "insmod" program to load the module manually.
  677. end
  678. # STIG Viewer Link: http://www.stigviewer.com/check/V-38491
  679. it "V-38491 There must be no .rhosts or hosts.equiv files on the system." do
  680. # Check: The existence of the file "/etc/hosts.equiv" or a file named ".rhosts" inside a user home directory indicates the presence of an Rsh trust relationship.
  681. # If these files exist, this is a finding.
  682. expect( file('/etc/hosts.equiv')).not_to be_file
  683. expect( command('find /home -name \'.rhosts\'') ).to return_stdout ""
  684. # Fix: The files "/etc/hosts.equiv" and "~/.rhosts" (in each user's home directory) list remote hosts and users that are trusted by the local system when using the rshd daemon. To remove these files, run the following command to delete them from any location.
  685. # # rm /etc/hosts.equiv
  686. # $ rm ~/.rhosts
  687. end
  688. # STIG Viewer Link: http://www.stigviewer.com/check/V-38492
  689. it "V-38492 The system must prevent the root account from logging in from virtual consoles." do
  690. # Check: To check for virtual console entries which permit root login, run the following command:
  691. # # grep '^vc/[0-9]' /etc/securetty
  692. # If any output is returned, then root logins over virtual console devices is permitted.
  693. # If root login over virtual console devices is permitted, this is a finding.
  694. expect( file('/etc/securetty')).not_to contain /^vc\/[0-9]/
  695. # Fix: To restrict root logins through the (deprecated) virtual console devices, ensure lines of this form do not appear in "/etc/securetty":
  696. # vc/1
  697. # vc/2
  698. # vc/3
  699. # vc/4
  700. # Note: Virtual console entries are not limited to those listed above. Any lines starting with "vc/" followed by numerals should be removed.
  701. end
  702. # STIG Viewer Link: http://www.stigviewer.com/check/V-38493
  703. it "V-38493 Audit log directories must have mode 0755 or less permissive." do
  704. # Check: Run the following command to check the mode of the system audit directories:
  705. # grep "^log_file" /etc/audit/auditd.conf|sed 's/^[^/]*//; s/[^/]*$//'|xargs stat -c %a:%n
  706. # Audit directories must be mode 0755 or less permissive.
  707. # If any are more permissive, this is a finding.
  708. expect( file('/var/log/audit')).to be_mode 750
  709. # Fix: Change the mode of the audit log directories with the following command:
  710. # # chmod go-w [audit_directory]
  711. end
  712. # STIG Viewer Link: http://www.stigviewer.com/check/V-38494
  713. it "V-38494 The system must prevent the root account from logging in from serial consoles." do
  714. # Check: To check for serial port entries which permit root login, run the following command:
  715. # # grep '^ttyS[0-9]' /etc/securetty
  716. # If any output is returned, then root login over serial ports is permitted.
  717. # If root login over serial ports is permitted, this is a finding.
  718. expect( file('/etc/securetty')).not_to contain /^ttyS[0-9]/
  719. # Fix: To restrict root logins on serial ports, ensure lines of this form do not appear in "/etc/securetty":
  720. # ttyS0
  721. # ttyS1
  722. # Note: Serial port entries are not limited to those listed above. Any lines starting with "ttyS" followed by numerals should be removed
  723. end
  724. # STIG Viewer Link: http://www.stigviewer.com/check/V-38495
  725. it "V-38495 Audit log files must be owned by root." do
  726. # Check: Run the following command to check the owner of the system audit logs:
  727. # grep "^log_file" /etc/audit/auditd.conf|sed s/^[^\/]*//|xargs stat -c %U:%n
  728. # Audit logs must be owned by root.
  729. # If they are not, this is a finding.
  730. expect( file('/var/log/audit/audit.log')).to be_owned_by 'root'
  731. # Fix: Change the owner of the audit log files with the following command:
  732. # # chown root [audit_file]
  733. end
  734. # STIG Viewer Link: http://www.stigviewer.com/check/V-38496
  735. it "V-38496 Default system accounts, other than root, must be locked." do
  736. # Check: To obtain a listing of all users and the contents of their shadow password field, run the command:
  737. # $ awk -F: '{print $1 ":" $2}' /etc/shadow
  738. # Identify the system accounts from this listing. These will primarily be the accounts with UID numbers less than 500, other than root.
  739. # If any system account (other than root) has a valid password hash, this is a finding.
  740. expect( command('egrep -v "^\+" /etc/passwd | awk -F: \'($1!="root" && $3<500 && $2!="x") {print}\'')).to return_stdout ""
  741. # Fix: Some accounts are not associated with a human user of the system, and exist to perform some administrative function. An attacker should not be able to log into these accounts.
  742. # Disable login access to these accounts with the command:
  743. # # passwd -l [SYSACCT]
  744. end
  745. # STIG Viewer Link: http://www.stigviewer.com/check/V-38497
  746. it "V-38497 The system must not have accounts configured with blank or null passwords." do
  747. # Check: To verify that null passwords cannot be used, run the following command:
  748. # # grep nullok /etc/pam.d/system-auth /etc/pam.d/system-auth-ac
  749. # If this produces any output, it may be possible to log into accounts with empty passwords.
  750. # If NULL passwords can be used, this is a finding.
  751. expect( file('/etc/pam.d/system-auth-ac')).not_to contain "nullok"
  752. # Fix: If an account is configured for password authentication but does not have an assigned password, it may be possible to log into the account without authentication. Remove any instances of the "nullok" option in "/etc/pam.d/system-auth-ac" to prevent logins with empty passwords.
  753. end
  754. # STIG Viewer Link: http://www.stigviewer.com/check/V-38498
  755. it "V-38498 Audit log files must have mode 0640 or less permissive." do
  756. # Check: Run the following command to check the mode of the system audit logs:
  757. # grep "^log_file" /etc/audit/auditd.conf|sed s/^[^\/]*//|xargs stat -c %a:%n
  758. # Audit logs must be mode 0640 or less permissive.
  759. # If any are more permissive, this is a finding.
  760. expect( file('/var/log/audit/audit.log')).to be_mode 600
  761. # Fix: Change the mode of the audit log files with the following command:
  762. # # chmod 0640 [audit_file]
  763. end
  764. # STIG Viewer Link: http://www.stigviewer.com/check/V-38499
  765. it "V-38499 The /etc/passwd file must not contain password hashes." do
  766. # Check: To check that no password hashes are stored in "/etc/passwd", run the following command:
  767. # # awk -F: '($2 != "x") {print}' /etc/passwd
  768. # If it produces any output, then a password hash is stored in "/etc/passwd".
  769. # If any stored hashes are found in /etc/passwd, this is a finding.
  770. expect( command('awk -F: \'($2 != "x") {print}\' /etc/passwd') ).to return_stdout ""
  771. # Fix: If any password hashes are stored in "/etc/passwd" (in the second field, instead of an "x"), the cause of this misconfiguration should be investigated. The account should have its password reset and the hash should be properly stored, or the account should be deleted entirely.
  772. end
  773. # STIG Viewer Link: http://www.stigviewer.com/check/V-38500
  774. it "V-38500 The root account must be the only account having a UID of 0." do
  775. # Check: To list all password file entries for accounts with UID 0, run the following command:
  776. # # awk -F: '($3 == "0") {print}' /etc/passwd
  777. # This should print only one line, for the user root.
  778. # If any account other than root has a UID of 0, this is a finding.
  779. expect( command('/bin/cat /etc/passwd | /bin/awk -F: \'($3 == 0) { print $1 }\'')).to return_stdout "root"
  780. # Fix: If any account other than root has a UID of 0, this misconfiguration should be investigated and the accounts other than root should be removed or have their UID changed.
  781. end
  782. # STIG Viewer Link: http://www.stigviewer.com/check/V-38501
  783. it "V-38501 The system must disable accounts after excessive login failures within a 15-minute interval." do
  784. # Check: To ensure the failed password attempt policy is configured correctly, run the following command:
  785. # # grep pam_faillock /etc/pam.d/system-auth-ac
  786. # The output should show "fail_interval=<interval-in-seconds>" where "interval-in-seconds" is 900 (15 minutes) or greater. If the "fail_interval" parameter is not set, the default setting of 900 seconds is acceptable.
  787. # If that is not the case, this is a finding.
  788. expect( file('/etc/pam.d/system-auth-ac')).to contain "fail_interval=900"
  789. ####@TODO Need to test if it is empty or check if the 2 lines have the same value and that value is above 900
  790. # Fix: To configure the system to lock out accounts after a number of incorrect login attempts within a 15-minute interval using "pam_faillock.so":
  791. # Add the following lines immediately below the "pam_env.so" statement in the AUTH section of
  792. # "/etc/pam.d/system-auth-ac":
  793. # auth [default=die] pam_faillock.so authfail deny=3 unlock_time=604800 fail_interval=900
  794. # auth required pam_faillock.so authsucc deny=3 unlock_time=604800 fail_interval=900
  795. # Note that any updates made to "/etc/pam.d/system-auth-ac" will be overwritten by the "authconfig" program. The "authconfig" program should not be used.
  796. end
  797. # STIG Viewer Link: http://www.stigviewer.com/check/V-38502
  798. it "V-38502 The /etc/shadow file must be owned by root." do
  799. # Check: To check the ownership of "/etc/shadow", run the command:
  800. # $ ls -l /etc/shadow
  801. # If properly configured, the output should indicate the following owner: "root"
  802. # If it does not, this is a finding.
  803. expect( file('/etc/shadow')).to be_owned_by 'root'
  804. # Fix: To properly set the owner of "/etc/shadow", run the command:
  805. # # chown root /etc/shadow
  806. end
  807. # STIG Viewer Link: http://www.stigviewer.com/check/V-38503
  808. it "V-38503 The /etc/shadow file must be group-owned by root." do
  809. # Check: To check the group ownership of "/etc/shadow", run the command:
  810. # $ ls -l /etc/shadow
  811. # If properly configured, the output should indicate the following group-owner. "root"
  812. # If it does not, this is a finding.
  813. expect( file('/etc/shadow')).to be_grouped_into 'root'
  814. # Fix: To properly set the group owner of "/etc/shadow", run the command:
  815. # # chgrp root /etc/shadow
  816. end
  817. # STIG Viewer Link: http://www.stigviewer.com/check/V-38504
  818. it "V-38504 The /etc/shadow file must have mode 0000." do
  819. # Check: To check the permissions of "/etc/shadow", run the command:
  820. # $ ls -l /etc/shadow
  821. # If properly configured, the output should indicate the following permissions: "----------"
  822. # If it does not, this is a finding.
  823. expect( file('/etc/shadow')).to be_mode 000
  824. # Fix: To properly set the permissions of "/etc/shadow", run the command:
  825. # # chmod 0000 /etc/shadow
  826. end
  827. # STIG Viewer Link: http://www.stigviewer.com/check/V-38511
  828. it "V-38511 IP forwarding for IPv4 must not be enabled, unless the system is a router." do
  829. # Check: If the system serves as a router, this is not applicable.
  830. # The status of the "net.ipv4.ip_forward" kernel parameter can be queried by running the following command:
  831. # $ sysctl net.ipv4.ip_forward
  832. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  833. # If the correct value is not returned, this is a finding.
  834. if property[:roles].include? 'router'
  835. expect( linux_kernel_parameter('net.ipv4.ip_forward').value).to equal(1)
  836. else
  837. expect( linux_kernel_parameter('net.ipv4.ip_forward').value ).to equal(0)
  838. end
  839. # Fix: To set the runtime status of the "net.ipv4.ip_forward" kernel parameter, run the following command:
  840. # # sysctl -w net.ipv4.ip_forward=0
  841. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  842. # net.ipv4.ip_forward = 0
  843. end
  844. # STIG Viewer Link: http://www.stigviewer.com/check/V-38512
  845. it "V-38512 The operating system must prevent public IPv4 access into an organizations internal networks, except as appropriately mediated by managed interfaces employing boundary protection devices." do
  846. # Check: If the system is a cross-domain system, this is not applicable.
  847. # Run the following command to determine the current status of the "iptables" service:
  848. # # service iptables status
  849. # If the service is enabled, it should return the following:
  850. # iptables is running...
  851. # If the service is not running, this is a finding.
  852. expect( service('iptables')).to be_enabled
  853. expect( service('iptables')).to be_running
  854. if $environment['ipv6Enabled']
  855. expect( service('ip6tables')).to be_enabled
  856. expect( service('ip6tables')).to be_running
  857. end
  858. # Fix: The "iptables" service can be enabled with the following command:
  859. # # chkconfig iptables on
  860. end
  861. # STIG Viewer Link: http://www.stigviewer.com/check/V-38513
  862. it "V-38513 The systems local IPv4 firewall must implement a deny-all, allow-by-exception policy for inbound packets." do
  863. # Check: Inspect the file "/etc/sysconfig/iptables" to determine the default policy for the INPUT chain. It should be set to DROP.
  864. # # grep ":INPUT" /etc/sysconfig/iptables
  865. # If the default policy for the INPUT chain is not set to DROP, this is a finding.
  866. expect( file('/etc/sysconfig/iptables')).to contain /^\:INPUT DROP \[0\:0\]/
  867. if $environment['ipv6Enabled']
  868. expect( file('/etc/sysconfig/ip6tables')).to contain /^\:INPUT DROP \[0\:0\]/
  869. end
  870. # Fix: To set the default policy to DROP (instead of ACCEPT) for the built-in INPUT chain which processes incoming packets, add or correct the following line in "/etc/sysconfig/iptables":
  871. # :INPUT DROP [0:0]
  872. end
  873. # STIG Viewer Link: http://www.stigviewer.com/check/V-38514
  874. it "V-38514 The Datagram Congestion Control Protocol (DCCP) must be disabled unless required." do
  875. # Check: If the system is configured to prevent the loading of the "dccp" kernel module, it will contain lines inside any file in "/etc/modprobe.d" or the deprecated"/etc/modprobe.conf". These lines instruct the module loading system to run another program (such as "/bin/true") upon a module "install" event. Run the following command to search for such lines in all files in "/etc/modprobe.d" and the deprecated "/etc/modprobe.conf":
  876. # $ grep -r dccp /etc/modprobe.conf /etc/modprobe.d
  877. # If no line is returned, this is a finding.
  878. expect( command('grep -r dccp /etc/modprobe.d') ).not_to return_stdout ""
  879. # Fix: The Datagram Congestion Control Protocol (DCCP) is a relatively new transport layer protocol, designed to support streaming media and telephony. To configure the system to prevent the "dccp" kernel module from being loaded, add the following line to a file in the directory "/etc/modprobe.d":
  880. # install dccp /bin/true
  881. end
  882. # STIG Viewer Link: http://www.stigviewer.com/check/V-38515
  883. it "V-38515 The Stream Control Transmission Protocol (SCTP) must be disabled unless required." do
  884. # Check: If the system is configured to prevent the loading of the "sctp" kernel module, it will contain lines inside any file in "/etc/modprobe.d" or the deprecated"/etc/modprobe.conf". These lines instruct the module loading system to run another program (such as "/bin/true") upon a module "install" event. Run the following command to search for such lines in all files in "/etc/modprobe.d" and the deprecated "/etc/modprobe.conf":
  885. # $ grep -r sctp /etc/modprobe.conf /etc/modprobe.d
  886. # If no line is returned, this is a finding.
  887. expect( command('grep -r sctp /etc/modprobe.d') ).not_to return_stdout ""
  888. # Fix: The Stream Control Transmission Protocol (SCTP) is a transport layer protocol, designed to support the idea of message-oriented communication, with several streams of messages within one connection. To configure the system to prevent the "sctp" kernel module from being loaded, add the following line to a file in the directory "/etc/modprobe.d":
  889. # install sctp /bin/true
  890. end
  891. # STIG Viewer Link: http://www.stigviewer.com/check/V-38516
  892. it "V-38516 The Reliable Datagram Sockets (RDS) protocol must be disabled unless required." do
  893. # Check: If the system is configured to prevent the loading of the "rds" kernel module, it will contain lines inside any file in "/etc/modprobe.d" or the deprecated"/etc/modprobe.conf". These lines instruct the module loading system to run another program (such as "/bin/true") upon a module "install" event. Run the following command to search for such lines in all files in "/etc/modprobe.d" and the deprecated "/etc/modprobe.conf":
  894. # $ grep -r rds /etc/modprobe.conf /etc/modprobe.d
  895. # If no line is returned, this is a finding.
  896. expect( command('grep -r rds /etc/modprobe.d')).not_to return_stdout ""
  897. # Fix: The Reliable Datagram Sockets (RDS) protocol is a transport layer protocol designed to provide reliable high- bandwidth, low-latency communications between nodes in a cluster. To configure the system to prevent the "rds" kernel module from being loaded, add the following line to a file in the directory "/etc/modprobe.d":
  898. # install rds /bin/true
  899. end
  900. # STIG Viewer Link: http://www.stigviewer.com/check/V-38517
  901. it "V-38517 The Transparent Inter-Process Communication (TIPC) protocol must be disabled unless required." do
  902. # Check: If the system is configured to prevent the loading of the "tipc" kernel module, it will contain lines inside any file in "/etc/modprobe.d" or the deprecated"/etc/modprobe.conf". These lines instruct the module loading system to run another program (such as "/bin/true") upon a module "install" event. Run the following command to search for such lines in all files in "/etc/modprobe.d" and the deprecated "/etc/modprobe.conf":
  903. # $ grep -r tipc /etc/modprobe.conf /etc/modprobe.d
  904. # If no line is returned, this is a finding.
  905. expect( command('grep -r tipc /etc/modprobe.d') ).not_to return_stdout ""
  906. # Fix: The Transparent Inter-Process Communication (TIPC) protocol is designed to provide communications between nodes in a cluster. To configure the system to prevent the "tipc" kernel module from being loaded, add the following line to a file in the directory "/etc/modprobe.d":
  907. # install tipc /bin/true
  908. end
  909. # STIG Viewer Link: http://www.stigviewer.com/check/V-38518
  910. it "V-38518 All rsyslog-generated log files must be owned by root." do
  911. # Check: The owner of all log files written by "rsyslog" should be root. These log files are determined by the second part of each Rule line in "/etc/rsyslog.conf" and typically all appear in "/var/log". For each log file [LOGFILE] referenced in "/etc/rsyslog.conf", run the following command to inspect the file's owner:
  912. # $ ls -l [LOGFILE]
  913. # If the owner is not root, this is a finding.
  914. $environment['logFiles'].each do |log|
  915. expect( file(log)).to be_owned_by 'root'
  916. end
  917. # Fix: The owner of all log files written by "rsyslog" should be root. These log files are determined by the second part of each Rule line in "/etc/rsyslog.conf" typically all appear in "/var/log". For each log file [LOGFILE] referenced in "/etc/rsyslog.conf", run the following command to inspect the file's owner:
  918. # $ ls -l [LOGFILE]
  919. # If the owner is not "root", run the following command to correct this:
  920. # # chown root [LOGFILE]
  921. end
  922. # STIG Viewer Link: http://www.stigviewer.com/check/V-38519
  923. it "V-38519 All rsyslog-generated log files must be group-owned by root." do
  924. # Check: The group-owner of all log files written by "rsyslog" should be root. These log files are determined by the second part of each Rule line in "/etc/rsyslog.conf" and typically all appear in "/var/log". For each log file [LOGFILE] referenced in "/etc/rsyslog.conf", run the following command to inspect the file's group owner:
  925. # $ ls -l [LOGFILE]
  926. # If the group-owner is not root, this is a finding.
  927. $environment['logFiles'].each do |log|
  928. expect( file(log)).to be_grouped_into 'root'
  929. end
  930. # Fix: The group-owner of all log files written by "rsyslog" should be root. These log files are determined by the second part of each Rule line in "/etc/rsyslog.conf" and typically all appear in "/var/log". For each log file [LOGFILE] referenced in "/etc/rsyslog.conf", run the following command to inspect the file's group owner:
  931. # $ ls -l [LOGFILE]
  932. # If the owner is not "root", run the following command to correct this:
  933. # # chgrp root [LOGFILE]
  934. end
  935. # STIG Viewer Link: http://www.stigviewer.com/check/V-38520
  936. it "V-38520 The operating system must back up audit records on an organization defined frequency onto a different system or media than the system being audited." do
  937. # Check: To ensure logs are sent to a remote host, examine the file "/etc/rsyslog.conf". If using UDP, a line similar to the following should be present:
  938. # *.* @[loghost.example.com]
  939. # If using TCP, a line similar to the following should be present:
  940. # *.* @@[loghost.example.com]
  941. # If using RELP, a line similar to the following should be present:
  942. # *.* :omrelp:[loghost.example.com]
  943. # If none of these are present, this is a finding.
  944. if $environment['logger'] == 'syslog-ng'
  945. expect( file('/etc/syslog-ng/syslog-ng.conf')).to contain "log { source(s_sys); destination(d_log_server); };"
  946. elsif $environment['logger'] == 'rsyslog'
  947. expect( command('grep "^\*\.\* @@" /etc/rsyslog.conf')).not_to return_stdout ""
  948. else
  949. fail("The value of the logger variable is unknown.")
  950. end
  951. # Fix: To configure rsyslog to send logs to a remote log server, open "/etc/rsyslog.conf" and read and understand the last section of the file, which describes the multiple directives necessary to activate remote logging. Along with these other directives, the system can be configured to forward its logs to a particular log server by adding or correcting one of the following lines, substituting "[loghost.example.com]" appropriately. The choice of protocol depends on the environment of the system; although TCP and RELP provide more reliable message delivery, they may not be supported in all environments.
  952. # To use UDP for log message delivery:
  953. # *.* @[loghost.example.com]
  954. # To use TCP for log message delivery:
  955. # *.* @@[loghost.example.com]
  956. # To use RELP for log message delivery:
  957. # *.* :omrelp:[loghost.example.com]
  958. end
  959. # STIG Viewer Link: http://www.stigviewer.com/check/V-38521
  960. it "V-38521 The operating system must support the requirement to centrally manage the content of audit records generated by organization defined information system components." do
  961. # Check: To ensure logs are sent to a remote host, examine the file "/etc/rsyslog.conf". If using UDP, a line similar to the following should be present:
  962. # *.* @[loghost.example.com]
  963. # If using TCP, a line similar to the following should be present:
  964. # *.* @@[loghost.example.com]
  965. # If using RELP, a line similar to the following should be present:
  966. # *.* :omrelp:[loghost.example.com]
  967. # If none of these are present, this is a finding.
  968. if $environment['logger'] == 'syslog-ng'
  969. expect( file('/etc/syslog-ng/syslog-ng.conf')).to contain "log { source(s_sys); destination(d_log_server); };"
  970. elsif $environment['logger'] == 'rsyslog'
  971. expect( command('grep "^\*\.\* @@" /etc/rsyslog.conf')).not_to return_stdout ""
  972. else
  973. fail("The value of the logger variable is unknown.")
  974. end # Fix: To configure rsyslog to send logs to a remote log server, open "/etc/rsyslog.conf" and read and understand the last section of the file, which describes the multiple directives necessary to activate remote logging. Along with these other directives, the system can be configured to forward its logs to a particular log server by adding or correcting one of the following lines, substituting "[loghost.example.com]" appropriately. The choice of protocol depends on the environment of the system; although TCP and RELP provide more reliable message delivery, they may not be supported in all environments.
  975. # To use UDP for log message delivery:
  976. # *.* @[loghost.example.com]
  977. # To use TCP for log message delivery:
  978. # *.* @@[loghost.example.com]
  979. # To use RELP for log message delivery:
  980. # *.* :omrelp:[loghost.example.com]
  981. end
  982. # STIG Viewer Link: http://www.stigviewer.com/check/V-38522
  983. it "V-38522 The audit system must be configured to audit all attempts to alter system time through settimeofday." do
  984. # Check: To determine if the system is configured to audit calls to the "settimeofday" system call, run the following command:
  985. # # auditctl -l | grep syscall | grep settimeofday
  986. # If the system is configured to audit this activity, it will return a line.
  987. # If the system is not configured to audit time changes, this is a finding.
  988. expect( command('auditctl -l | grep syscall | grep settimeofday') ).not_to return_stdout ""
  989. # Fix: On a 32-bit system, add the following to "/etc/audit/audit.rules":
  990. # # audit_time_rules
  991. # -a always,exit -F arch=b32 -S settimeofday -k audit_time_rules
  992. # On a 64-bit system, add the following to "/etc/audit/audit.rules":
  993. # # audit_time_rules
  994. # -a always,exit -F arch=b64 -S settimeofday -k audit_time_rules
  995. # The -k option allows for the specification of a key in string form that can be used for better reporting capability through ausearch and aureport. Multiple system calls can be defined on the same line to save space if desired, but is not required. See an example of multiple combined syscalls:
  996. # -a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime
  997. # -k audit_time_rules
  998. end
  999. # STIG Viewer Link: http://www.stigviewer.com/check/V-38523
  1000. it "V-38523 The system must not accept IPv4 source-routed packets on any interface." do
  1001. # Check: The status of the "net.ipv4.conf.all.accept_source_route" kernel parameter can be queried by running the following command:
  1002. # $ sysctl net.ipv4.conf.all.accept_source_route
  1003. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1004. # If the correct value is not returned, this is a finding.
  1005. expect( linux_kernel_parameter('net.ipv4.conf.all.accept_source_route').value ).to equal(0)
  1006. # Fix: To set the runtime status of the "net.ipv4.conf.all.accept_source_route" kernel parameter, run the following command:
  1007. # # sysctl -w net.ipv4.conf.all.accept_source_route=0
  1008. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1009. # net.ipv4.conf.all.accept_source_route = 0
  1010. end
  1011. # STIG Viewer Link: http://www.stigviewer.com/check/V-38524
  1012. it "V-38524 The system must not accept ICMPv4 redirect packets on any interface." do
  1013. # Check: The status of the "net.ipv4.conf.all.accept_redirects" kernel parameter can be queried by running the following command:
  1014. # $ sysctl net.ipv4.conf.all.accept_redirects
  1015. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1016. # If the correct value is not returned, this is a finding.
  1017. expect( linux_kernel_parameter('net.ipv4.conf.all.accept_redirects').value ).to equal(0)
  1018. # Fix: To set the runtime status of the "net.ipv4.conf.all.accept_redirects" kernel parameter, run the following command:
  1019. # # sysctl -w net.ipv4.conf.all.accept_redirects=0
  1020. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1021. # net.ipv4.conf.all.accept_redirects = 0
  1022. end
  1023. # STIG Viewer Link: http://www.stigviewer.com/check/V-38525
  1024. it "V-38525 The audit system must be configured to audit all attempts to alter system time through stime." do
  1025. # Check: To determine if the system is configured to audit calls to the "stime" system call, run the following command:
  1026. # # auditctl -l | grep syscall | grep stime
  1027. # If the system is configured to audit this activity, it will return a line.
  1028. # If the system is not configured to audit time changes, this is a finding.
  1029. pending("Not applicable")
  1030. # Fix: On a 32-bit system, add the following to "/etc/audit/audit.rules":
  1031. # # audit_time_rules
  1032. # -a always,exit -F arch=b32 -S stime -k audit_time_rules
  1033. # On a 64-bit system, the "-S stime" is not necessary. The -k option allows for the specification of a key in string form that can be used for better reporting
  1034. # capability through ausearch and aureport. Multiple system calls can be defined on the same line to save space if desired, but is not required. See an example
  1035. # of multiple combined syscalls:
  1036. # -a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime
  1037. # -k audit_time_rules
  1038. end
  1039. # STIG Viewer Link: http://www.stigviewer.com/check/V-38526
  1040. it "V-38526 The system must not accept ICMPv4 secure redirect packets on any interface." do
  1041. # Check: The status of the "net.ipv4.conf.all.secure_redirects" kernel parameter can be queried by running the following command:
  1042. # $ sysctl net.ipv4.conf.all.secure_redirects
  1043. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1044. # If the correct value is not returned, this is a finding.
  1045. expect( linux_kernel_parameter('net.ipv4.conf.all.secure_redirects').value ).to equal(0)
  1046. # Fix: To set the runtime status of the "net.ipv4.conf.all.secure_redirects" kernel parameter, run the following command:
  1047. # # sysctl -w net.ipv4.conf.all.secure_redirects=0
  1048. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1049. # net.ipv4.conf.all.secure_redirects = 0
  1050. end
  1051. # STIG Viewer Link: http://www.stigviewer.com/check/V-38527
  1052. it "V-38527 The audit system must be configured to audit all attempts to alter system time through clock_settime." do
  1053. # Check: To determine if the system is configured to audit calls to the "clock_settime" system call, run the following command:
  1054. # # auditctl -l | grep syscall | grep clock_settime
  1055. # If the system is configured to audit this activity, it will return a line.
  1056. # If the system is not configured to audit time changes, this is a finding.
  1057. expect( command('auditctl -l | grep syscall | grep clock_settime') ).not_to return_stdout ""
  1058. # Fix: On a 32-bit system, add the following to "/etc/audit/audit.rules":
  1059. # # audit_time_rules
  1060. # -a always,exit -F arch=b32 -S clock_settime -k audit_time_rules
  1061. # On a 64-bit system, add the following to "/etc/audit/audit.rules":
  1062. # # audit_time_rules
  1063. # -a always,exit -F arch=b64 -S clock_settime -k audit_time_rules
  1064. # The -k option allows for the specification of a key in string form that can be used for better reporting capability through ausearch and aureport. Multiple system calls can be defined on the same line to save space if desired, but is not required. See an example of multiple combined syscalls:
  1065. # -a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime
  1066. # -k audit_time_rules
  1067. end
  1068. # STIG Viewer Link: http://www.stigviewer.com/check/V-38528
  1069. it "V-38528 The system must log Martian packets." do
  1070. # Check: The status of the "net.ipv4.conf.all.log_martians" kernel parameter can be queried by running the following command:
  1071. # $ sysctl net.ipv4.conf.all.log_martians
  1072. # The output of the command should indicate a value of "1". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1073. # If the correct value is not returned, this is a finding.
  1074. expect( linux_kernel_parameter('net.ipv4.conf.all.log_martians').value ).to equal(1)
  1075. # Fix: To set the runtime status of the "net.ipv4.conf.all.log_martians" kernel parameter, run the following command:
  1076. # # sysctl -w net.ipv4.conf.all.log_martians=1
  1077. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1078. # net.ipv4.conf.all.log_martians = 1
  1079. end
  1080. # STIG Viewer Link: http://www.stigviewer.com/check/V-38529
  1081. it "V-38529 The system must not accept IPv4 source-routed packets by default." do
  1082. # Check: The status of the "net.ipv4.conf.default.accept_source_route" kernel parameter can be queried by running the following command:
  1083. # $ sysctl net.ipv4.conf.default.accept_source_route
  1084. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1085. # If the correct value is not returned, this is a finding.
  1086. expect( linux_kernel_parameter('net.ipv4.conf.default.accept_source_route').value ).to equal(0)
  1087. # Fix: To set the runtime status of the "net.ipv4.conf.default.accept_source_route" kernel parameter, run the following command:
  1088. # # sysctl -w net.ipv4.conf.default.accept_source_route=0
  1089. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1090. # net.ipv4.conf.default.accept_source_route = 0
  1091. end
  1092. # STIG Viewer Link: http://www.stigviewer.com/check/V-38530
  1093. it "V-38530 The audit system must be configured to audit all attempts to alter system time through /etc/localtime." do
  1094. # Check: To determine if the system is configured to audit attempts to alter time via the /etc/localtime file, run the following command:
  1095. # # auditctl -l | grep "watch=/etc/localtime"
  1096. # If the system is configured to audit this activity, it will return a line.
  1097. # If the system is not configured to audit time changes, this is a finding.
  1098. expect( command('auditctl -l | grep "watch=/etc/localtime') ).not_to return_stdout ""
  1099. # Fix: Add the following to "/etc/audit/audit.rules":
  1100. # -w /etc/localtime -p wa -k audit_time_rules
  1101. # The -k option allows for the specification of a key in string form that can be used for better reporting capability through ausearch and aureport and should always be used.
  1102. end
  1103. # STIG Viewer Link: http://www.stigviewer.com/check/V-38531
  1104. it "V-38531 The operating system must automatically audit account creation." do
  1105. # Check: To determine if the system is configured to audit account changes, run the following command:
  1106. # auditctl -l | egrep '(/etc/passwd|/etc/shadow|/etc/group|/etc/gshadow|/etc/security/opasswd)'
  1107. # If the system is configured to watch for account changes, lines should be returned for each file specified (and with "perm=wa" for each).
  1108. # If the system is not configured to audit account changes, this is a finding.
  1109. expect( command(' auditctl -l | egrep \'/etc/passwd\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1110. expect( command(' auditctl -l | egrep \'/etc/shadow\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1111. expect( command(' auditctl -l | egrep \'/etc/group\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1112. expect( command(' auditctl -l | egrep \'/etc/gshadow\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1113. expect( command(' auditctl -l | egrep \'/etc/security/opasswd\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1114. # Fix: Add the following to "/etc/audit/audit.rules", in order to capture events that modify account changes:
  1115. # # audit_account_changes
  1116. # -w /etc/group -p wa -k audit_account_changes
  1117. # -w /etc/passwd -p wa -k audit_account_changes
  1118. # -w /etc/gshadow -p wa -k audit_account_changes
  1119. # -w /etc/shadow -p wa -k audit_account_changes
  1120. # -w /etc/security/opasswd -p wa -k audit_account_changes
  1121. end
  1122. # STIG Viewer Link: http://www.stigviewer.com/check/V-38532
  1123. it "V-38532 The system must not accept ICMPv4 secure redirect packets by default." do
  1124. # Check: The status of the "net.ipv4.conf.default.secure_redirects" kernel parameter can be queried by running the following command:
  1125. # $ sysctl net.ipv4.conf.default.secure_redirects
  1126. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1127. # If the correct value is not returned, this is a finding.
  1128. expect( linux_kernel_parameter('net.ipv4.conf.default.secure_redirects').value ).to equal(0)
  1129. # Fix: To set the runtime status of the "net.ipv4.conf.default.secure_redirects" kernel parameter, run the following command:
  1130. # # sysctl -w net.ipv4.conf.default.secure_redirects=0
  1131. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1132. # net.ipv4.conf.default.secure_redirects = 0
  1133. end
  1134. # STIG Viewer Link: http://www.stigviewer.com/check/V-38533
  1135. it "V-38533 The system must ignore IPv4 ICMP redirect messages." do
  1136. # Check: The status of the "net.ipv4.conf.default.accept_redirects" kernel parameter can be queried by running the following command:
  1137. # $ sysctl net.ipv4.conf.default.accept_redirects
  1138. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1139. # If the correct value is not returned, this is a finding.
  1140. expect( linux_kernel_parameter('net.ipv4.conf.default.accept_redirects').value ).to equal(0)
  1141. # Fix: To set the runtime status of the "net.ipv4.conf.default.accept_redirects" kernel parameter, run the following command:
  1142. # # sysctl -w net.ipv4.conf.default.accept_redirects=0
  1143. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1144. # net.ipv4.conf.default.accept_redirects = 0
  1145. end
  1146. # STIG Viewer Link: http://www.stigviewer.com/check/V-38534
  1147. it "V-38534 The operating system must automatically audit account modification." do
  1148. # Check: To determine if the system is configured to audit account changes, run the following command:
  1149. # auditctl -l | egrep '(/etc/passwd|/etc/shadow|/etc/group|/etc/gshadow|/etc/security/opasswd)'
  1150. # If the system is configured to watch for account changes, lines should be returned for each file specified (and with "perm=wa" for each).
  1151. # If the system is not configured to audit account changes, this is a finding.
  1152. expect( command(' auditctl -l | egrep \'/etc/passwd\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1153. expect( command(' auditctl -l | egrep \'/etc/shadow\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1154. expect( command(' auditctl -l | egrep \'/etc/group\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1155. expect( command(' auditctl -l | egrep \'/etc/gshadow\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1156. expect( command(' auditctl -l | egrep \'/etc/security/opasswd\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1157. # Fix: Add the following to "/etc/audit/audit.rules", in order to capture events that modify account changes:
  1158. # # audit_account_changes
  1159. # -w /etc/group -p wa -k audit_account_changes
  1160. # -w /etc/passwd -p wa -k audit_account_changes
  1161. # -w /etc/gshadow -p wa -k audit_account_changes
  1162. # -w /etc/shadow -p wa -k audit_account_changes
  1163. # -w /etc/security/opasswd -p wa -k audit_account_changes
  1164. end
  1165. # STIG Viewer Link: http://www.stigviewer.com/check/V-38535
  1166. it "V-38535 The system must not respond to ICMPv4 sent to a broadcast address." do
  1167. # Check: The status of the "net.ipv4.icmp_echo_ignore_broadcasts" kernel parameter can be queried by running the following command:
  1168. # $ sysctl net.ipv4.icmp_echo_ignore_broadcasts
  1169. # The output of the command should indicate a value of "1". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1170. # If the correct value is not returned, this is a finding.
  1171. expect( linux_kernel_parameter('net.ipv4.icmp_echo_ignore_broadcasts').value ).to equal(1)
  1172. # Fix: To set the runtime status of the "net.ipv4.icmp_echo_ignore_broadcasts" kernel parameter, run the following command:
  1173. # # sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1
  1174. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1175. # net.ipv4.icmp_echo_ignore_broadcasts = 1
  1176. end
  1177. # STIG Viewer Link: http://www.stigviewer.com/check/V-38536
  1178. it "V-38536 The operating system must automatically audit account disabling actions." do
  1179. # Check: To determine if the system is configured to audit account changes, run the following command:
  1180. # auditctl -l | egrep '(/etc/passwd|/etc/shadow|/etc/group|/etc/gshadow|/etc/security/opasswd)'
  1181. # If the system is configured to watch for account changes, lines should be returned for each file specified (and with "perm=wa" for each).
  1182. # If the system is not configured to audit account changes, this is a finding.
  1183. expect( command(' auditctl -l | egrep \'/etc/passwd\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1184. expect( command(' auditctl -l | egrep \'/etc/shadow\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1185. expect( command(' auditctl -l | egrep \'/etc/group\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1186. expect( command(' auditctl -l | egrep \'/etc/gshadow\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1187. expect( command(' auditctl -l | egrep \'/etc/security/opasswd\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1188. # Fix: Add the following to "/etc/audit/audit.rules", in order to capture events that modify account changes:
  1189. # # audit_account_changes
  1190. # -w /etc/group -p wa -k audit_account_changes
  1191. # -w /etc/passwd -p wa -k audit_account_changes
  1192. # -w /etc/gshadow -p wa -k audit_account_changes
  1193. # -w /etc/shadow -p wa -k audit_account_changes
  1194. # -w /etc/security/opasswd -p wa -k audit_account_changes
  1195. end
  1196. # STIG Viewer Link: http://www.stigviewer.com/check/V-38537
  1197. it "V-38537 The system must ignore ICMPv4 bogus error responses." do
  1198. # Check: The status of the "net.ipv4.icmp_ignore_bogus_error_responses" kernel parameter can be queried by running the following command:
  1199. # $ sysctl net.ipv4.icmp_ignore_bogus_error_responses
  1200. # The output of the command should indicate a value of "1". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1201. # If the correct value is not returned, this is a finding.
  1202. expect( linux_kernel_parameter('net.ipv4.icmp_ignore_bogus_error_responses').value ).to equal(1)
  1203. # Fix: To set the runtime status of the "net.ipv4.icmp_ignore_bogus_error_responses" kernel parameter, run the following command:
  1204. # # sysctl -w net.ipv4.icmp_ignore_bogus_error_responses=1
  1205. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1206. # net.ipv4.icmp_ignore_bogus_error_responses = 1
  1207. end
  1208. # STIG Viewer Link: http://www.stigviewer.com/check/V-38538
  1209. it "V-38538 The operating system must automatically audit account termination." do
  1210. # Check: To determine if the system is configured to audit account changes, run the following command:
  1211. # auditctl -l | egrep '(/etc/passwd|/etc/shadow|/etc/group|/etc/gshadow|/etc/security/opasswd)'
  1212. # If the system is configured to watch for account changes, lines should be returned for each file specified (and with "perm=wa" for each).
  1213. # If the system is not configured to audit account changes, this is a finding.
  1214. expect( command(' auditctl -l | egrep \'/etc/passwd\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1215. expect( command(' auditctl -l | egrep \'/etc/shadow\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1216. expect( command(' auditctl -l | egrep \'/etc/group\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1217. expect( command(' auditctl -l | egrep \'/etc/gshadow\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1218. expect( command(' auditctl -l | egrep \'/etc/security/opasswd\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1219. # Fix: Add the following to "/etc/audit/audit.rules", in order to capture events that modify account changes:
  1220. # # audit_account_changes
  1221. # -w /etc/group -p wa -k audit_account_changes
  1222. # -w /etc/passwd -p wa -k audit_account_changes
  1223. # -w /etc/gshadow -p wa -k audit_account_changes
  1224. # -w /etc/shadow -p wa -k audit_account_changes
  1225. # -w /etc/security/opasswd -p wa -k audit_account_changes
  1226. end
  1227. # STIG Viewer Link: http://www.stigviewer.com/check/V-38539
  1228. it "V-38539 The system must be configured to use TCP syncookies." do
  1229. # Check: The status of the "net.ipv4.tcp_syncookies" kernel parameter can be queried by running the following command:
  1230. # $ sysctl net.ipv4.tcp_syncookies
  1231. # The output of the command should indicate a value of "1". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1232. # If the correct value is not returned, this is a finding.
  1233. expect( linux_kernel_parameter('net.ipv4.tcp_syncookies').value ).to equal(1)
  1234. # Fix: To set the runtime status of the "net.ipv4.tcp_syncookies" kernel parameter, run the following command:
  1235. # # sysctl -w net.ipv4.tcp_syncookies=1
  1236. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1237. # net.ipv4.tcp_syncookies = 1
  1238. end
  1239. # STIG Viewer Link: http://www.stigviewer.com/check/V-38540
  1240. it "V-38540 The audit system must be configured to audit modifications to the systems network configuration." do
  1241. # Check: To determine if the system is configured to audit changes to its network configuration, run the following command:
  1242. # auditctl -l | egrep '(sethostname|setdomainname|/etc/issue|/etc/issue.net|/etc/hosts|/etc/sysconfig/network)'
  1243. # If the system is configured to watch for network configuration changes, a line should be returned for each file specified (and "perm=wa" should be indicated for each).
  1244. # If the system is not configured to audit changes of the network configuration, this is a finding.
  1245. expect( file('/etc/audit/audit.rules') ).to contain "-S sethostname"
  1246. expect( file('/etc/audit/audit.rules') ).to contain "-S setdomainname"
  1247. expect( command(' auditctl -l | egrep \'/etc/issue\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1248. expect( command(' auditctl -l | egrep \'/etc/issue.net\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1249. expect( command(' auditctl -l | egrep \'/etc/hosts\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1250. expect( command(' auditctl -l | egrep \'/etc/sysconfig/network\'|grep \'perm=wa\'') ).not_to return_stdout ""
  1251. # Fix: Add the following to "/etc/audit/audit.rules", setting ARCH to either b32 or b64 as appropriate for your system:
  1252. # # audit_network_modifications
  1253. # -a exit,always -F arch=ARCH -S sethostname -S setdomainname -k audit_network_modifications
  1254. # -w /etc/issue -p wa -k audit_network_modifications
  1255. # -w /etc/issue.net -p wa -k audit_network_modifications
  1256. # -w /etc/hosts -p wa -k audit_network_modifications
  1257. # -w /etc/sysconfig/network -p wa -k audit_network_modifications
  1258. end
  1259. # STIG Viewer Link: http://www.stigviewer.com/check/V-38541
  1260. it "V-38541 The audit system must be configured to audit modifications to the systems Mandatory Access Control (MAC) configuration (SELinux)." do
  1261. # Check: To determine if the system is configured to audit changes to its SELinux configuration files, run the following command:
  1262. # # auditctl -l | grep "dir=/etc/selinux"
  1263. # If the system is configured to watch for changes to its SELinux configuration, a line should be returned (including "perm=wa" indicating permissions that are watched).
  1264. # If the system is not configured to audit attempts to change the MAC policy, this is a finding.
  1265. expect( command('auditctl -l | grep "dir=/etc/selinux"|grep \'perm=wa\'') ).not_to return_stdout ""
  1266. # Fix: Add the following to "/etc/audit/audit.rules":
  1267. # -w /etc/selinux/ -p wa -k MAC-policy
  1268. end
  1269. # STIG Viewer Link: http://www.stigviewer.com/check/V-38542
  1270. it "V-38542 The system must use a reverse-path filter for IPv4 network traffic when possible on all interfaces." do
  1271. # Check: The status of the "net.ipv4.conf.all.rp_filter" kernel parameter can be queried by running the following command:
  1272. # $ sysctl net.ipv4.conf.all.rp_filter
  1273. # The output of the command should indicate a value of "1". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1274. # If the correct value is not returned, this is a finding.
  1275. expect( linux_kernel_parameter('net.ipv4.conf.all.rp_filter').value ).to equal(1)
  1276. # Fix: To set the runtime status of the "net.ipv4.conf.all.rp_filter" kernel parameter, run the following command:
  1277. # # sysctl -w net.ipv4.conf.all.rp_filter=1
  1278. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1279. # net.ipv4.conf.all.rp_filter = 1
  1280. end
  1281. # STIG Viewer Link: http://www.stigviewer.com/check/V-38543
  1282. it "V-38543 The audit system must be configured to audit all discretionary access control permission modifications using chmod." do
  1283. # Check: To determine if the system is configured to audit calls to the "chmod" system call, run the following command:
  1284. # # auditctl -l | grep syscall | grep chmod
  1285. # If the system is configured to audit this activity, it will return several lines.
  1286. # If no lines are returned, this is a finding.
  1287. expect( command('auditctl -l | grep syscall | grep chmod') ).not_to return_stdout ""
  1288. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1289. # -a always,exit -F arch=b32 -S chmod -F auid>=500 -F auid!=4294967295 \
  1290. # -k perm_mod
  1291. # -a always,exit -F arch=b32 -S chmod -F auid==0 -k perm_mod
  1292. # If the system is 64-bit, then also add the following:
  1293. # -a always,exit -F arch=b64 -S chmod -F auid>=500 -F auid!=4294967295 \
  1294. # -k perm_mod
  1295. # -a always,exit -F arch=b64 -S chmod -F auid==0 -k perm_mod
  1296. end
  1297. # STIG Viewer Link: http://www.stigviewer.com/check/V-38544
  1298. it "V-38544 The system must use a reverse-path filter for IPv4 network traffic when possible by default." do
  1299. # Check: The status of the "net.ipv4.conf.default.rp_filter" kernel parameter can be queried by running the following command:
  1300. # $ sysctl net.ipv4.conf.default.rp_filter
  1301. # The output of the command should indicate a value of "1". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1302. # If the correct value is not returned, this is a finding.
  1303. expect( linux_kernel_parameter('net.ipv4.conf.default.rp_filter').value ).to equal(1)
  1304. # Fix: To set the runtime status of the "net.ipv4.conf.default.rp_filter" kernel parameter, run the following command:
  1305. # # sysctl -w net.ipv4.conf.default.rp_filter=1
  1306. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1307. # net.ipv4.conf.default.rp_filter = 1
  1308. end
  1309. # STIG Viewer Link: http://www.stigviewer.com/check/V-38545
  1310. it "V-38545 The audit system must be configured to audit all discretionary access control permission modifications using chown." do
  1311. # Check: To determine if the system is configured to audit calls to the "chown" system call, run the following command:
  1312. # # auditctl -l | grep syscall | grep chown
  1313. # If the system is configured to audit this activity, it will return several lines.
  1314. # If no lines are returned, this is a finding.
  1315. expect( command('auditctl -l | grep syscall | grep chown') ).not_to return_stdout ""
  1316. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1317. # -a always,exit -F arch=b32 -S chown -F auid>=500 -F auid!=4294967295 \
  1318. # -k perm_mod
  1319. # -a always,exit -F arch=b32 -S chown -F auid==0 -k perm_mod
  1320. # If the system is 64-bit, then also add the following:
  1321. # -a always,exit -F arch=b64 -S chown -F auid>=500 -F auid!=4294967295 \
  1322. # -k perm_mod
  1323. # -a always,exit -F arch=b64 -S chown -F auid==0 -k perm_mod
  1324. end
  1325. # STIG Viewer Link: http://www.stigviewer.com/check/V-38546
  1326. it "V-38546 The IPv6 protocol handler must not be bound to the network stack unless needed." do
  1327. # Check: If the system uses IPv6, this is not applicable.
  1328. # If the system is configured to prevent the loading of the "ipv6" kernel module, it will contain a line of the form:
  1329. # options ipv6 disable=1
  1330. # Such lines may be inside any file in "/etc/modprobe.d" or the deprecated "/etc/modprobe.conf". This permits insertion of the IPv6 kernel module (which other parts of the system expect to be present), but otherwise keeps it inactive. Run the following command to search for such lines in all files in "/etc/modprobe.d" and the deprecated "/etc/modprobe.conf":
  1331. # $ grep -r ipv6 /etc/modprobe.conf /etc/modprobe.d
  1332. # If the IPv6 kernel module is loaded, this is a finding.
  1333. if $environment['ipv6Enabled']
  1334. pending("Not applicable")
  1335. else
  1336. expect( command('grep -r ipv6 /etc/modprobe.d') ).not_to return_stdout ""
  1337. end
  1338. # Fix: To prevent the IPv6 kernel module ("ipv6") from loading the IPv6 networking stack, add the following line to "/etc/modprobe.d/disabled.conf" (or another file in "/etc/modprobe.d"):
  1339. # options ipv6 disable=1
  1340. # This permits the IPv6 module to be loaded (and thus satisfy other modules that depend on it), while disabling support for the IPv6 protocol.
  1341. end
  1342. # STIG Viewer Link: http://www.stigviewer.com/check/V-38547
  1343. it "V-38547 The audit system must be configured to audit all discretionary access control permission modifications using fchmod." do
  1344. # Check: To determine if the system is configured to audit calls to the "fchmod" system call, run the following command:
  1345. # # auditctl -l | grep syscall | grep fchmod
  1346. # If the system is configured to audit this activity, it will return several lines.
  1347. # If no lines are returned, this is a finding.
  1348. expect( command('auditctl -l | grep syscall | grep fchmod') ).not_to return_stdout ""
  1349. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1350. # -a always,exit -F arch=b32 -S fchmod -F auid>=500 -F auid!=4294967295 \
  1351. # -k perm_mod
  1352. # -a always,exit -F arch=b32 -S fchmod -F auid==0 -k perm_mod
  1353. # If the system is 64-bit, then also add the following:
  1354. # -a always,exit -F arch=b64 -S fchmod -F auid>=500 -F auid!=4294967295 \
  1355. # -k perm_mod
  1356. # -a always,exit -F arch=b64 -S fchmod -F auid==0 -k perm_mod
  1357. end
  1358. # STIG Viewer Link: http://www.stigviewer.com/check/V-38548
  1359. it "V-38548 The system must ignore ICMPv6 redirects by default." do
  1360. # Check: The status of the "net.ipv6.conf.default.accept_redirects" kernel parameter can be queried by running the following command:
  1361. # $ sysctl net.ipv6.conf.default.accept_redirects
  1362. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1363. # If the correct value is not returned, this is a finding.
  1364. if $environment['ipv6Enabled']
  1365. expect( linux_kernel_parameter('net.ipv6.conf.default.accept_redirects').value ).to equal(0)
  1366. else
  1367. pending("Not applicable")
  1368. end
  1369. # Fix: To set the runtime status of the "net.ipv6.conf.default.accept_redirects" kernel parameter, run the following command:
  1370. # # sysctl -w net.ipv6.conf.default.accept_redirects=0
  1371. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  1372. # net.ipv6.conf.default.accept_redirects = 0
  1373. end
  1374. # STIG Viewer Link: http://www.stigviewer.com/check/V-38549
  1375. it "V-38549 The system must employ a local IPv6 firewall." do
  1376. # Check: If IPv6 is disabled, this is not applicable.
  1377. # Run the following command to determine the current status of the "ip6tables" service:
  1378. # # service ip6tables status
  1379. # If the service is enabled, it should return the following:
  1380. # ip6tables is running...
  1381. # If the service is not running, this is a finding.
  1382. if $environment['ipv6Enabled']
  1383. expect( linux_kernel_parameter('net.ipv6.conf.default.accept_redirects').value ).to equal(0)
  1384. else
  1385. pending("Not applicable")
  1386. end
  1387. # Fix: The "ip6tables" service can be enabled with the following command:
  1388. # # chkconfig ip6tables on
  1389. end
  1390. # STIG Viewer Link: http://www.stigviewer.com/check/V-38550
  1391. it "V-38550 The audit system must be configured to audit all discretionary access control permission modifications using fchmodat." do
  1392. # Check: To determine if the system is configured to audit calls to the "fchmodat" system call, run the following command:
  1393. # # auditctl -l | grep syscall | grep fchmodat
  1394. # If the system is configured to audit this activity, it will return several lines.
  1395. # If no lines are returned, this is a finding.
  1396. expect( command('auditctl -l | grep syscall | grep fchmodat') ).not_to return_stdout ""
  1397. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1398. # -a always,exit -F arch=b32 -S fchmodat -F auid>=500 -F auid!=4294967295 \
  1399. # -k perm_mod
  1400. # -a always,exit -F arch=b32 -S fchmodat -F auid==0 -k perm_mod
  1401. # If the system is 64-bit, then also add the following:
  1402. # -a always,exit -F arch=b64 -S fchmodat -F auid>=500 -F auid!=4294967295 \
  1403. # -k perm_mod
  1404. # -a always,exit -F arch=b64 -S fchmodat -F auid==0 -k perm_mod
  1405. end
  1406. # STIG Viewer Link: http://www.stigviewer.com/check/V-38551
  1407. it "V-38551 The operating system must connect to external networks or information systems only through managed IPv6 interfaces consisting of boundary protection devices arranged in accordance with an organizational security architecture." do
  1408. # Check: If IPv6 is disabled, this is not applicable.
  1409. # Run the following command to determine the current status of the "ip6tables" service:
  1410. # # service ip6tables status
  1411. # If the service is enabled, it should return the following:
  1412. # ip6tables is running...
  1413. # If the service is not running, this is a finding.
  1414. if $environment['ipv6Enabled']
  1415. expect( service('ip6tables')).to be_running
  1416. else
  1417. pending("Not applicable")
  1418. end
  1419. # Fix: The "ip6tables" service can be enabled with the following command:
  1420. # # chkconfig ip6tables on
  1421. end
  1422. # STIG Viewer Link: http://www.stigviewer.com/check/V-38552
  1423. it "V-38552 The audit system must be configured to audit all discretionary access control permission modifications using fchown." do
  1424. # Check: To determine if the system is configured to audit calls to the "fchown" system call, run the following command:
  1425. # # auditctl -l | grep syscall | grep fchown
  1426. # If the system is configured to audit this activity, it will return several lines.
  1427. # If no lines are returned, this is a finding.
  1428. expect( command('auditctl -l | grep syscall | grep fchown') ).not_to return_stdout ""
  1429. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1430. # -a always,exit -F arch=b32 -S fchown -F auid>=500 -F auid!=4294967295 \
  1431. # -k perm_mod
  1432. # -a always,exit -F arch=b32 -S fchown -F auid==0 -k perm_mod
  1433. # If the system is 64-bit, then also add the following:
  1434. # -a always,exit -F arch=b64 -S fchown -F auid>=500 -F auid!=4294967295 \
  1435. # -k perm_mod
  1436. # -a always,exit -F arch=b64 -S fchown -F auid==0 -k perm_mod
  1437. end
  1438. # STIG Viewer Link: http://www.stigviewer.com/check/V-38553
  1439. it "V-38553 The operating system must prevent public IPv6 access into an organizations internal networks, except as appropriately mediated by managed interfaces employing boundary protection devices." do
  1440. # Check: If IPv6 is disabled, this is not applicable.
  1441. # Run the following command to determine the current status of the "ip6tables" service:
  1442. # # service ip6tables status
  1443. # If the service is enabled, it should return the following:
  1444. # ip6tables is running...
  1445. # If the service is not running, this is a finding.
  1446. if $environment['ipv6Enabled']
  1447. expect( service('ip6tables')).to be_enabled
  1448. else
  1449. pending("Not applicable")
  1450. end
  1451. # Fix: The "ip6tables" service can be enabled with the following command:
  1452. # # chkconfig ip6tables on
  1453. end
  1454. # STIG Viewer Link: http://www.stigviewer.com/check/V-38554
  1455. it "V-38554 The audit system must be configured to audit all discretionary access control permission modifications using fchownat." do
  1456. # Check: To determine if the system is configured to audit calls to the "fchownat" system call, run the following command:
  1457. # # auditctl -l | grep syscall | grep fchownat
  1458. # If the system is configured to audit this activity, it will return several lines.
  1459. # If no lines are returned, this is a finding.
  1460. expect( command('auditctl -l | grep syscall | grep fchownat') ).not_to return_stdout ""
  1461. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1462. # -a always,exit -F arch=b32 -S fchownat -F auid>=500 -F auid!=4294967295 \
  1463. # -k perm_mod
  1464. # -a always,exit -F arch=b32 -S fchownat -F auid==0 -k perm_mod
  1465. # If the system is 64-bit, then also add the following:
  1466. # -a always,exit -F arch=b64 -S fchownat -F auid>=500 -F auid!=4294967295 \
  1467. # -k perm_mod
  1468. # -a always,exit -F arch=b64 -S fchownat -F auid==0 -k perm_mod
  1469. end
  1470. # STIG Viewer Link: http://www.stigviewer.com/check/V-38555
  1471. it "V-38555 The system must employ a local IPv4 firewall." do
  1472. # Check: If the system is a cross-domain system, this is not applicable.
  1473. # Run the following command to determine the current status of the "iptables" service:
  1474. # # service iptables status
  1475. # If the service is enabled, it should return the following:
  1476. # iptables is running...
  1477. # If the service is not running, this is a finding.
  1478. expect( service('iptables')).to be_running
  1479. if $environment['ipv6Enabled']
  1480. expect( service('ip6tables')).to be_running
  1481. end
  1482. # Fix: The "iptables" service can be enabled with the following command:
  1483. # # chkconfig iptables on
  1484. end
  1485. # STIG Viewer Link: http://www.stigviewer.com/check/V-38556
  1486. it "V-38556 The audit system must be configured to audit all discretionary access control permission modifications using fremovexattr." do
  1487. # Check: To determine if the system is configured to audit calls to the "fremovexattr" system call, run the following command:
  1488. # # auditctl -l | grep syscall | grep fremovexattr
  1489. # If the system is configured to audit this activity, it will return several lines.
  1490. # If no lines are returned, this is a finding.
  1491. expect( command('auditctl -l | grep syscall | grep fremovexattr') ).not_to return_stdout ""
  1492. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1493. # -a always,exit -F arch=b32 -S fremovexattr -F auid>=500 -F auid!=4294967295 \
  1494. # -k perm_mod
  1495. # -a always,exit -F arch=b32 -S fremovexattr -F auid==0 -k perm_mod
  1496. # If the system is 64-bit, then also add the following:
  1497. # -a always,exit -F arch=b64 -S fremovexattr -F auid>=500 -F auid!=4294967295 \
  1498. # -k perm_mod
  1499. # -a always,exit -F arch=b64 -S fremovexattr -F auid==0 -k perm_mod
  1500. end
  1501. # STIG Viewer Link: http://www.stigviewer.com/check/V-38557
  1502. it "V-38557 The audit system must be configured to audit all discretionary access control permission modifications using fsetxattr." do
  1503. # Check: To determine if the system is configured to audit calls to the "fsetxattr" system call, run the following command:
  1504. # # auditctl -l | grep syscall | grep fsetxattr
  1505. # If the system is configured to audit this activity, it will return several lines.
  1506. # If no lines are returned, this is a finding.
  1507. expect( command('auditctl -l | grep syscall | grep fsetxattr') ).not_to return_stdout ""
  1508. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1509. # -a always,exit -F arch=b32 -S fsetxattr -F auid>=500 -F auid!=4294967295 \
  1510. # -k perm_mod
  1511. # -a always,exit -F arch=b32 -S fsetxattr -F auid==0 -k perm_mod
  1512. # If the system is 64-bit, then also add the following:
  1513. # -a always,exit -F arch=b64 -S fsetxattr -F auid>=500 -F auid!=4294967295 \
  1514. # -k perm_mod
  1515. # -a always,exit -F arch=b64 -S fsetxattr -F auid==0 -k perm_mod
  1516. end
  1517. # STIG Viewer Link: http://www.stigviewer.com/check/V-38558
  1518. it "V-38558 The audit system must be configured to audit all discretionary access control permission modifications using lchown." do
  1519. # Check: To determine if the system is configured to audit calls to the "lchown" system call, run the following command:
  1520. # # auditctl -l | grep syscall | grep lchown
  1521. # If the system is configured to audit this activity, it will return several lines.
  1522. # If no lines are returned, this is a finding.
  1523. expect( command('auditctl -l | grep syscall | grep lchown') ).not_to return_stdout ""
  1524. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1525. # -a always,exit -F arch=b32 -S lchown -F auid>=500 -F auid!=4294967295 \
  1526. # -k perm_mod
  1527. # -a always,exit -F arch=b32 -S lchown -F auid==0 -k perm_mod
  1528. # If the system is 64-bit, then also add the following:
  1529. # -a always,exit -F arch=b64 -S lchown -F auid>=500 -F auid!=4294967295 \
  1530. # -k perm_mod
  1531. # -a always,exit -F arch=b64 -S lchown -F auid==0 -k perm_mod
  1532. end
  1533. # STIG Viewer Link: http://www.stigviewer.com/check/V-38559
  1534. it "V-38559 The audit system must be configured to audit all discretionary access control permission modifications using lremovexattr." do
  1535. # Check: To determine if the system is configured to audit calls to the "lremovexattr" system call, run the following command:
  1536. # # auditctl -l | grep syscall | grep lremovexattr
  1537. # If the system is configured to audit this activity, it will return several lines.
  1538. # If no lines are returned, this is a finding.
  1539. expect( command('auditctl -l | grep syscall | grep lremovexattr') ).not_to return_stdout ""
  1540. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1541. # -a always,exit -F arch=b32 -S lremovexattr -F auid>=500 -F auid!=4294967295 \
  1542. # -k perm_mod
  1543. # -a always,exit -F arch=b32 -S lremovexattr -F auid==0 -k perm_mod
  1544. # If the system is 64-bit, then also add the following:
  1545. # -a always,exit -F arch=b64 -S lremovexattr -F auid>=500 -F auid!=4294967295 \
  1546. # -k perm_mod
  1547. # -a always,exit -F arch=b64 -S lremovexattr -F auid==0 -k perm_mod
  1548. end
  1549. # STIG Viewer Link: http://www.stigviewer.com/check/V-38560
  1550. it "V-38560 The operating system must connect to external networks or information systems only through managed IPv4 interfaces consisting of boundary protection devices arranged in accordance with an organizational security architecture." do
  1551. # Check: If the system is a cross-domain system, this is not applicable.
  1552. # Run the following command to determine the current status of the "iptables" service:
  1553. # # service iptables status
  1554. # If the service is enabled, it should return the following:
  1555. # iptables is running...
  1556. # If the service is not running, this is a finding.
  1557. expect( service('iptables')).to be_enabled
  1558. if $environment['ipv6Enabled']
  1559. expect( service('ip6tables')).to be_enabled
  1560. end
  1561. # Fix: The "iptables" service can be enabled with the following command:
  1562. # # chkconfig iptables on
  1563. end
  1564. # STIG Viewer Link: http://www.stigviewer.com/check/V-38561
  1565. it "V-38561 The audit system must be configured to audit all discretionary access control permission modifications using lsetxattr." do
  1566. # Check: To determine if the system is configured to audit calls to the "lsetxattr" system call, run the following command:
  1567. # # auditctl -l | grep syscall | grep lsetxattr
  1568. # If the system is configured to audit this activity, it will return several lines.
  1569. # If no lines are returned, this is a finding.
  1570. expect( command('auditctl -l | grep syscall | grep lsetxattr') ).not_to return_stdout ""
  1571. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1572. # -a always,exit -F arch=b32 -S lsetxattr -F auid>=500 -F auid!=4294967295 \
  1573. # -k perm_mod
  1574. # -a always,exit -F arch=b32 -S lsetxattr -F auid==0 -k perm_mod
  1575. # If the system is 64-bit, then also add the following:
  1576. # -a always,exit -F arch=b64 -S lsetxattr -F auid>=500 -F auid!=4294967295 \
  1577. # -k perm_mod
  1578. # -a always,exit -F arch=b64 -S lsetxattr -F auid==0 -k perm_mod
  1579. end
  1580. # STIG Viewer Link: http://www.stigviewer.com/check/V-38563
  1581. it "V-38563 The audit system must be configured to audit all discretionary access control permission modifications using removexattr." do
  1582. # Check: To determine if the system is configured to audit calls to the "removexattr" system call, run the following command:
  1583. # # auditctl -l | grep syscall | grep removexattr
  1584. # If the system is configured to audit this activity, it will return several lines.
  1585. # If no lines are returned, this is a finding.
  1586. expect( command('auditctl -l | grep syscall | grep removexattr') ).not_to return_stdout ""
  1587. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1588. # -a always,exit -F arch=b32 -S removexattr -F auid>=500 -F auid!=4294967295 \
  1589. # -k perm_mod
  1590. # -a always,exit -F arch=b32 -S removexattr -F auid==0 -k perm_mod
  1591. # If the system is 64-bit, then also add the following:
  1592. # -a always,exit -F arch=b64 -S removexattr -F auid>=500 -F auid!=4294967295 \
  1593. # -k perm_mod
  1594. # -a always,exit -F arch=b64 -S removexattr -F auid==0 -k perm_mod
  1595. end
  1596. # STIG Viewer Link: http://www.stigviewer.com/check/V-38565
  1597. it "V-38565 The audit system must be configured to audit all discretionary access control permission modifications using setxattr." do
  1598. # Check: To determine if the system is configured to audit calls to the "setxattr" system call, run the following command:
  1599. # # auditctl -l | grep syscall | grep setxattr
  1600. # If the system is configured to audit this activity, it will return several lines.
  1601. # If no lines are returned, this is a finding.
  1602. expect( command('auditctl -l | grep syscall | grep setxattr') ).not_to return_stdout ""
  1603. # Fix: At a minimum, the audit system should collect file permission changes for all users and root. Add the following to "/etc/audit/audit.rules":
  1604. # -a always,exit -F arch=b32 -S setxattr -F auid>=500 -F auid!=4294967295 \
  1605. # -k perm_mod
  1606. # -a always,exit -F arch=b32 -S setxattr -F auid==0 -k perm_mod
  1607. # If the system is 64-bit, then also add the following:
  1608. # -a always,exit -F arch=b64 -S setxattr -F auid>=500 -F auid!=4294967295 \
  1609. # -k perm_mod
  1610. # -a always,exit -F arch=b64 -S setxattr -F auid==0 -k perm_mod
  1611. end
  1612. # STIG Viewer Link: http://www.stigviewer.com/check/V-38566
  1613. it "V-38566 The audit system must be configured to audit failed attempts to access files and programs." do
  1614. # Check: To verify that the audit system collects unauthorized file accesses, run the following commands:
  1615. # # grep EACCES /etc/audit/audit.rules
  1616. # # grep EPERM /etc/audit/audit.rules
  1617. # If either command lacks output, this is a finding.
  1618. expect( command('grep EACCES /etc/audit/audit.rules') ).not_to return_stdout ""
  1619. expect( command('grep EPERM /etc/audit/audit.rules') ).not_to return_stdout ""
  1620. # Fix: At a minimum, the audit system should collect unauthorized file accesses for all users and root. Add the following to "/etc/audit/audit.rules", setting ARCH to either b32 or b64 as appropriate for your system:
  1621. # -a always,exit -F arch=ARCH -S creat -S open -S openat -S truncate \
  1622. # -S ftruncate -F exit=-EACCES -F auid>=500 -F auid!=4294967295 -k access
  1623. # -a always,exit -F arch=ARCH -S creat -S open -S openat -S truncate \
  1624. # -S ftruncate -F exit=-EPERM -F auid>=500 -F auid!=4294967295 -k access
  1625. # -a always,exit -F arch=ARCH -S creat -S open -S openat -S truncate \
  1626. # -S ftruncate -F exit=-EACCES -F auid==0 -k access
  1627. # -a always,exit -F arch=ARCH -S creat -S open -S openat -S truncate \
  1628. # -S ftruncate -F exit=-EPERM -F auid==0 -k access
  1629. end
  1630. # STIG Viewer Link: http://www.stigviewer.com/check/V-38567
  1631. it "V-38567 The audit system must be configured to audit all use of setuid programs." do
  1632. # Check: To verify that auditing of privileged command use is configured, run the following command to find relevant setuid programs:
  1633. # # find / -xdev -type f -perm -4000 -o -perm -2000 2>/dev/null
  1634. # Run the following command to verify entries in the audit rules for all programs found with the previous command:
  1635. # # grep path /etc/audit/audit.rules
  1636. # It should be the case that all relevant setuid programs have a line in the audit rules.
  1637. # If it is not the case, this is a finding.
  1638. pathLines = command('find / -xdev -type f -perm -4000 -o -perm -2000 2>/dev/null').stdout.strip
  1639. pathLines.each_line do |line|
  1640. expect( command("grep '#{line.chomp}' /etc/audit/audit.rules")).not_to return_stdout ""
  1641. end
  1642. # Fix: At a minimum, the audit system should collect the execution of privileged commands for all users and root. To find the relevant setuid programs:
  1643. # # find / -xdev -type f -perm -4000 -o -perm -2000 2>/dev/null
  1644. # Then, for each setuid program on the system, add a line of the following form to "/etc/audit/audit.rules", where [SETUID_PROG_PATH] is the full path to each setuid program in the list:
  1645. # -a always,exit -F path=[SETUID_PROG_PATH] -F perm=x -F auid>=500 -F auid!=4294967295 -k privileged
  1646. end
  1647. # STIG Viewer Link: http://www.stigviewer.com/check/V-38568
  1648. it "V-38568 The audit system must be configured to audit successful file system mounts." do
  1649. # Check: To verify that auditing is configured for all media exportation events, run the following command:
  1650. # # auditctl -l | grep syscall | grep mount
  1651. # If there is no output, this is a finding.
  1652. expect( command('auditctl -l | grep syscall | grep mount') ).not_to return_stdout ""
  1653. # Fix: At a minimum, the audit system should collect media exportation events for all users and root. Add the following to "/etc/audit/audit.rules", setting ARCH to either b32 or b64 as appropriate for your system:
  1654. # -a always,exit -F arch=ARCH -S mount -F auid>=500 -F auid!=4294967295 -k export
  1655. # -a always,exit -F arch=ARCH -S mount -F auid==0 -k export
  1656. end
  1657. # STIG Viewer Link: http://www.stigviewer.com/check/V-38569
  1658. it "V-38569 The system must require passwords to contain at least one uppercase alphabetic character." do
  1659. # Check: To check how many uppercase characters are required in a password, run the following command:
  1660. # $ grep pam_cracklib /etc/pam.d/system-auth
  1661. # The "ucredit" parameter (as a negative number) will indicate how many uppercase characters are required. The DoD requires at least one uppercase character in a password. This would appear as "ucredit=-1".
  1662. # If ucredit is not found or not set to the required value, this is a finding.
  1663. expect( file('/etc/pam.d/system-auth-ac') ).to contain "ucredit=-1"
  1664. # Fix: The pam_cracklib module's "ucredit=" parameter controls requirements for usage of uppercase letters in a password. When set to a negative number, any password will be required to contain that many uppercase characters. When set to a positive number, pam_cracklib will grant +1 additional length credit for each uppercase character. Add "ucredit=-1" after pam_cracklib.so to require use of an uppercase character in passwords.
  1665. end
  1666. # STIG Viewer Link: http://www.stigviewer.com/check/V-38570
  1667. it "V-38570 The system must require passwords to contain at least one special character." do
  1668. # Check: To check how many special characters are required in a password, run the following command:
  1669. # $ grep pam_cracklib /etc/pam.d/system-auth
  1670. # The "ocredit" parameter (as a negative number) will indicate how many special characters are required. The DoD requires at least one special character in a password. This would appear as "ocredit=-1".
  1671. # If ocredit is not found or not set to the required value, this is a finding.
  1672. expect( file('/etc/pam.d/system-auth-ac') ).to contain "ocredit=-1"
  1673. # Fix: The pam_cracklib module's "ocredit=" parameter controls requirements for usage of special (or ``other'') characters in a password. When set to a negative number, any password will be required to contain that many special characters. When set to a positive number, pam_cracklib will grant +1 additional length credit for each special character. Add "ocredit=-1" after pam_cracklib.so to require use of a special character in passwords.
  1674. end
  1675. # STIG Viewer Link: http://www.stigviewer.com/check/V-38571
  1676. it "V-38571 The system must require passwords to contain at least one lowercase alphabetic character." do
  1677. # Check: To check how many lowercase characters are required in a password, run the following command:
  1678. # $ grep pam_cracklib /etc/pam.d/system-auth
  1679. # The "lcredit" parameter (as a negative number) will indicate how many special characters are required. The DoD requires at least one lowercase character in a password. This would appear as "lcredit=-1".
  1680. # If lcredit is not found or not set to the required value, this is a finding.
  1681. expect( file('/etc/pam.d/system-auth-ac') ).to contain "lcredit=-1"
  1682. # Fix: The pam_cracklib module's "lcredit=" parameter controls requirements for usage of lowercase letters in a password. When set to a negative number, any password will be required to contain that many lowercase characters. When set to a positive number, pam_cracklib will grant +1 additional length credit for each lowercase character. Add "lcredit=-1" after pam_cracklib.so to require use of a lowercase character in passwords.
  1683. end
  1684. # STIG Viewer Link: http://www.stigviewer.com/check/V-38572
  1685. it "V-38572 The system must require at least four characters be changed between the old and new passwords during a password change." do
  1686. # Check: To check how many characters must differ during a password change, run the following command:
  1687. # $ grep pam_cracklib /etc/pam.d/system-auth
  1688. # The "difok" parameter will indicate how many characters must differ. The DoD requires four characters differ during a password change. This would appear as "difok=4".
  1689. # If difok is not found or not set to the required value, this is a finding.
  1690. expect( file('/etc/pam.d/system-auth-ac') ).to contain "difok=4"
  1691. # Fix: The pam_cracklib module's "difok" parameter controls requirements for usage of different characters during a password change. Add "difok=[NUM]" after pam_cracklib.so to require differing characters when changing passwords, substituting [NUM] appropriately. The DoD requirement is 4.
  1692. end
  1693. # STIG Viewer Link: http://www.stigviewer.com/check/V-38573
  1694. it "V-38573 The system must disable accounts after three consecutive unsuccessful login attempts." do
  1695. # Check: To ensure the failed password attempt policy is configured correctly, run the following command:
  1696. # # grep pam_faillock /etc/pam.d/system-auth-ac
  1697. # The output should show "deny=3".
  1698. # If that is not the case, this is a finding.
  1699. expect( file('/etc/pam.d/system-auth-ac') ).to contain "deny=3"
  1700. # Fix: To configure the system to lock out accounts after a number of incorrect login attempts using "pam_faillock.so":
  1701. # Add the following lines immediately below the "pam_unix.so" statement in the AUTH section of "/etc/pam.d/system-auth-ac":
  1702. # auth [default=die] pam_faillock.so authfail deny=3 unlock_time=604800 fail_interval=900
  1703. # auth required pam_faillock.so authsucc deny=3 unlock_time=604800 fail_interval=900
  1704. # Note that any updates made to "/etc/pam.d/system-auth-ac" will be overwritten by the "authconfig" program. The "authconfig" program should not be used.
  1705. end
  1706. # STIG Viewer Link: http://www.stigviewer.com/check/V-38574
  1707. it "V-38574 The system must use a FIPS 140-2 approved cryptographic hashing algorithm for generating account password hashes (system-auth)." do
  1708. # Check: Inspect the "password" section of "/etc/pam.d/system-auth" and ensure that the "pam_unix.so" module includes the argument "sha512".
  1709. # $ grep sha512 /etc/pam.d/system-auth"
  1710. # If it does not, this is a finding.
  1711. expect( file('/etc/pam.d/system-auth-ac') ).to contain "sha512"
  1712. # Fix: In "/etc/pam.d/system-auth", the "password" section of the file controls which PAM modules execute during a password change. Set the "pam_unix.so" module in the "password" section to include the argument "sha512", as shown below:
  1713. # password sufficient pam_unix.so sha512 [other arguments...]
  1714. # This will help ensure when local users change their passwords, hashes for the new passwords will be generated using the SHA-512 algorithm. This is the default.
  1715. # Note that any updates made to "/etc/pam.d/system-auth" will be overwritten by the "authconfig" program. The "authconfig" program should not be used.
  1716. end
  1717. # STIG Viewer Link: http://www.stigviewer.com/check/V-38575
  1718. it "V-38575 The audit system must be configured to audit user deletions of files and programs." do
  1719. # Check: To determine if the system is configured to audit calls to the "unlink" system call, run the following command:
  1720. # # auditctl -l | grep syscall | grep unlink | grep -v unlinkat
  1721. # If the system is configured to audit this activity, it will return several lines.
  1722. # To determine if the system is configured to audit calls to the "unlinkat" system call, run the following command:
  1723. # # auditctl -l | grep syscall | grep unlinkat
  1724. # If the system is configured to audit this activity, it will return several lines. To determine if the system is configured to audit calls to the "rename" system call, run the following command:
  1725. # # auditctl -l | grep syscall | grep rename | grep -v renameat
  1726. # If the system is configured to audit this activity, it will return several lines. To determine if the system is configured to audit calls to the "renameat" system call, run the following command:
  1727. # # auditctl -l | grep syscall | grep renameat
  1728. # If the system is configured to audit this activity, it will return several lines.
  1729. # If no line is returned, this is a finding.
  1730. expect( command('auditctl -l | grep syscall | grep unlink') ).not_to return_stdout ""
  1731. expect( command('auditctl -l | grep syscall | grep unlinkat') ).not_to return_stdout ""
  1732. expect( command('auditctl -l | grep syscall | grep rename') ).not_to return_stdout ""
  1733. expect( command('auditctl -l | grep syscall | grep renameat') ).not_to return_stdout ""
  1734. # Fix: At a minimum, the audit system should collect file deletion events for all users and root. Add the following to "/etc/audit/audit.rules", setting ARCH to either b32 or b64 as appropriate for your system:
  1735. # -a always,exit -F arch=ARCH -S unlink -S unlinkat -S rename -S renameat \
  1736. # -F auid>=500 -F auid!=4294967295 -k delete
  1737. # -a always,exit -F arch=ARCH -S unlink -S unlinkat -S rename -S renameat \
  1738. # -F auid==0 -k delete
  1739. end
  1740. # STIG Viewer Link: http://www.stigviewer.com/check/V-38576
  1741. it "V-38576 The system must use a FIPS 140-2 approved cryptographic hashing algorithm for generating account password hashes (login.defs)." do
  1742. # Check: Inspect "/etc/login.defs" and ensure the following line appears:
  1743. # ENCRYPT_METHOD SHA512
  1744. # If it does not, this is a finding.
  1745. expect( file('/etc/login.defs') ).to contain /^ENCRYPT_METHOD SHA512/
  1746. # Fix: In "/etc/login.defs", add or correct the following line to ensure the system will use SHA-512 as the hashing algorithm:
  1747. # ENCRYPT_METHOD SHA512
  1748. end
  1749. # STIG Viewer Link: http://www.stigviewer.com/check/V-38577
  1750. it "V-38577 The system must use a FIPS 140-2 approved cryptographic hashing algorithm for generating account password hashes (libuser.conf)." do
  1751. # Check: Inspect "/etc/libuser.conf" and ensure the following line appears in the "[default]" section:
  1752. # crypt_style = sha512
  1753. # If it does not, this is a finding.
  1754. expect( file('/etc/libuser.conf') ).to contain /^crypt_style = sha512/
  1755. # Fix: In "/etc/libuser.conf", add or correct the following line in its "[defaults]" section to ensure the system will use the SHA-512 algorithm for password hashing:
  1756. # crypt_style = sha512
  1757. end
  1758. # STIG Viewer Link: http://www.stigviewer.com/check/V-38578
  1759. it "V-38578 The audit system must be configured to audit changes to the /etc/sudoers file." do
  1760. # Check: To verify that auditing is configured for system administrator actions, run the following command:
  1761. # # auditctl -l | grep "watch=/etc/sudoers"
  1762. # If there is no output, this is a finding.
  1763. expect( command('auditctl -l | grep "watch=/etc/sudoers"') ).not_to return_stdout ""
  1764. # Fix: At a minimum, the audit system should collect administrator actions for all users and root. Add the following to "/etc/audit/audit.rules":
  1765. # -w /etc/sudoers -p wa -k actions
  1766. end
  1767. # STIG Viewer Link: http://www.stigviewer.com/check/V-38579
  1768. it "V-38579 The system boot loader configuration file(s) must be owned by root." do
  1769. # Check: To check the ownership of "/etc/grub.conf", run the command:
  1770. # $ ls -lL /etc/grub.conf
  1771. # If properly configured, the output should indicate the following owner: "root"
  1772. # If it does not, this is a finding.
  1773. expect( file('/etc/grub.conf')).to be_owned_by 'root'
  1774. # Fix: The file "/etc/grub.conf" should be owned by the "root" user to prevent destruction or modification of the file. To properly set the owner of "/etc/grub.conf", run the command:
  1775. # # chown root /etc/grub.conf
  1776. end
  1777. # STIG Viewer Link: http://www.stigviewer.com/check/V-38580
  1778. it "V-38580 The audit system must be configured to audit the loading and unloading of dynamic kernel modules." do
  1779. # Check: To determine if the system is configured to audit calls to the "init_module" system call, run the following command:
  1780. # # auditctl -l | grep syscall | grep init_module
  1781. # If the system is configured to audit this activity, it will return a line. To determine if the system is configured to audit calls to the "delete_module" system call, run the following command:
  1782. # # auditctl -l | grep syscall | grep delete_module
  1783. # If the system is configured to audit this activity, it will return a line.
  1784. # If no line is returned, this is a finding.
  1785. expect( command('auditctl -l | grep syscall | grep init_module') ).not_to return_stdout ""
  1786. expect( command('auditctl -l | grep syscall | grep delete_module') ).not_to return_stdout ""
  1787. # Fix: Add the following to "/etc/audit/audit.rules" in order to capture kernel module loading and unloading events, setting ARCH to either b32 or b64 as appropriate for your system:
  1788. # -w /sbin/insmod -p x -k modules
  1789. # -w /sbin/rmmod -p x -k modules
  1790. # -w /sbin/modprobe -p x -k modules
  1791. # -a always,exit -F arch=[ARCH] -S init_module -S delete_module -k modules
  1792. end
  1793. # STIG Viewer Link: http://www.stigviewer.com/check/V-38581
  1794. it "V-38581 The system boot loader configuration file(s) must be group-owned by root." do
  1795. # Check: To check the group ownership of "/etc/grub.conf", run the command:
  1796. # $ ls -lL /etc/grub.conf
  1797. # If properly configured, the output should indicate the following group-owner. "root"
  1798. # If it does not, this is a finding.
  1799. expect( file('/etc/grub.conf')).to be_grouped_into 'root'
  1800. # Fix: The file "/etc/grub.conf" should be group-owned by the "root" group to prevent destruction or modification of the file. To properly set the group owner of "/etc/grub.conf", run the command:
  1801. # # chgrp root /etc/grub.conf
  1802. end
  1803. # STIG Viewer Link: http://www.stigviewer.com/check/V-38582
  1804. it "V-38582 The xinetd service must be disabled if no network services utilizing it are enabled." do
  1805. # Check: If network services are using the xinetd service, this is not applicable.
  1806. # To check that the "xinetd" service is disabled in system boot configuration, run the following command:
  1807. # # chkconfig "xinetd" --list
  1808. # Output should indicate the "xinetd" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  1809. # # chkconfig "xinetd" --list
  1810. # "xinetd" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  1811. # Run the following command to verify "xinetd" is disabled through current runtime configuration:
  1812. # # service xinetd status
  1813. # If the service is disabled the command will return the following output:
  1814. # xinetd is stopped
  1815. # If the service is running, this is a finding.
  1816. expect( service('xinetd')).not_to be_enabled
  1817. expect( service('xinetd')).not_to be_running
  1818. # Fix: The "xinetd" service can be disabled with the following command:
  1819. # # chkconfig xinetd off
  1820. end
  1821. # STIG Viewer Link: http://www.stigviewer.com/check/V-38583
  1822. it "V-38583 The system boot loader configuration file(s) must have mode 0600 or less permissive." do
  1823. # Check: To check the permissions of "/etc/grub.conf", run the command:
  1824. # $ ls -lL /etc/grub.conf
  1825. # If properly configured, the output should indicate the following permissions: "-rw-------"
  1826. # If it does not, this is a finding.
  1827. expect( file('/etc/grub.conf')).to be_mode 600
  1828. # Fix: File permissions for "/etc/grub.conf" should be set to 600, which is the default. To properly set the permissions of "/etc/grub.conf", run the command:
  1829. # # chmod 600 /etc/grub.conf
  1830. end
  1831. # STIG Viewer Link: http://www.stigviewer.com/check/V-38584
  1832. it "V-38584 The xinetd service must be uninstalled if no network services utilizing it are enabled." do
  1833. # Check: If network services are using the xinetd service, this is not applicable.
  1834. # Run the following command to determine if the "xinetd" package is installed:
  1835. # # rpm -q xinetd
  1836. # If the package is installed, this is a finding.
  1837. expect( package('xinetd') ).not_to be_installed
  1838. # Fix: The "xinetd" package can be uninstalled with the following command:
  1839. # # yum erase xinetd
  1840. end
  1841. # STIG Viewer Link: http://www.stigviewer.com/check/V-38585
  1842. it "V-38585 The system boot loader must require authentication." do
  1843. # Check: To verify the boot loader password has been set and encrypted, run the following command:
  1844. # # grep password /etc/grub.conf
  1845. # The output should show the following:
  1846. # password --encrypted "$6$[rest-of-the-password-hash]"
  1847. # If it does not, this is a finding.
  1848. expect( command('grep password /etc/grub.conf') ).to return_stdout /password --encrypted \$6\$.*/
  1849. # Fix: The grub boot loader should have password protection enabled to protect boot-time settings. To do so,
  1850. # select a password and then generate a hash from it by running the following command:
  1851. # # grub-crypt --sha-512
  1852. # When prompted to enter a password, insert the following line into "/etc/grub.conf" immediately after
  1853. # the header comments. (Use the output from "grub-crypt" as the value of [password-hash]):
  1854. # password --encrypted [password-hash]
  1855. end
  1856. # STIG Viewer Link: http://www.stigviewer.com/check/V-38586
  1857. it "V-38586 The system must require authentication upon booting into single-user and maintenance modes." do
  1858. # Check: To check if authentication is required for single-user mode, run the following command:
  1859. # $ grep SINGLE /etc/sysconfig/init
  1860. # The output should be the following:
  1861. # SINGLE=/sbin/sulogin
  1862. # If the output is different, this is a finding.
  1863. expect( command('grep SINGLE /etc/sysconfig/init') ).to return_stdout /^SINGLE=\/sbin\/sulogin/
  1864. # Fix: Single-user mode is intended as a system recovery method, providing a single user root access to the system by providing a boot option at startup. By default, no authentication is performed if single-user mode is selected.
  1865. # To require entry of the root password even if the system is started in single-user mode, add or correct the following line in the file "/etc/sysconfig/init":
  1866. # SINGLE=/sbin/sulogin
  1867. end
  1868. # STIG Viewer Link: http://www.stigviewer.com/check/V-38587
  1869. it "V-38587 The telnet-server package must not be installed." do
  1870. # Check: Run the following command to determine if the "telnet-server" package is installed:
  1871. # # rpm -q telnet-server
  1872. # If the package is installed, this is a finding.
  1873. expect( package('telnet-server') ).not_to be_installed
  1874. # Fix: The "telnet-server" package can be uninstalled with the following command:
  1875. # # yum erase telnet-server
  1876. end
  1877. # STIG Viewer Link: http://www.stigviewer.com/check/V-38588
  1878. it "V-38588 The system must not permit interactive boot." do
  1879. # Check: To check whether interactive boot is disabled, run the following command:
  1880. # $ grep PROMPT /etc/sysconfig/init
  1881. # If interactive boot is disabled, the output will show:
  1882. # PROMPT=no
  1883. # If it does not, this is a finding.
  1884. expect( command('grep PROMPT /etc/sysconfig/init') ).to return_stdout /^PROMPT=no/
  1885. # Fix: To disable the ability for users to perform interactive startups, edit the file "/etc/sysconfig/init". Add or correct the line:
  1886. # PROMPT=no
  1887. # The "PROMPT" option allows the console user to perform an interactive system startup, in which it is possible to select the set of services which are started on boot.
  1888. end
  1889. # STIG Viewer Link: http://www.stigviewer.com/check/V-38589
  1890. it "V-38589 The telnet daemon must not be running." do
  1891. # Check: To check that the "telnet" service is disabled in system boot configuration, run the following command:
  1892. # # chkconfig "telnet" --list
  1893. # Output should indicate the "telnet" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  1894. # # chkconfig "telnet" --list
  1895. # "telnet" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  1896. # Run the following command to verify "telnet" is disabled through current runtime configuration:
  1897. # # service telnet status
  1898. # If the service is disabled the command will return the following output:
  1899. # telnet is stopped
  1900. # If the service is running, this is a finding.
  1901. expect( service('telnet')).not_to be_enabled
  1902. expect( service('telnet')).not_to be_running
  1903. # Fix: The "telnet" service can be disabled with the following command:
  1904. # # chkconfig telnet off
  1905. end
  1906. # STIG Viewer Link: http://www.stigviewer.com/check/V-38590
  1907. it "V-38590 The system must allow locking of the console screen in text mode." do
  1908. # Check: Run the following command to determine if the "screen" package is installed:
  1909. # # rpm -q screen
  1910. # If the package is not installed, this is a finding.
  1911. expect( package('screen')).to be_installed
  1912. # Fix: To enable console screen locking when in text mode, install the "screen" package:
  1913. # # yum install screen
  1914. # Instruct users to begin new terminal sessions with the following command:
  1915. # $ screen
  1916. # The console can now be locked with the following key combination:
  1917. # ctrl+a x
  1918. end
  1919. # STIG Viewer Link: http://www.stigviewer.com/check/V-38591
  1920. it "V-38591 The rsh-server package must not be installed." do
  1921. # Check: Run the following command to determine if the "rsh-server" package is installed:
  1922. # # rpm -q rsh-server
  1923. # If the package is installed, this is a finding.
  1924. expect( package('rsh-server')).not_to be_installed
  1925. # Fix: The "rsh-server" package can be uninstalled with the following command:
  1926. # # yum erase rsh-server
  1927. end
  1928. # STIG Viewer Link: http://www.stigviewer.com/check/V-38592
  1929. it "V-38592 The system must require administrator action to unlock an account locked by excessive failed login attempts." do
  1930. # Check: To ensure the failed password attempt policy is configured correctly, run the following command:
  1931. # # grep pam_faillock /etc/pam.d/system-auth-ac
  1932. # The output should show "unlock_time=<some-large-number>"; the largest acceptable value is 604800
  1933. # seconds (one week).
  1934. # If that is not the case, this is a finding.
  1935. expect( file('/etc/pam.d/system-auth-ac')).to contain "unlock_time=604800"
  1936. # Fix: To configure the system to lock out accounts after a number of incorrect login attempts and require an
  1937. # administrator to unlock the account using "pam_faillock.so":
  1938. # Add the following lines immediately below the "pam_unix.so" statement in the AUTH section of
  1939. # "/etc/pam.d/system-auth-ac":
  1940. # auth [default=die] pam_faillock.so authfail deny=3 unlock_time=604800 fail_interval=900
  1941. # auth required pam_faillock.so authsucc deny=3 unlock_time=604800 fail_interval=900
  1942. # Note that any updates made to "/etc/pam.d/system-auth-ac" will be overwritten by the "authconfig" program. The "authconfig" program should not be used.
  1943. end
  1944. # STIG Viewer Link: http://www.stigviewer.com/check/V-38593
  1945. it "V-38593 The Department of Defense (DoD) login banner must be displayed immediately prior to, or as part of, console login prompts." do
  1946. # Check: To check if the system login banner is compliant, run the following command:
  1947. # $ cat /etc/issue
  1948. # If it does not display the required banner, this is a finding.
  1949. expect( file('/etc/issue')).to be_file
  1950. expect( command('cat /etc/issue')).not_to return_stdout ""
  1951. # Fix: To configure the system login banner:
  1952. # Edit "/etc/issue". Replace the default text with a message compliant with the local site policy or a legal disclaimer. The DoD required text is either:
  1953. # "You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only. By using this IS (which includes any device attached to this IS), you consent to the following conditions:
  1954. # -The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM), law enforcement (LE), and counterintelligence (CI) investigations.
  1955. # -At any time, the USG may inspect and seize data stored on this IS.
  1956. # -Communications using, or data stored on, this IS are not private, are subject to routine monitoring, interception, and search, and may be disclosed or used for any USG-authorized purpose.
  1957. # -This IS includes security measures (e.g., authentication and access controls) to protect USG interests -- not for your personal benefit or privacy.
  1958. # -Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching or monitoring of the content of privileged communications, or work product, related to personal representation or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product are private and confidential. See User Agreement for details."
  1959. # OR:
  1960. # "I've read & consent to terms in IS user agreem't."
  1961. end
  1962. # STIG Viewer Link: http://www.stigviewer.com/check/V-38594
  1963. it "V-38594 The rshd service must not be running." do
  1964. # Check: To check that the "rsh" service is disabled in system boot configuration, run the following command:
  1965. # # chkconfig "rsh" --list
  1966. # Output should indicate the "rsh" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  1967. # # chkconfig "rsh" --list
  1968. # "rsh" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  1969. # Run the following command to verify "rsh" is disabled through current runtime configuration:
  1970. # # service rsh status
  1971. # If the service is disabled the command will return the following output:
  1972. # rsh is stopped
  1973. # If the service is running, this is a finding.
  1974. expect( service('rsh')).not_to be_enabled
  1975. expect( service('rsh')).not_to be_running
  1976. # Fix: The "rsh" service, which is available with the "rsh-server" package and runs as a service through xinetd, should be disabled. The "rsh" service can be disabled with the following command:
  1977. # # chkconfig rsh off
  1978. end
  1979. # STIG Viewer Link: http://www.stigviewer.com/check/V-38595
  1980. it "V-38595 The system must be configured to require the use of a CAC, PIV compliant hardware token, or Alternate Logon Token (ALT) for authentication." do
  1981. # Check: Interview the SA to determine if all accounts not exempted by policy are using CAC authentication. For DoD systems, the following systems and accounts are exempt from using smart card (CAC) authentication:
  1982. # SIPRNET systems
  1983. # Standalone systems
  1984. # Application accounts
  1985. # Temporary employee accounts, such as students or interns, who cannot easily receive a CAC or PIV
  1986. # Operational tactical locations that are not collocated with RAPIDS workstations to issue CAC or ALT
  1987. # Test systems, such as those with an Interim Approval to Test (IATT) and use a separate VPN, firewall, or security measure preventing access to network and system components from outside the protection boundary documented in the IATT.
  1988. # If non-exempt accounts are not using CAC authentication, this is a finding.
  1989. pending( "Manual step" )
  1990. # Fix: To enable smart card authentication, consult the documentation at:
  1991. # https://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Smart_Cards/enabling-smart-card-login.html
  1992. end
  1993. # STIG Viewer Link: http://www.stigviewer.com/check/V-38596
  1994. it "V-38596 The system must implement virtual address space randomization." do
  1995. # Check: The status of the "kernel.randomize_va_space" kernel parameter can be queried by running the following command:
  1996. # $ sysctl kernel.randomize_va_space
  1997. # The output of the command should indicate a value of at least "1" (preferably "2"). If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  1998. # If the correct value is not returned, this is a finding.
  1999. expect( linux_kernel_parameter('kernel.randomize_va_space').value ).to equal(2)
  2000. # Fix: To set the runtime status of the "kernel.randomize_va_space" kernel parameter, run the following command:
  2001. # # sysctl -w kernel.randomize_va_space=2
  2002. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  2003. # kernel.randomize_va_space = 2
  2004. end
  2005. # STIG Viewer Link: http://www.stigviewer.com/check/V-38597
  2006. it "V-38597 The system must limit the ability of processes to have simultaneous write and execute access to memory." do
  2007. # Check: The status of the "kernel.exec-shield" kernel parameter can be queried by running the following command:
  2008. # $ sysctl kernel.exec-shield
  2009. # The output of the command should indicate a value of "1". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  2010. # If the correct value is not returned, this is a finding.
  2011. expect( linux_kernel_parameter('kernel.exec-shield').value ).to equal(1)
  2012. # Fix: To set the runtime status of the "kernel.exec-shield" kernel parameter, run the following command:
  2013. # # sysctl -w kernel.exec-shield=1
  2014. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  2015. # kernel.exec-shield = 1
  2016. end
  2017. # STIG Viewer Link: http://www.stigviewer.com/check/V-38598
  2018. it "V-38598 The rexecd service must not be running." do
  2019. # Check: To check that the "rexec" service is disabled in system boot configuration, run the following command:
  2020. # # chkconfig "rexec" --list
  2021. # Output should indicate the "rexec" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2022. # # chkconfig "rexec" --list
  2023. # "rexec" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2024. # Run the following command to verify "rexec" is disabled through current runtime configuration:
  2025. # # service rexec status
  2026. # If the service is disabled the command will return the following output:
  2027. # rexec is stopped
  2028. # If the service is running, this is a finding.
  2029. expect( service('rexec')).not_to be_enabled
  2030. expect( service('rexec')).not_to be_running
  2031. # Fix: The "rexec" service, which is available with the "rsh-server" package and runs as a service through xinetd, should be disabled. The "rexec" service can be disabled with the following command:
  2032. # # chkconfig rexec off
  2033. end
  2034. # STIG Viewer Link: http://www.stigviewer.com/check/V-38599
  2035. it "V-38599 The FTPS/FTP service on the system must be configured with the Department of Defense (DoD) login banner." do
  2036. # Check: To verify this configuration, run the following command:
  2037. # grep "banner_file" /etc/vsftpd/vsftpd.conf
  2038. # The output should show the value of "banner_file" is set to "/etc/issue", an example of which is shown below.
  2039. # # grep "banner_file" /etc/vsftpd/vsftpd.conf
  2040. # banner_file=/etc/issue
  2041. # If it does not, this is a finding.
  2042. if package('vsftpd').installed?("rpm",nil)
  2043. expect( file('/etc/vsftpd/vsftpd.conf')).to contain "banner_file=/etc/issue"
  2044. else
  2045. pending('Not applicable')
  2046. end
  2047. # Fix: Edit the vsftpd configuration file, which resides at "/etc/vsftpd/vsftpd.conf" by default. Add or correct the following configuration options.
  2048. # banner_file=/etc/issue
  2049. end
  2050. # STIG Viewer Link: http://www.stigviewer.com/check/V-38600
  2051. it "V-38600 The system must not send ICMPv4 redirects by default." do
  2052. # Check: The status of the "net.ipv4.conf.default.send_redirects" kernel parameter can be queried by running the following command:
  2053. # $ sysctl net.ipv4.conf.default.send_redirects
  2054. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  2055. # If the correct value is not returned, this is a finding.
  2056. expect( linux_kernel_parameter('net.ipv4.conf.default.send_redirects').value ).to equal(0)
  2057. # Fix: To set the runtime status of the "net.ipv4.conf.default.send_redirects" kernel parameter, run the following command:
  2058. # # sysctl -w net.ipv4.conf.default.send_redirects=0
  2059. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  2060. # net.ipv4.conf.default.send_redirects = 0
  2061. end
  2062. # STIG Viewer Link: http://www.stigviewer.com/check/V-38601
  2063. it "V-38601 The system must not send ICMPv4 redirects from any interface." do
  2064. # Check: The status of the "net.ipv4.conf.all.send_redirects" kernel parameter can be queried by running the following command:
  2065. # $ sysctl net.ipv4.conf.all.send_redirects
  2066. # The output of the command should indicate a value of "0". If this value is not the default value, investigate how it could have been adjusted at runtime, and verify it is not set improperly in "/etc/sysctl.conf".
  2067. # If the correct value is not returned, this is a finding.
  2068. expect( linux_kernel_parameter('net.ipv4.conf.all.send_redirects').value ).to equal(0)
  2069. # Fix: To set the runtime status of the "net.ipv4.conf.all.send_redirects" kernel parameter, run the following command:
  2070. # # sysctl -w net.ipv4.conf.all.send_redirects=0
  2071. # If this is not the system's default value, add the following line to "/etc/sysctl.conf":
  2072. # net.ipv4.conf.all.send_redirects = 0
  2073. end
  2074. # STIG Viewer Link: http://www.stigviewer.com/check/V-38602
  2075. it "V-38602 The rlogind service must not be running." do
  2076. # Check: To check that the "rlogin" service is disabled in system boot configuration, run the following command:
  2077. # # chkconfig "rlogin" --list
  2078. # Output should indicate the "rlogin" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2079. # # chkconfig "rlogin" --list
  2080. # "rlogin" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2081. # Run the following command to verify "rlogin" is disabled through current runtime configuration:
  2082. # # service rlogin status
  2083. # If the service is disabled the command will return the following output:
  2084. # rlogin is stopped
  2085. # If the service is running, this is a finding.
  2086. expect( service('rlogin')).not_to be_enabled
  2087. expect( service('rlogin')).not_to be_running
  2088. # Fix: The "rlogin" service, which is available with the "rsh-server" package and runs as a service through xinetd, should be disabled. The "rlogin" service can be disabled with the following command:
  2089. # # chkconfig rlogin off
  2090. end
  2091. # STIG Viewer Link: http://www.stigviewer.com/check/V-38603
  2092. it "V-38603 The ypserv package must not be installed." do
  2093. # Check: Run the following command to determine if the "ypserv" package is installed:
  2094. # # rpm -q ypserv
  2095. # If the package is installed, this is a finding.
  2096. expect( package('ypserv')).not_to be_installed
  2097. # Fix: The "ypserv" package can be uninstalled with the following command:
  2098. # # yum erase ypserv
  2099. end
  2100. # STIG Viewer Link: http://www.stigviewer.com/check/V-38604
  2101. it "V-38604 The ypbind service must not be running." do
  2102. # Check: To check that the "ypbind" service is disabled in system boot configuration, run the following command:
  2103. # # chkconfig "ypbind" --list
  2104. # Output should indicate the "ypbind" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2105. # # chkconfig "ypbind" --list
  2106. # "ypbind" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2107. # Run the following command to verify "ypbind" is disabled through current runtime configuration:
  2108. # # service ypbind status
  2109. # If the service is disabled the command will return the following output:
  2110. # ypbind is stopped
  2111. # If the service is running, this is a finding.
  2112. expect( service('ypbind')).not_to be_enabled
  2113. expect( service('ypbind')).not_to be_running
  2114. # Fix: The "ypbind" service, which allows the system to act as a client in a NIS or NIS+ domain, should be disabled. The "ypbind" service can be disabled with the following command:
  2115. # # chkconfig ypbind off
  2116. end
  2117. # STIG Viewer Link: http://www.stigviewer.com/check/V-38605
  2118. it "V-38605 The cron service must be running." do
  2119. # Check: Run the following command to determine the current status of the "crond" service:
  2120. # # service crond status
  2121. # If the service is enabled, it should return the following:
  2122. # crond is running...
  2123. # If the service is not running, this is a finding.
  2124. expect( service('crond')).to be_enabled
  2125. expect( service('crond')).to be_running
  2126. # Fix: The "crond" service is used to execute commands at preconfigured times. It is required by almost all systems to perform necessary maintenance tasks, such as notifying root of system activity. The "crond" service can be enabled with the following command:
  2127. # # chkconfig crond on
  2128. end
  2129. # STIG Viewer Link: http://www.stigviewer.com/check/V-38606
  2130. it "V-38606 The tftp-server package must not be installed." do
  2131. # Check: Run the following command to determine if the "tftp-server" package is installed:
  2132. # # rpm -q tftp-server
  2133. # If the package is installed, this is a finding.
  2134. expect( package('tftp-server')).not_to be_installed
  2135. # Fix: The "tftp-server" package can be removed with the following command:
  2136. # # yum erase tftp-server
  2137. end
  2138. # STIG Viewer Link: http://www.stigviewer.com/check/V-38607
  2139. it "V-38607 The SSH daemon must be configured to use only the SSHv2 protocol." do
  2140. # Check: To check which SSH protocol version is allowed, run the following command:
  2141. # # grep Protocol /etc/ssh/sshd_config
  2142. # If configured properly, output should be
  2143. # Protocol 2
  2144. # If it is not, this is a finding.
  2145. expect( file('/etc/ssh/sshd_config')).to contain /^Protocol 2/
  2146. # Fix: Only SSH protocol version 2 connections should be permitted. The default setting in "/etc/ssh/sshd_config" is correct, and can be verified by ensuring that the following line appears:
  2147. # Protocol 2
  2148. end
  2149. # STIG Viewer Link: http://www.stigviewer.com/check/V-38608
  2150. it "V-38608 The SSH daemon must set a timeout interval on idle sessions." do
  2151. # Check: Run the following command to see what the timeout interval is:
  2152. # # grep ClientAliveInterval /etc/ssh/sshd_config
  2153. # If properly configured, the output should be:
  2154. # ClientAliveInterval 900
  2155. # If it is not, this is a finding.
  2156. expect( file('/etc/ssh/sshd_config')).to contain /^ClientAliveInterval 900/
  2157. # Fix: SSH allows administrators to set an idle timeout interval. After this interval has passed, the idle user will be automatically logged out.
  2158. # To set an idle timeout interval, edit the following line in "/etc/ssh/sshd_config" as follows:
  2159. # ClientAliveInterval [interval]
  2160. # The timeout [interval] is given in seconds. To have a timeout of 15 minutes, set [interval] to 900.
  2161. # If a shorter timeout has already been set for the login shell, that value will preempt any SSH setting made here. Keep in mind that some processes may stop SSH from correctly detecting that the user is idle.
  2162. end
  2163. # STIG Viewer Link: http://www.stigviewer.com/check/V-38609
  2164. it "V-38609 The TFTP service must not be running." do
  2165. # Check: To check that the "tftp" service is disabled in system boot configuration, run the following command:
  2166. # # chkconfig "tftp" --list
  2167. # Output should indicate the "tftp" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2168. # # chkconfig "tftp" --list
  2169. # "tftp" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2170. # Run the following command to verify "tftp" is disabled through current runtime configuration:
  2171. # # service tftp status
  2172. # If the service is disabled the command will return the following output:
  2173. # tftp is stopped
  2174. # If the service is running, this is a finding.
  2175. expect( service('tftp')).not_to be_enabled
  2176. expect( service('tftp')).not_to be_running
  2177. # Fix: The "tftinstalled?p" service should be disabled. The "tftp" service can be disabled with the following command:
  2178. # # chkconfig tftp off
  2179. end
  2180. # STIG Viewer Link: http://www.stigviewer.com/check/V-38610
  2181. it "V-38610 The SSH daemon must set a timeout count on idle sessions." do
  2182. # Check: To ensure the SSH idle timeout will occur when the "ClientAliveCountMax" is set, run the following command:
  2183. # # grep ClientAliveCountMax /etc/ssh/sshd_config
  2184. # If properly configured, output should be:
  2185. # ClientAliveCountMax 0
  2186. # If it is not, this is a finding.
  2187. expect( file('/etc/ssh/sshd_config')).to contain /^ClientAliveCountMax 0/
  2188. # Fix: To ensure the SSH idle timeout occurs precisely when the "ClientAliveCountMax" is set, edit "/etc/ssh/sshd_config" as follows:
  2189. # ClientAliveCountMax 0
  2190. end
  2191. # STIG Viewer Link: http://www.stigviewer.com/check/V-38611
  2192. it "V-38611 The SSH daemon must ignore .rhosts files." do
  2193. # Check: To determine how the SSH daemon's "IgnoreRhosts" option is set, run the following command:
  2194. # # grep -i IgnoreRhosts /etc/ssh/sshd_config
  2195. # If no line, a commented line, or a line indicating the value "yes" is returned, then the required value is set.
  2196. # If the required value is not set, this is a finding.
  2197. expect( file('/etc/ssh/sshd_config')).to contain /^IgnoreRhosts/
  2198. # Fix: SSH can emulate the behavior of the obsolete rsh command in allowing users to enable insecure access to their accounts via ".rhosts" files.
  2199. # To ensure this behavior is disabled, add or correct the following line in "/etc/ssh/sshd_config":
  2200. # IgnoreRhosts yes
  2201. end
  2202. # STIG Viewer Link: http://www.stigviewer.com/check/V-38612
  2203. it "V-38612 The SSH daemon must not allow host-based authentication." do
  2204. # Check: To determine how the SSH daemon's "HostbasedAuthentication" option is set, run the following command:
  2205. # # grep -i HostbasedAuthentication /etc/ssh/sshd_config
  2206. # If no line, a commented line, or a line indicating the value "no" is returned, then the required value is set.
  2207. # If the required value is not set, this is a finding.
  2208. expect( file('/etc/ssh/sshd_config')).to contain /^HostbasedAuthentication no/
  2209. # Fix: SSH's cryptographic host-based authentication is more secure than ".rhosts" authentication, since hosts are cryptographically authenticated. However, it is not recommended that hosts unilaterally trust one another, even within an organization.
  2210. # To disable host-based authentication, add or correct the following line in "/etc/ssh/sshd_config":
  2211. # HostbasedAuthentication no
  2212. end
  2213. # STIG Viewer Link: http://www.stigviewer.com/check/V-38613
  2214. it "V-38613 The system must not permit root logins using remote access programs such as ssh." do
  2215. # Check: To determine how the SSH daemon's "PermitRootLogin" option is set, run the following command:
  2216. # # grep -i PermitRootLogin /etc/ssh/sshd_config
  2217. # If a line indicating "no" is returned, then the required value is set.
  2218. # If the required value is not set, this is a finding.
  2219. expect( file('/etc/ssh/sshd_config')).to contain /^PermitRootLogin no/
  2220. # Fix: The root user should never be allowed to log in to a system directly over a network. To disable root login via SSH, add or correct the following line in "/etc/ssh/sshd_config":
  2221. # PermitRootLogin no
  2222. end
  2223. # STIG Viewer Link: http://www.stigviewer.com/check/V-38614
  2224. it "V-38614 The SSH daemon must not allow authentication using an empty password." do
  2225. # Check: To determine how the SSH daemon's "PermitEmptyPasswords" option is set, run the following command:
  2226. # # grep -i PermitEmptyPasswords /etc/ssh/sshd_config
  2227. # If no line, a commented line, or a line indicating the value "no" is returned, then the required value is set.
  2228. # If the required value is not set, this is a finding.
  2229. expect( file('/etc/ssh/sshd_config')).to contain /^PermitEmptyPasswords no/
  2230. # Fix: To explicitly disallow remote login from accounts with empty passwords, add or correct the following line in "/etc/ssh/sshd_config":
  2231. # PermitEmptyPasswords no
  2232. # Any accounts with empty passwords should be disabled immediately, and PAM configuration should prevent users from being able to assign themselves empty passwords.
  2233. end
  2234. # STIG Viewer Link: http://www.stigviewer.com/check/V-38615
  2235. it "V-38615 The SSH daemon must be configured with the Department of Defense (DoD) login banner." do
  2236. # Check: To determine how the SSH daemon's "Banner" option is set, run the following command:
  2237. # # grep -i Banner /etc/ssh/sshd_config
  2238. # If a line indicating /etc/issue is returned, then the required value is set.
  2239. # If the required value is not set, this is a finding.
  2240. expect( file('/etc/ssh/sshd_config')).to contain /^Banner \/etc\/issue/
  2241. # Fix: To enable the warning banner and ensure it is consistent across the system, add or correct the following line in "/etc/ssh/sshd_config":
  2242. # Banner /etc/issue
  2243. # Another section contains information on how to create an appropriate system-wide warning banner.
  2244. end
  2245. # STIG Viewer Link: http://www.stigviewer.com/check/V-38616
  2246. it "V-38616 The SSH daemon must not permit user environment settings." do
  2247. # Check: To ensure users are not able to present environment daemons, run the following command:
  2248. # # grep PermitUserEnvironment /etc/ssh/sshd_config
  2249. # If properly configured, output should be:
  2250. # PermitUserEnvironment no
  2251. # If it is not, this is a finding.
  2252. expect( file('/etc/ssh/sshd_config')).to contain /^PermitUserEnvironment no/
  2253. # Fix: To ensure users are not able to present environment options to the SSH daemon, add or correct the following line in "/etc/ssh/sshd_config":
  2254. # PermitUserEnvironment no
  2255. end
  2256. # STIG Viewer Link: http://www.stigviewer.com/check/V-38617
  2257. it "V-38617 The SSH daemon must be configured to use only FIPS 140-2 approved ciphers." do
  2258. # Check: Only FIPS-approved ciphers should be used. To verify that only FIPS-approved ciphers are in use, run the following command:
  2259. # # grep Ciphers /etc/ssh/sshd_config
  2260. # The output should contain only those ciphers which are FIPS-approved, namely, the AES and 3DES ciphers.
  2261. # If that is not the case, this is a finding.
  2262. expect( file('/etc/ssh/sshd_config')).to contain /^Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc/
  2263. # Fix: Limit the ciphers to those algorithms which are FIPS-approved. Counter (CTR) mode is also preferred over cipher-block chaining (CBC) mode. The following line in "/etc/ssh/sshd_config" demonstrates use of FIPS-approved ciphers:
  2264. # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
  2265. # The man page "sshd_config(5)" contains a list of supported ciphers.
  2266. end
  2267. # STIG Viewer Link: http://www.stigviewer.com/check/V-38618
  2268. it "V-38618 The avahi service must be disabled." do
  2269. # Check: To check that the "avahi-daemon" service is disabled in system boot configuration, run the following command:
  2270. # # chkconfig "avahi-daemon" --list
  2271. # Output should indicate the "avahi-daemon" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2272. # # chkconfig "avahi-daemon" --list
  2273. # "avahi-daemon" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2274. # Run the following command to verify "avahi-daemon" is disabled through current runtime configuration:
  2275. # # service avahi-daemon status
  2276. # If the service is disabled the command will return the following output:
  2277. # avahi-daemon is stopped
  2278. # If the service is running, this is a finding.
  2279. expect( service('avahi-daemon')).not_to be_enabled
  2280. expect( service('avahi-daemon')).not_to be_running
  2281. # Fix: The "avahi-daemon" service can be disabled with the following command:
  2282. # # chkconfig avahi-daemon off
  2283. end
  2284. # STIG Viewer Link: http://www.stigviewer.com/check/V-38619
  2285. it "V-38619 There must be no .netrc files on the system." do
  2286. # Check: To check the system for the existence of any ".netrc" files, run the following command:
  2287. # # find /home -xdev -name .netrc
  2288. # If any .netrc files exist, this is a finding.
  2289. expect( command('find /home -xdev -name .netrc')).to return_stdout ""
  2290. # Fix: The ".netrc" files contain login information used to auto-login into FTP servers and reside in the user's home directory. These files may contain unencrypted passwords to remote FTP servers making them susceptible to access by unauthorized users and should not be used. Any ".netrc" files should be removed.
  2291. end
  2292. # STIG Viewer Link: http://www.stigviewer.com/check/V-38620
  2293. it "V-38620 The system clock must be synchronized continuously, or at least daily." do
  2294. # Check: Run the following command to determine the current status of the "ntpd" service:
  2295. # # service ntpd status
  2296. # If the service is enabled, it should return the following:
  2297. # ntpd is running...
  2298. # If the service is not running, this is a finding.
  2299. expect( service('ntpd')).to be_enabled
  2300. expect( service('ntpd')).to be_running
  2301. # Fix: The "ntpd" service can be enabled with the following command:
  2302. # # chkconfig ntpd on
  2303. # # service ntpd start
  2304. end
  2305. # STIG Viewer Link: http://www.stigviewer.com/check/V-38621
  2306. it "V-38621 The system clock must be synchronized to an authoritative DoD time source." do
  2307. # Check: A remote NTP server should be configured for time synchronization. To verify one is configured, open the following file.
  2308. # /etc/ntp.conf
  2309. # In the file, there should be a section similar to the following:
  2310. # # --- OUR TIMESERVERS -----
  2311. # server [ntpserver]
  2312. # If this is not the case, this is a finding.
  2313. pending( "Optional step" )
  2314. # Fix: To specify a remote NTP server for time synchronization, edit the file "/etc/ntp.conf". Add or correct the following lines, substituting the IP or hostname of a remote NTP server for ntpserver.
  2315. # server [ntpserver]
  2316. # This instructs the NTP software to contact that remote server to obtain time data.
  2317. end
  2318. # STIG Viewer Link: http://www.stigviewer.com/check/V-38622
  2319. it "V-38622 Mail relaying must be restricted." do
  2320. # Check: Run the following command to ensure postfix accepts mail messages from only the local system:
  2321. # $ grep inet_interfaces /etc/postfix/main.cf
  2322. # If properly configured, the output should show only "localhost".
  2323. # If it does not, this is a finding.
  2324. expect( file('/etc/postfix/main.cf')).to contain /^inet_interfaces = localhost$/
  2325. # Fix: Edit the file "/etc/postfix/main.cf" to ensure that only the following "inet_interfaces" line appears:
  2326. # inet_interfaces = localhost
  2327. end
  2328. # STIG Viewer Link: http://www.stigviewer.com/check/V-38623
  2329. it "V-38623 All rsyslog-generated log files must have mode 0600 or less permissive." do
  2330. # Check: The file permissions for all log files written by rsyslog should be set to 600, or more restrictive. These log files are determined by the second part of each Rule line in "/etc/rsyslog.conf" and typically all appear in "/var/log". For each log file [LOGFILE] referenced in "/etc/rsyslog.conf", run the following command to inspect the file's permissions:
  2331. # $ ls -l [LOGFILE]
  2332. # The permissions should be 600, or more restrictive.
  2333. # If the permissions are not correct, this is a finding.
  2334. $environment['logFiles'].each do |log|
  2335. expect( file(log)).to be_mode 600
  2336. end
  2337. # Fix: The file permissions for all log files written by rsyslog should be set to 600, or more restrictive. These log files are determined by the second part of each Rule line in "/etc/rsyslog.conf" and typically all appear in "/var/log". For each log file [LOGFILE] referenced in "/etc/rsyslog.conf", run the following command to inspect the file's permissions:
  2338. # $ ls -l [LOGFILE]
  2339. # If the permissions are not 600 or more restrictive, run the following command to correct this:
  2340. # # chmod 0600 [LOGFILE]
  2341. end
  2342. # STIG Viewer Link: http://www.stigviewer.com/check/V-38624
  2343. it "V-38624 System logs must be rotated daily." do
  2344. # Check: Run the following commands to determine the current status of the "logrotate" service:
  2345. # # grep logrotate /var/log/cron*
  2346. # If the logrotate service is not run on a daily basis by cron, this is a finding.
  2347. expect(package('logrotate')).to be_installed
  2348. expect( file('/etc/cron.daily/logrotate')).to be_file
  2349. expect( file('/etc/logrotate.d/syslog')).to be_file
  2350. expect( file('/etc/logrotate.conf')).to contain /^daily$/
  2351. # Fix: The "logrotate" service should be installed or reinstalled if it is not installed and operating properly, by running the following command:
  2352. # # yum reinstall logrotate
  2353. end
  2354. # STIG Viewer Link: http://www.stigviewer.com/check/V-38625
  2355. it "V-38625 If the system is using LDAP for authentication or account information, the system must use a TLS connection using FIPS 140-2 approved cryptographic algorithms." do
  2356. # Check: If the system does not use LDAP for authentication or account information, this is not applicable.
  2357. # To ensure LDAP is configured to use TLS for all transactions, run the following command:
  2358. # $ grep start_tls /etc/pam_ldap.conf
  2359. # If no lines are returned, this is a finding.
  2360. if property[:roles].include? 'ldapClient'
  2361. expect( file('/etc/pam_ldap.conf')).to contain /^ssl start_tls$/
  2362. else
  2363. pending("Not applicable")
  2364. end
  2365. # Fix: Configure LDAP to enforce TLS use. First, edit the file "/etc/pam_ldap.conf", and add or correct the following lines:
  2366. # ssl start_tls
  2367. # Then review the LDAP server and ensure TLS has been configured.
  2368. end
  2369. # STIG Viewer Link: http://www.stigviewer.com/check/V-38626
  2370. it "V-38626 The LDAP client must use a TLS connection using trust certificates signed by the site CA." do
  2371. # Check: If the system does not use LDAP for authentication or account information, this is not applicable.
  2372. # To ensure TLS is configured with trust certificates, run the following command:
  2373. # # grep cert /etc/pam_ldap.conf
  2374. # If there is no output, or the lines are commented out, this is a finding.
  2375. if property[:roles].include? 'ldapClient'
  2376. expect( file('/etc/pki/tls/CA/cacert.pem')).to be_file
  2377. expect( file('/etc/pam_ldap.conf')).to contain /^tls_cacertfile \/etc\/pki\/tls\/CA\/cacert.pem$/
  2378. else
  2379. pending("Not applicable")
  2380. end
  2381. # Fix: Ensure a copy of the site's CA certificate has been placed in the file "/etc/pki/tls/CA/cacert.pem". Configure LDAP to enforce
  2382. # TLS use and to trust certificates signed by the site's CA. First, edit the file "/etc/pam_ldap.conf", and add or correct either of the following lines:
  2383. # tls_cacertdir /etc/pki/tls/CA
  2384. # or
  2385. # tls_cacertfile /etc/pki/tls/CA/cacert.pem
  2386. # Then review the LDAP server and ensure TLS has been configured.
  2387. end
  2388. # STIG Viewer Link: http://www.stigviewer.com/check/V-38627
  2389. it "V-38627 The openldap-servers package must not be installed unless required." do
  2390. # Check: To verify the "openldap-servers" package is not installed, run the following command:
  2391. # $ rpm -q openldap-servers
  2392. # The output should show the following.
  2393. # package openldap-servers is not installed
  2394. # If it does not, this is a finding.
  2395. expect(package('openldap-servers')).not_to be_installed
  2396. # Fix: The "openldap-servers" package should be removed if not in use. Is this machine the OpenLDAP server? If not, remove the package.
  2397. # # yum erase openldap-servers
  2398. # The openldap-servers RPM is not installed by default on RHEL6 machines. It is needed only by the OpenLDAP server, not by the clients which use LDAP for authentication. If the system is not intended for use as an LDAP Server it should be removed.
  2399. end
  2400. # STIG Viewer Link: http://www.stigviewer.com/check/V-38628
  2401. it "V-38628 The operating system must produce audit records containing sufficient information to establish the identity of any user/subject associated with the event." do
  2402. # Check: Run the following command to determine the current status of the "auditd" service:
  2403. # # service auditd status
  2404. # If the service is enabled, it should return the following:
  2405. # auditd is running...
  2406. # If the service is not running, this is a finding.
  2407. expect( service('auditd')).to be_enabled
  2408. expect( service('auditd')).to be_running
  2409. # Fix: The "auditd" service is an essential userspace component of the Linux Auditing System, as it is responsible for writing audit records to disk. The "auditd" service can be enabled with the following command:
  2410. # # chkconfig auditd on
  2411. end
  2412. # STIG Viewer Link: http://www.stigviewer.com/check/V-38629
  2413. it "V-38629 The graphical desktop environment must set the idle timeout to no more than 15 minutes." do
  2414. # Check: To check the current idle time-out value, run the following command:
  2415. # $ gconftool-2 -g /apps/gnome-screensaver/idle_delay
  2416. # If properly configured, the output should be "15".
  2417. # If it is not, this is a finding.
  2418. if property[:gnomeInstalled]
  2419. expect( command('gconftool-2 -g /apps/gnome-screensaver/idle_delay')).to return_stdout "15"
  2420. else
  2421. pending( "Not applicable" )
  2422. end
  2423. # Fix: Run the following command to set the idle time-out value for inactivity in the GNOME desktop to 15 minutes:
  2424. # # gconftool-2 \
  2425. # --direct \
  2426. # --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
  2427. # --type int \
  2428. # --set /apps/gnome-screensaver/idle_delay 15
  2429. end
  2430. # STIG Viewer Link: http://www.stigviewer.com/check/V-38630
  2431. it "V-38630 The graphical desktop environment must automatically lock after 15 minutes of inactivity and the system must require user to re-authenticate to unlock the environment." do
  2432. # Check: To check the screensaver mandatory use status, run the following command:
  2433. # $ gconftool-2 -g /apps/gnome-screensaver/idle_activation_enabled
  2434. # If properly configured, the output should be "true".
  2435. # If it is not, this is a finding.
  2436. if property[:gnomeInstalled]
  2437. expect( command('gconftool-2 -g /apps/gnome-screensaver/idle_activation_enabled')).to return_stdout "true"
  2438. else
  2439. pending( "Not applicable" )
  2440. end
  2441. # Fix: Run the following command to activate the screensaver in the GNOME desktop after a period of inactivity:
  2442. # # gconftool-2 --direct \
  2443. # --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
  2444. # --type bool \
  2445. # --set /apps/gnome-screensaver/idle_activation_enabled true
  2446. end
  2447. # STIG Viewer Link: http://www.stigviewer.com/check/V-38631
  2448. it "V-38631 The operating system must employ automated mechanisms to facilitate the monitoring and control of remote access methods." do
  2449. # Check: Run the following command to determine the current status of the "auditd" service:
  2450. # # service auditd status
  2451. # If the service is enabled, it should return the following:
  2452. # auditd is running...
  2453. # If the service is not running, this is a finding.
  2454. expect( service('auditd')).to be_enabled
  2455. expect( service('auditd')).to be_running
  2456. # Fix: The "auditd" service is an essential userspace component of the Linux Auditing System, as it is responsible for writing audit records to disk. The "auditd" service can be enabled with the following command:
  2457. # # chkconfig auditd on
  2458. end
  2459. # STIG Viewer Link: http://www.stigviewer.com/check/V-38632
  2460. it "V-38632 The operating system must produce audit records containing sufficient information to establish what type of events occurred." do
  2461. # Check: Run the following command to determine the current status of the "auditd" service:
  2462. # # service auditd status
  2463. # If the service is enabled, it should return the following:
  2464. # auditd is running...
  2465. # If the service is not running, this is a finding.
  2466. expect( service('auditd')).to be_enabled
  2467. expect( service('auditd')).to be_running
  2468. # Fix: The "auditd" service is an essential userspace component of the Linux Auditing System, as it is responsible for writing audit records to disk. The "auditd" service can be enabled with the following command:
  2469. # # chkconfig auditd on
  2470. end
  2471. # STIG Viewer Link: http://www.stigviewer.com/check/V-38633
  2472. it "V-38633 The system must set a maximum audit log file size." do
  2473. # Check: Inspect "/etc/audit/auditd.conf" and locate the following line to determine how much data the system will
  2474. # retain in each audit log file: "# grep max_log_file /etc/audit/auditd.conf"
  2475. # max_log_file = 6
  2476. # If the system audit data threshold hasn't been properly set up, this is a finding.
  2477. expect( command("grep '^max_log_file = [0-9]' /etc/audit/auditd.conf")).not_to return_stdout ""
  2478. maxFileRegex = '^max_log_file = (?<value>\d+)$'
  2479. maxLogFile = command("grep '^max_log_file = [0-9]' /etc/audit/auditd.conf").stdout.strip
  2480. parts = maxLogFile.match(maxFileRegex)
  2481. expect( Integer(parts['value']) ).to be >= 6
  2482. # Fix: Determine the amount of audit data (in megabytes) which should be retained in each log file. Edit the file "/etc/audit/auditd.conf". Add or modify the following line, substituting the correct value for [STOREMB]:
  2483. # max_log_file = [STOREMB]
  2484. # Set the value to "6" (MB) or higher for general-purpose systems. Larger values, of course, support retention of even more audit data.
  2485. end
  2486. # STIG Viewer Link: http://www.stigviewer.com/check/V-38634
  2487. it "V-38634 The system must rotate audit log files that reach the maximum file size." do
  2488. # Check: Inspect "/etc/audit/auditd.conf" and locate the following line to determine if the system is configured to rotate
  2489. # logs when they reach their maximum size: "# grep max_log_file_action /etc/audit/auditd.conf"
  2490. # max_log_file_action "rotate"
  2491. # If the system has not been properly set up to rotate audit logs, this is a finding.
  2492. expect( command("grep -i '^max_log_file_action = rotate' /etc/audit/auditd.conf")).not_to return_stdout ""
  2493. # Fix: The default action to take when the logs reach their maximum size is to rotate the log files, discarding the oldest one. To configure the action taken by "auditd", add or correct the line in "/etc/audit/auditd.conf":
  2494. # max_log_file_action = [ACTION]
  2495. # Possible values for [ACTION] are described in the "auditd.conf" man page. These include:
  2496. # "ignore"
  2497. # "syslog"
  2498. # "suspend"
  2499. # "rotate"
  2500. # "keep_logs"
  2501. # Set the "[ACTION]" to "rotate" to ensure log rotation occurs. This is the default. The setting is case-insensitive.
  2502. end
  2503. # STIG Viewer Link: http://www.stigviewer.com/check/V-38635
  2504. it "V-38635 The audit system must be configured to audit all attempts to alter system time through adjtimex." do
  2505. # Check: To determine if the system is configured to audit calls to the "adjtimex" system call, run the following command:
  2506. # # auditctl -l | grep syscall | grep adjtimex
  2507. # If the system is configured to audit this activity, it will return a line.
  2508. # If the system is not configured to audit time changes, this is a finding.
  2509. expect( command("auditctl -l | grep syscall | grep adjtimex")).not_to return_stdout ""
  2510. # Fix: On a 32-bit system, add the following to "/etc/audit/audit.rules":
  2511. # # audit_time_rules
  2512. # -a always,exit -F arch=b32 -S adjtimex -k audit_time_rules
  2513. # On a 64-bit system, add the following to "/etc/audit/audit.rules":
  2514. # # audit_time_rules
  2515. # -a always,exit -F arch=b64 -S adjtimex -k audit_time_rules
  2516. # The -k option allows for the specification of a key in string form that can be used for better reporting capability through ausearch and aureport. Multiple system calls can be defined on the same line to save space if desired, but is not required. See an example of multiple combined syscalls:
  2517. # -a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime
  2518. # -k audit_time_rules
  2519. end
  2520. # STIG Viewer Link: http://www.stigviewer.com/check/V-38636
  2521. it "V-38636 The system must retain enough rotated audit logs to cover the required log retention period." do
  2522. # Check: Inspect "/etc/audit/auditd.conf" and locate the following line to determine how many logs the system is configured to retain after
  2523. # rotation: "# grep num_logs /etc/audit/auditd.conf"
  2524. # num_logs = 5
  2525. # If the overall system log file(s) retention hasn't been properly set up, this is a finding.
  2526. expect( command("grep '^num_logs = [0-9]' /etc/audit/auditd.conf")).not_to return_stdout ""
  2527. maxFileRegex = '^num_logs = (?<value>\d+)$'
  2528. maxLogFile = command("grep '^num_logs = [0-9]' /etc/audit/auditd.conf").stdout.strip
  2529. parts = maxLogFile.match(maxFileRegex)
  2530. expect( Integer(parts['value']) ).to be >= 5
  2531. # Fix: Determine how many log files "auditd" should retain when it rotates logs. Edit the file "/etc/audit/auditd.conf". Add or modify the following line, substituting [NUMLOGS] with the correct value:
  2532. # num_logs = [NUMLOGS]
  2533. # Set the value to 5 for general-purpose systems. Note that values less than 2 result in no log rotation.
  2534. end
  2535. # STIG Viewer Link: http://www.stigviewer.com/check/V-38637
  2536. it "V-38637 The system package management tool must verify contents of all files associated with the audit package." do
  2537. # Check: The following command will list which audit files on the system have file hashes different from what is expected by the RPM database.
  2538. # # rpm -V audit | grep '$1 ~ /..5/ && $2 != "c"'
  2539. # If there is output, this is a finding.
  2540. expect( command('rpm -V audit | grep \'$1 ~ /..5/ && $2 != "c"\'')).to return_stdout ""
  2541. # Fix: The RPM package management system can check the hashes of audit system package files. Run the following command to list which audit files on the system have hashes that differ from what is expected by the RPM database:
  2542. # # rpm -V audit | grep '^..5'
  2543. # A "c" in the second column indicates that a file is a configuration file, which may appropriately be expected to change. If the file that has changed was not expected to then refresh from distribution media or online repositories.
  2544. # rpm -Uvh [affected_package]
  2545. # OR
  2546. # yum reinstall [affected_package]
  2547. end
  2548. # STIG Viewer Link: http://www.stigviewer.com/check/V-38638
  2549. it "V-38638 The graphical desktop environment must have automatic lock enabled." do
  2550. # Check: To check the status of the idle screen lock activation, run the following command:
  2551. # $ gconftool-2 -g /apps/gnome-screensaver/lock_enabled
  2552. # If properly configured, the output should be "true".
  2553. # If it is not, this is a finding.
  2554. if property[:gnomeInstalled]
  2555. expect( command('gconftool-2 -g /apps/gnome-screensaver/lock_enabled')).to return_stdout "true"
  2556. else
  2557. pending( "Not applicable" )
  2558. end
  2559. # Fix: Run the following command to activate locking of the screensaver in the GNOME desktop when it is activated:
  2560. # # gconftool-2 --direct \
  2561. # --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
  2562. # --type bool \
  2563. # --set /apps/gnome-screensaver/lock_enabled true
  2564. end
  2565. # STIG Viewer Link: http://www.stigviewer.com/check/V-38639
  2566. it "V-38639 The system must display a publicly-viewable pattern during a graphical desktop environment session lock." do
  2567. # Check: To ensure the screensaver is configured to be blank, run the following command:
  2568. # $ gconftool-2 -g /apps/gnome-screensaver/mode
  2569. # If properly configured, the output should be "blank-only"
  2570. # If it is not, this is a finding.
  2571. if property[:gnomeInstalled]
  2572. expect( command('gconftool-2 -g /apps/gnome-screensaver/mode')).to return_stdout "blank-only"
  2573. else
  2574. pending( "Not applicable" )
  2575. end
  2576. # Fix: Run the following command to set the screensaver mode in the GNOME desktop to a blank screen:
  2577. # # gconftool-2
  2578. # --direct \
  2579. # --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
  2580. # --type string \
  2581. # --set /apps/gnome-screensaver/mode blank-only
  2582. end
  2583. # STIG Viewer Link: http://www.stigviewer.com/check/V-38640
  2584. it "V-38640 The Automatic Bug Reporting Tool (abrtd) service must not be running." do
  2585. # Check: To check that the "abrtd" service is disabled in system boot configuration, run the following command:
  2586. # # chkconfig "abrtd" --list
  2587. # Output should indicate the "abrtd" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2588. # # chkconfig "abrtd" --list
  2589. # "abrtd" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2590. # Run the following command to verify "abrtd" is disabled through current runtime configuration:
  2591. # # service abrtd status
  2592. # If the service is disabled the command will return the following output:
  2593. # abrtd is stopped
  2594. # If the service is running, this is a finding.
  2595. expect( service('abrtd')).not_to be_enabled
  2596. expect( service('abrtd')).not_to be_running
  2597. # Fix: The Automatic Bug Reporting Tool ("abrtd") daemon collects and reports crash data when an application crash is detected. Using a variety of plugins, abrtd can email crash reports to system administrators, log crash reports to files, or forward crash reports to a centralized issue tracking system such as RHTSupport. The "abrtd" service can be disabled with the following command:
  2598. # # chkconfig abrtd off
  2599. end
  2600. # STIG Viewer Link: http://www.stigviewer.com/check/V-38641
  2601. it "V-38641 The atd service must be disabled." do
  2602. # Check: If the system uses the "atd" service, this is not applicable.
  2603. # To check that the "atd" service is disabled in system boot configuration, run the following command:
  2604. # # chkconfig "atd" --list
  2605. # Output should indicate the "atd" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2606. # # chkconfig "atd" --list
  2607. # "atd" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2608. # Run the following command to verify "atd" is disabled through current runtime configuration:
  2609. # # service atd status
  2610. # If the service is disabled the command will return the following output:
  2611. # atd is stopped
  2612. # If the service is running, this is a finding.
  2613. expect( service('atd')).not_to be_enabled
  2614. expect( service('atd')).not_to be_running
  2615. # Fix: The "at" and "batch" commands can be used to schedule tasks that are meant to be executed only once. This allows delayed execution in a manner similar to cron, except that it is not recurring. The daemon "atd" keeps track of tasks scheduled via "at" and "batch", and executes them at the specified time. The "atd" service can be disabled with the following command:
  2616. # # chkconfig atd off
  2617. end
  2618. # STIG Viewer Link: http://www.stigviewer.com/check/V-38642
  2619. it "V-38642 The system default umask for daemons must be 027 or 022." do
  2620. # Check: To check the value of the "umask", run the following command:
  2621. # $ grep umask /etc/init.d/functions
  2622. # The output should show either "022" or "027".
  2623. # If it does not, this is a finding.
  2624. expect( command("grep -i '^umask 022\\|027' /etc/init.d/functions")).not_to return_stdout ""
  2625. # Fix: The file "/etc/init.d/functions" includes initialization parameters for most or all daemons started at boot time. The default umask of 022 prevents creation of group- or world-writable files. To set the default umask for daemons, edit the following line, inserting 022 or 027 for [UMASK] appropriately:
  2626. # umask [UMASK]
  2627. # Setting the umask to too restrictive a setting can cause serious errors at runtime. Many daemons on the system already individually restrict themselves to a umask of 077 in their own init scripts.
  2628. end
  2629. # STIG Viewer Link: http://www.stigviewer.com/check/V-38643
  2630. it "V-38643 There must be no world-writable files on the system." do
  2631. # Check: To find world-writable files, run the following command:
  2632. # # find / -xdev -type f -perm -002
  2633. # If there is output, this is a finding.
  2634. expect( command("find / -xdev -type f -perm -002")).to return_stdout ""
  2635. # Fix: It is generally a good idea to remove global (other) write access to a file when it is discovered. However, check with documentation for specific applications before making changes. Also, monitor for recurring world-writable files, as these may be symptoms of a misconfigured application or user account.
  2636. end
  2637. # STIG Viewer Link: http://www.stigviewer.com/check/V-38644
  2638. it "V-38644 The ntpdate service must not be running." do
  2639. # Check: To check that the "ntpdate" service is disabled in system boot configuration, run the following command:
  2640. # # chkconfig "ntpdate" --list
  2641. # Output should indicate the "ntpdate" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2642. # # chkconfig "ntpdate" --list
  2643. # "ntpdate" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2644. # Run the following command to verify "ntpdate" is disabled through current runtime configuration:
  2645. # # service ntpdate status
  2646. # If the service is disabled the command will return the following output:
  2647. # ntpdate is stopped
  2648. # If the service is running, this is a finding.
  2649. expect( service('ntpdate')).not_to be_enabled
  2650. expect( service('ntpdate')).not_to be_running
  2651. # Fix: The ntpdate service sets the local hardware clock by polling NTP servers when the system boots. It synchronizes to the NTP servers listed in "/etc/ntp/step-tickers" or "/etc/ntp.conf" and then sets the local hardware clock to the newly synchronized system time. The "ntpdate" service can be disabled with the following command:
  2652. # # chkconfig ntpdate off
  2653. end
  2654. # STIG Viewer Link: http://www.stigviewer.com/check/V-38645
  2655. it "V-38645 The system default umask in /etc/login.defs must be 077." do
  2656. # Check: Verify the "umask" setting is configured correctly in the "/etc/login.defs" file by running the following command:
  2657. # # grep -i "umask" /etc/login.defs
  2658. # All output must show the value of "umask" set to 077, as shown in the below:
  2659. # # grep -i "umask" /etc/login.defs
  2660. # UMASK 077
  2661. # If the above command returns no output, or if the umask is configured incorrectly, this is a finding.
  2662. expect( command("grep -i '^umask[[:space:]]\\+077' /etc/login.defs")).not_to return_stdout ""
  2663. # Fix: To ensure the default umask controlled by "/etc/login.defs" is set properly, add or correct the "umask" setting in "/etc/login.defs" to read as follows:
  2664. # UMASK 077
  2665. end
  2666. # STIG Viewer Link: http://www.stigviewer.com/check/V-38646
  2667. it "V-38646 The oddjobd service must not be running." do
  2668. # Check: To check that the "oddjobd" service is disabled in system boot configuration, run the following command:
  2669. # # chkconfig "oddjobd" --list
  2670. # Output should indicate the "oddjobd" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2671. # # chkconfig "oddjobd" --list
  2672. # "oddjobd" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2673. # Run the following command to verify "oddjobd" is disabled through current runtime configuration:
  2674. # # service oddjobd status
  2675. # If the service is disabled the command will return the following output:
  2676. # oddjobd is stopped
  2677. # If the service is running, this is a finding.
  2678. expect( service('oddjobd')).not_to be_enabled
  2679. expect( service('oddjobd')).not_to be_running
  2680. # Fix: The "oddjobd" service exists to provide an interface and access control mechanism through which specified privileged tasks can run tasks for unprivileged client applications. Communication with "oddjobd" is through the system message bus. The "oddjobd" service can be disabled with the following command:
  2681. # # chkconfig oddjobd off
  2682. end
  2683. # STIG Viewer Link: http://www.stigviewer.com/check/V-38647
  2684. it "V-38647 The system default umask in /etc/profile must be 077." do
  2685. # Check: Verify the "umask" setting is configured correctly in the "/etc/profile" file by running the following command:
  2686. # # grep "umask" /etc/profile
  2687. # All output must show the value of "umask" set to 077, as shown in the below:
  2688. # # grep "umask" /etc/profile
  2689. # umask 077
  2690. # If the above command returns no output, or if the umask is configured incorrectly, this is a finding.
  2691. expect( command("grep -i '^umask[[:space:]]\\+077' /etc/lprofile")).not_to return_stdout ""
  2692. # Fix: To ensure the default umask controlled by "/etc/profile" is set properly, add or correct the "umask" setting in "/etc/profile" to read as follows:
  2693. # umask 077
  2694. end
  2695. # STIG Viewer Link: http://www.stigviewer.com/check/V-38648
  2696. it "V-38648 The qpidd service must not be running." do
  2697. # Check: To check that the "qpidd" service is disabled in system boot configuration, run the following command:
  2698. # # chkconfig "qpidd" --list
  2699. # Output should indicate the "qpidd" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2700. # # chkconfig "qpidd" --list
  2701. # "qpidd" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2702. # Run the following command to verify "qpidd" is disabled through current runtime configuration:
  2703. # # service qpidd status
  2704. # If the service is disabled the command will return the following output:
  2705. # qpidd is stopped
  2706. # If the service is running, this is a finding.
  2707. expect( service('qpidd')).not_to be_enabled
  2708. expect( service('qpidd')).not_to be_running
  2709. # Fix: The "qpidd" service provides high speed, secure, guaranteed delivery services. It is an implementation of the Advanced Message Queuing Protocol. By default the qpidd service will bind to port 5672 and listen for connection attempts. The "qpidd" service can be disabled with the following command:
  2710. # # chkconfig qpidd off
  2711. end
  2712. # STIG Viewer Link: http://www.stigviewer.com/check/V-38649
  2713. it "V-38649 The system default umask for the csh shell must be 077." do
  2714. # Check: Verify the "umask" setting is configured correctly in the "/etc/csh.cshrc" file by running the following command:
  2715. # # grep "umask" /etc/csh.cshrc
  2716. # All output must show the value of "umask" set to 077, as shown in the below:
  2717. # # grep "umask" /etc/csh.cshrc
  2718. # umask 077
  2719. # If the above command returns no output, or if the umask is configured incorrectly, this is a finding.
  2720. expect( command("grep -i '^umask[[:space:]]\\+077' /etc/csh.cshrc")).not_to return_stdout ""
  2721. matches = command("grep -i '^umask[[:space:]]\\+077' /etc/csh.cshrc").stdout.strip
  2722. expect( matches.lines.count ).to equal(1)
  2723. # Fix: To ensure the default umask for users of the C shell is set properly, add or correct the "umask" setting in "/etc/csh.cshrc" to read as follows:
  2724. # umask 077
  2725. end
  2726. # STIG Viewer Link: http://www.stigviewer.com/check/V-38650
  2727. it "V-38650 The rdisc service must not be running." do
  2728. # Check: To check that the "rdisc" service is disabled in system boot configuration, run the following command:
  2729. # # chkconfig "rdisc" --list
  2730. # Output should indicate the "rdisc" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  2731. # # chkconfig "rdisc" --list
  2732. # "rdisc" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  2733. # Run the following command to verify "rdisc" is disabled through current runtime configuration:
  2734. # # service rdisc status
  2735. # If the service is disabled the command will return the following output:
  2736. # rdisc is stopped
  2737. # If the service is running, this is a finding.
  2738. expect( service('rdisc')).not_to be_enabled
  2739. expect( service('rdisc')).not_to be_running
  2740. # Fix: The "rdisc" service implements the client side of the ICMP Internet Router Discovery Protocol (IRDP), which allows discovery of routers on the local subnet. If a router is discovered then the local routing table is updated with a corresponding default route. By default this daemon is disabled. The "rdisc" service can be disabled with the following command:
  2741. # # chkconfig rdisc off
  2742. end
  2743. # STIG Viewer Link: http://www.stigviewer.com/check/V-38651
  2744. it "V-38651 The system default umask for the bash shell must be 077." do
  2745. # Check: Verify the "umask" setting is configured correctly in the "/etc/bashrc" file by running the following command:
  2746. # # grep "umask" /etc/bashrc
  2747. # All output must show the value of "umask" set to 077, as shown below:
  2748. # # grep "umask" /etc/bashrc
  2749. # umask 077
  2750. # umask 077
  2751. # If the above command returns no output, or if the umask is configured incorrectly, this is a finding.
  2752. expect( command("grep -i '^[[:space:]]\\+umask[[:space:]]\\+077' /etc/bashrc")).not_to return_stdout ""
  2753. matches = command("grep -i '^[[:space:]]\\+umask[[:space:]]\\+077' /etc/bashrc").stdout.strip
  2754. expect( matches.lines.count ).to equal(1)
  2755. # Fix: To ensure the default umask for users of the Bash shell is set properly, add or correct the "umask" setting in "/etc/bashrc" to read as follows:
  2756. # umask 077
  2757. end
  2758. # STIG Viewer Link: http://www.stigviewer.com/check/V-38652
  2759. it "V-38652 Remote file systems must be mounted with the nodev option." do
  2760. # Check: To verify the "nodev" option is configured for all NFS mounts, run the following command:
  2761. # $ mount | grep nfs
  2762. # All NFS mounts should show the "nodev" setting in parentheses.
  2763. # If the setting does not show, this is a finding.
  2764. if property[:roles].include? 'nfsClient'
  2765. expect( command("mount | grep nfs | grep nodev")).not_to return_stdout ""
  2766. else
  2767. pending( "Not applicable" )
  2768. end
  2769. # Fix: Add the "nodev" option to the fourth column of "/etc/fstab" for the line which controls mounting of any NFS mounts.
  2770. end
  2771. # STIG Viewer Link: http://www.stigviewer.com/check/V-38653
  2772. it "V-38653 The snmpd service must not use a default password." do
  2773. # Check: To ensure the default password is not set, run the following command:
  2774. # # grep -v "^#" /etc/snmp/snmpd.conf| grep public
  2775. # There should be no output.
  2776. # If there is output, this is a finding.
  2777. if property[:roles].include? 'snmpClient'
  2778. expect( command('grep -v "^#" /etc/snmp/snmpd.conf| grep public')).to return_stdout ""
  2779. else
  2780. pending("Not applicable")
  2781. end
  2782. # Fix: Edit "/etc/snmp/snmpd.conf", remove default community string "public". Upon doing that, restart the SNMP service:
  2783. # # service snmpd restart
  2784. end
  2785. # STIG Viewer Link: http://www.stigviewer.com/check/V-38654
  2786. it "V-38654 Remote file systems must be mounted with the nosuid option." do
  2787. # Check: To verify the "nosuid" option is configured for all NFS mounts, run the following command:
  2788. # $ mount | grep nfs
  2789. # All NFS mounts should show the "nosuid" setting in parentheses.
  2790. # If the setting does not show, this is a finding.
  2791. if property[:roles].include? 'nfsClient'
  2792. expect( command("mount | grep nfs | grep nosuid")).not_to return_stdout ""
  2793. else
  2794. pending( "Not applicable" )
  2795. end
  2796. # Fix: Add the "nosuid" option to the fourth column of "/etc/fstab" for the line which controls mounting of any NFS mounts.
  2797. end
  2798. # STIG Viewer Link: http://www.stigviewer.com/check/V-38655
  2799. it "V-38655 The noexec option must be added to removable media partitions." do
  2800. # Check: To verify that binaries cannot be directly executed from removable media, run the following command:
  2801. # # grep noexec /etc/fstab
  2802. # The output should show "noexec" in use.
  2803. # If it does not, this is a finding.
  2804. pending( "Optional step" )
  2805. # Fix: The "noexec" mount option prevents the direct execution of binaries on the mounted filesystem. Users
  2806. # should not be allowed to execute binaries that exist on partitions mounted from removable media (such as
  2807. # a USB key). The "noexec" option prevents code from being executed directly from the media itself, and may
  2808. # therefore provide a line of defense against certain types of worms or malicious code. Add the "noexec" option
  2809. # to the fourth column of "/etc/fstab" for the line which controls mounting of any removable media partitions.
  2810. end
  2811. # STIG Viewer Link: http://www.stigviewer.com/check/V-38656
  2812. it "V-38656 The system must use SMB client signing for connecting to samba servers using smbclient." do
  2813. # Check: To verify that Samba clients running smbclient must use packet signing, run the following command:
  2814. # # grep signing /etc/samba/smb.conf
  2815. # The output should show:
  2816. # client signing = mandatory
  2817. # If it is not, this is a finding.
  2818. if property[:roles].include? 'sambaClient'
  2819. expect( command("grep signing /etc/samba/smb.conf | grep 'client signing = mandatory'")).not_to return_stdout ""
  2820. else
  2821. pending("Not applicable")
  2822. end
  2823. # Fix: To require samba clients running "smbclient" to use packet signing, add the following to the "[global]" section of the Samba configuration file in "/etc/samba/smb.conf":
  2824. # client signing = mandatory
  2825. # Requiring samba clients such as "smbclient" to use packet signing ensures they can only communicate with servers that support packet signing.
  2826. end
  2827. # STIG Viewer Link: http://www.stigviewer.com/check/V-38657
  2828. it "V-38657 The system must use SMB client signing for connecting to samba servers using mount.cifs." do
  2829. # Check: To verify that Samba clients using mount.cifs must use packet signing, run the following command:
  2830. # # grep sec /etc/fstab
  2831. # The output should show either "krb5i" or "ntlmv2i" in use.
  2832. # If it does not, this is a finding.
  2833. if property[:roles].include? 'sambaClient'
  2834. expect( command("grep sec /etc/fstab | grep 'krb5i\\|ntlmv2i'")).not_to return_stdout ""
  2835. else
  2836. pending("Not applicable")
  2837. end
  2838. # Fix: Require packet signing of clients who mount Samba shares using the "mount.cifs" program (e.g., those
  2839. # who specify shares in "/etc/fstab"). To do so, ensure signing options (either "sec=krb5i" or "sec=ntlmv2i") are used.
  2840. # See the "mount.cifs(8)" man page for more information. A Samba client should only communicate with servers who
  2841. # can support SMB packet signing.
  2842. end
  2843. # STIG Viewer Link: http://www.stigviewer.com/check/V-38658
  2844. it "V-38658 The system must prohibit the reuse of passwords within twenty-four iterations." do
  2845. # Check: To verify the password reuse setting is compliant, run the following command:
  2846. # $ grep remember /etc/pam.d/system-auth
  2847. # The output should show the following at the end of the line:
  2848. # remember=24
  2849. # If it does not, this is a finding.
  2850. expect( command("grep 'remember=24' /etc/pam.d/system-auth-ac")).not_to return_stdout ""
  2851. # Fix: Do not allow users to reuse recent passwords. This can be accomplished by using the "remember" option for the "pam_unix" PAM module. In the file "/etc/pam.d/system-auth", append "remember=24" to the line which refers to the "pam_unix.so" module, as shown:
  2852. # password sufficient pam_unix.so [existing_options] remember=24
  2853. # The DoD requirement is 24 passwords.
  2854. end
  2855. # STIG Viewer Link: http://www.stigviewer.com/check/V-38659
  2856. it "V-38659 The operating system must employ cryptographic mechanisms to protect information in storage." do
  2857. # Check: Determine if encryption must be used to protect data on the system.
  2858. # If encryption must be used and is not employed, this is a finding.
  2859. pending( "Optional step" )
  2860. # Fix: Red Hat Enterprise Linux 6 natively supports partition encryption through the Linux Unified Key Setup-on-disk-format (LUKS) technology. The easiest way to encrypt a partition is during installation time.
  2861. # For manual installations, select the "Encrypt" checkbox during partition creation to encrypt the partition. When this option is selected the system will prompt for a passphrase to use in decrypting the partition. The passphrase will subsequently need to be entered manually every time the system boots.
  2862. # For automated/unattended installations, it is possible to use Kickstart by adding the "--encrypted" and "--passphrase=" options to the definition of each partition to be encrypted. For example, the following line would encrypt the root partition:
  2863. # part / --fstype=ext3 --size=100 --onpart=hda1 --encrypted --passphrase=[PASSPHRASE]
  2864. # Any [PASSPHRASE] is stored in the Kickstart in plaintext, and the Kickstart must then be protected accordingly. Omitting the "--passphrase=" option from the partition definition will cause the installer to pause and interactively ask for the passphrase during installation.
  2865. # Detailed information on encrypting partitions using LUKS can be found on the Red Had Documentation web site:
  2866. # https://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-LUKS_Disk_Encryption.html
  2867. end
  2868. # STIG Viewer Link: http://www.stigviewer.com/check/V-38660
  2869. it "V-38660 The snmpd service must use only SNMP protocol version 3 or newer." do
  2870. # Check: To ensure only SNMPv3 or newer is used, run the following command:
  2871. # # grep 'v1\|v2c\|com2sec' /etc/snmp/snmpd.conf | grep -v '^#'
  2872. # There should be no output.
  2873. # If there is output, this is a finding.
  2874. if property[:roles].include? 'snmpClient'
  2875. expect( command("grep 'v1\|v2c\|com2sec' /etc/snmp/snmpd.conf | grep -v '^#'")).to return_stdout ""
  2876. else
  2877. pending("Not applicable")
  2878. end
  2879. # Fix: Edit "/etc/snmp/snmpd.conf", removing any references to "v1", "v2c", or "com2sec". Upon doing that, restart the SNMP service:
  2880. # # service snmpd restart
  2881. end
  2882. # STIG Viewer Link: http://www.stigviewer.com/check/V-38661
  2883. it "V-38661 The operating system must protect the confidentiality and integrity of data at rest." do
  2884. # Check: Determine if encryption must be used to protect data on the system.
  2885. # If encryption must be used and is not employed, this is a finding.
  2886. pending( "Optional step" )
  2887. # Fix: Red Hat Enterprise Linux 6 natively supports partition encryption through the Linux Unified Key Setup-on-disk-format (LUKS) technology. The easiest way to encrypt a partition is during installation time.
  2888. # For manual installations, select the "Encrypt" checkbox during partition creation to encrypt the partition. When this option is selected the system will prompt for a passphrase to use in decrypting the partition. The passphrase will subsequently need to be entered manually every time the system boots.
  2889. # For automated/unattended installations, it is possible to use Kickstart by adding the "--encrypted" and "--passphrase=" options to the definition of each partition to be encrypted. For example, the following line would encrypt the root partition:
  2890. # part / --fstype=ext3 --size=100 --onpart=hda1 --encrypted --passphrase=[PASSPHRASE]
  2891. # Any [PASSPHRASE] is stored in the Kickstart in plaintext, and the Kickstart must then be protected accordingly. Omitting the "--passphrase=" option from the partition definition will cause the installer to pause and interactively ask for the passphrase during installation.
  2892. # Detailed information on encrypting partitions using LUKS can be found on the Red Had Documentation web site:
  2893. # https://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-LUKS_Disk_Encryption.html
  2894. end
  2895. # STIG Viewer Link: http://www.stigviewer.com/check/V-38662
  2896. it "V-38662 The operating system must employ cryptographic mechanisms to prevent unauthorized disclosure of data at rest unless otherwise protected by alternative physical measures." do
  2897. # Check: Determine if encryption must be used to protect data on the system.
  2898. # If encryption must be used and is not employed, this is a finding.
  2899. pending( "Optional step" )
  2900. # Fix: Red Hat Enterprise Linux 6 natively supports partition encryption through the Linux Unified Key Setup-on-disk-format (LUKS) technology. The easiest way to encrypt a partition is during installation time.
  2901. # For manual installations, select the "Encrypt" checkbox during partition creation to encrypt the partition. When this option is selected the system will prompt for a passphrase to use in decrypting the partition. The passphrase will subsequently need to be entered manually every time the system boots.
  2902. # For automated/unattended installations, it is possible to use Kickstart by adding the "--encrypted" and "--passphrase=" options to the definition of each partition to be encrypted. For example, the following line would encrypt the root partition:
  2903. # part / --fstype=ext3 --size=100 --onpart=hda1 --encrypted --passphrase=[PASSPHRASE]
  2904. # Any [PASSPHRASE] is stored in the Kickstart in plaintext, and the Kickstart must then be protected accordingly. Omitting the "--passphrase=" option from the partition definition will cause the installer to pause and interactively ask for the passphrase during installation.
  2905. # Detailed information on encrypting partitions using LUKS can be found on the Red Had Documentation web site:
  2906. # https://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-LUKS_Disk_Encryption.html
  2907. end
  2908. # STIG Viewer Link: http://www.stigviewer.com/check/V-38663
  2909. it "V-38663 The system package management tool must verify permissions on all files and directories associated with the audit package." do
  2910. # Check: The following command will list which audit files on the system have permissions different from what is expected by the RPM database:
  2911. # # rpm -V audit | grep '^.M'
  2912. # If there is any output, for each file or directory found, compare the RPM-expected permissions with the permissions on the file or directory:
  2913. # # rpm -q --queryformat "[%{FILENAMES} %{FILEMODES:perms}\n]" audit | grep [filename]
  2914. # # ls -lL [filename]
  2915. # If the existing permissions are more permissive than those expected by RPM, this is a finding.
  2916. expect( command("rpm -V audit | grep '^.M'")).to return_stdout ""
  2917. # Fix: The RPM package management system can restore file access permissions of the audit package files and directories. The following command will update audit files with permissions different from what is expected by the RPM database:
  2918. # # rpm --setperms audit
  2919. end
  2920. # STIG Viewer Link: http://www.stigviewer.com/check/V-38664
  2921. it "V-38664 The system package management tool must verify ownership on all files and directories associated with the audit package." do
  2922. # Check: The following command will list which audit files on the system have ownership different from what is expected by the RPM database:
  2923. # # rpm -V audit | grep '^.....U'
  2924. # If there is output, this is a finding.
  2925. expect( command("rpm -V audit | grep '^.....U'")).to return_stdout ""
  2926. # Fix: The RPM package management system can restore file ownership of the audit package files and directories. The following command will update audit files with ownership different from what is expected by the RPM database:
  2927. # # rpm --setugids audit
  2928. end
  2929. # STIG Viewer Link: http://www.stigviewer.com/check/V-38665
  2930. it "V-38665 The system package management tool must verify group-ownership on all files and directories associated with the audit package." do
  2931. # Check: The following command will list which audit files on the system have group-ownership different from what is expected by the RPM database:
  2932. # # rpm -V audit | grep '^......G'
  2933. # If there is output, this is a finding.
  2934. expect( command("rpm -V audit | grep '^......G'")).to return_stdout ""
  2935. # Fix: The RPM package management system can restore file group-ownership of the audit package files and directories. The following command will update audit files with group-ownership different from what is expected by the RPM database:
  2936. # # rpm --setugids audit
  2937. end
  2938. # STIG Viewer Link: http://www.stigviewer.com/check/V-38666
  2939. it "V-38666 The system must use and update a DoD-approved virus scan program." do
  2940. # Check: Inspect the system for a cron job or system service which executes a virus scanning tool regularly.
  2941. # To verify the McAfee command line scan tool (uvscan) is scheduled for regular execution, run the following command to check for a cron job:
  2942. # # grep uvscan /etc/cron* /var/spool/cron/*
  2943. # This will reveal if and when the uvscan program will be run.
  2944. # To check on the age of uvscan virus definition files, run the following command:
  2945. # # cd /usr/local/uvscan
  2946. # # ls -la avvscan.dat avvnames.dat avvclean.dat
  2947. # The uvscan virus definitions should not be older than seven days.
  2948. # If virus scanning software does not run daily, or has signatures that are out of date, this is a finding.
  2949. expect( package("clamav")).to be_installed
  2950. ### Couldn't get this to work in bash. Had to bring out the big guns.
  2951. daysOld = command('python -c "import os.path, time;print (time.time() - os.path.getmtime(\"/var/lib/clamav/daily.cld\")) / (24 * 60 * 60)"').stdout.strip
  2952. expect( Float(daysOld)).to be <= 7.0
  2953. # Fix: Install virus scanning software, which uses signatures to search for the presence of viruses on the filesystem.
  2954. # The McAfee uvscan virus scanning tool is provided for DoD systems. Ensure virus definition files are no older than
  2955. # 7 days, or their last release. Configure the virus scanning software to perform scans dynamically on all accessed
  2956. # files. If this is not possible, configure the system to scan all altered files on the system on a daily basis. If
  2957. # the system processes inbound SMTP mail, configure the virus scanner to scan all received mail.
  2958. end
  2959. # STIG Viewer Link: http://www.stigviewer.com/check/V-38667
  2960. it "V-38667 The system must have a host-based intrusion detection tool installed." do
  2961. # Check: Inspect the system to determine if intrusion detection software has been installed. Verify the intrusion
  2962. # detection software is active.
  2963. # If no host-based intrusion detection tools are installed, this is a finding.
  2964. if $environment['ids'] == 'ossec'
  2965. expect( package('ossec-hids') ).to be_installed
  2966. elsif $environment['ids'] == 'aide'
  2967. expect( package('aide') ).to be_installed
  2968. else
  2969. fail("IDS variable set to unknown value")
  2970. end
  2971. # Fix: The base Red Hat platform already includes a sophisticated auditing system that can detect intruder activity, as
  2972. # well as SELinux, which provides host-based intrusion prevention capabilities by confining privileged programs and
  2973. # user sessions which may become compromised.
  2974. # Install an additional intrusion detection tool to provide complementary or duplicative monitoring, reporting, and
  2975. # reaction capabilities to those of the base platform. For DoD systems, the McAfee Host-based Security System is
  2976. # provided to fulfill this role.
  2977. end
  2978. # STIG Viewer Link: http://www.stigviewer.com/check/V-38668
  2979. it "V-38668 The x86 Ctrl-Alt-Delete key sequence must be disabled." do
  2980. # Check: Determine what actions the system takes when the Ctrl-Alt-Delete key sequence is pressed, run the following command:
  2981. # # cat `grep -l control-alt-delete /etc/init/*`
  2982. # Examine all lines following the "start on control-alt-delete" line in any files found. By default, the system uses
  2983. # "/etc/init/control-alt-delete.conf" to reboot the system with the following command when the Ctrl-Alt-Delete key sequence is pressed:
  2984. # exec /sbin/shutdown -r now "Control-Alt-Delete pressed"
  2985. # If the system is configured to run any shutdown command, this is a finding.
  2986. expect( file('/etc/init/control-alt-delete.override')).to be_file
  2987. expect( file('/etc/init/control-alt-delete.override')).to contain /^exec \/usr\/bin\/logger -p security.info "Ctrl-Alt-Delete pressed"/
  2988. matches = command("cat /etc/init/control-alt-delete.override").stdout.strip
  2989. expect( matches.lines.count ).to equal(1)
  2990. # Fix: Configure the system to log a message instead of rebooting the system by altering the "shutdown" line in "/etc/init/control-alt-delete.conf" to read as follows:
  2991. # exec /usr/bin/logger -p security.info "Ctrl-Alt-Delete pressed"
  2992. end
  2993. # STIG Viewer Link: http://www.stigviewer.com/check/V-38669
  2994. it "V-38669 The postfix service must be enabled for mail delivery." do
  2995. # Check: Run the following command to determine the current status of the "postfix" service:
  2996. # # service postfix status
  2997. # If the service is enabled, it should return the following:
  2998. # postfix is running...
  2999. # If the service is not enabled, this is a finding.
  3000. expect( service('postfix')).to be_enabled
  3001. expect( service('postfix')).to be_running
  3002. # Fix: The Postfix mail transfer agent is used for local mail delivery within the system. The default configuration only listens for connections to the default SMTP port (port 25) on the loopback interface (127.0.0.1). It is recommended to leave this service enabled for local mail delivery. The "postfix" service can be enabled with the following command:
  3003. # # chkconfig postfix on
  3004. # # service postfix start
  3005. end
  3006. # STIG Viewer Link: http://www.stigviewer.com/check/V-38670
  3007. it "V-38670 The operating system must detect unauthorized changes to software and information." do
  3008. # Check: To determine that periodic AIDE execution has been scheduled, run the following command:
  3009. # # grep aide /etc/crontab
  3010. # If there is no output, this is a finding.
  3011. if $environment['ids'] == 'ossec'
  3012. expect( service('ossec-hids')).to be_enabled
  3013. expect( service('ossec-hids')).to be_running
  3014. elsif $environment['ids'] == 'aide'
  3015. expect( command("grep aide /etc/crontab")).not_to return_stdout ""
  3016. else
  3017. fail("IDS variable set to unknown value")
  3018. end
  3019. # Fix: AIDE should be executed on a periodic basis to check for changes. To implement a daily execution of AIDE at 4:05am using cron, add the following line to /etc/crontab:
  3020. # 05 4 * * * root /usr/sbin/aide --check
  3021. # AIDE can be executed periodically through other means; this is merely one example.
  3022. end
  3023. # STIG Viewer Link: http://www.stigviewer.com/check/V-38671
  3024. it "V-38671 The sendmail package must be removed." do
  3025. # Check: Run the following command to determine if the "sendmail" package is installed:
  3026. # # rpm -q sendmail
  3027. # If the package is installed, this is a finding.
  3028. expect( package('sendmail')).not_to be_installed
  3029. # Fix: Sendmail is not the default mail transfer agent and is not installed by default. The "sendmail" package can be removed with the following command:
  3030. # # yum erase sendmail
  3031. end
  3032. # STIG Viewer Link: http://www.stigviewer.com/check/V-38672
  3033. it "V-38672 The netconsole service must be disabled unless required." do
  3034. # Check: To check that the "netconsole" service is disabled in system boot configuration, run the following command:
  3035. # # chkconfig "netconsole" --list
  3036. # Output should indicate the "netconsole" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  3037. # # chkconfig "netconsole" --list
  3038. # "netconsole" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  3039. # Run the following command to verify "netconsole" is disabled through current runtime configuration:
  3040. # # service netconsole status
  3041. # If the service is disabled the command will return the following output:
  3042. # netconsole is stopped
  3043. # If the service is running, this is a finding.
  3044. expect( service('netconsole')).not_to be_enabled
  3045. expect( service('netconsole')).not_to be_running
  3046. # Fix: The "netconsole" service is responsible for loading the netconsole kernel module, which logs kernel printk messages over UDP to a syslog server. This allows debugging of problems where disk logging fails and serial consoles are impractical. The "netconsole" service can be disabled with the following command:
  3047. # # chkconfig netconsole off
  3048. end
  3049. # STIG Viewer Link: http://www.stigviewer.com/check/V-38673
  3050. it "V-38673 The operating system must ensure unauthorized, security-relevant configuration changes detected are tracked." do
  3051. # Check: To determine that periodic AIDE execution has been scheduled, run the following command:
  3052. # # grep aide /etc/crontab
  3053. # If there is no output, this is a finding.
  3054. if $environment['ids'] == 'ossec'
  3055. expect( service('ossec-hids')).to be_enabled
  3056. expect( service('ossec-hids')).to be_running
  3057. elsif $environment['ids'] == 'aide'
  3058. expect( command("grep aide /etc/crontab")).not_to return_stdout ""
  3059. else
  3060. fail("IDS variable set to unknown value")
  3061. end
  3062. # Fix: AIDE should be executed on a periodic basis to check for changes. To implement a daily execution of AIDE at 4:05am using cron, add the following line to /etc/crontab:
  3063. # 05 4 * * * root /usr/sbin/aide --check
  3064. # AIDE can be executed periodically through other means; this is merely one example.
  3065. end
  3066. # STIG Viewer Link: http://www.stigviewer.com/check/V-38674
  3067. it "V-38674 X Windows must not be enabled unless required." do
  3068. # Check: To verify the default runlevel is 3, run the following command:
  3069. # # grep initdefault /etc/inittab
  3070. # The output should show the following:
  3071. # id:3:initdefault:
  3072. # If it does not, this is a finding.
  3073. expect( command("grep initdefault /etc/inittab| grep 'id:3:initdefault:'")).not_to return_stdout ""
  3074. # Fix: Setting the system's runlevel to 3 will prevent automatic startup of the X server. To do so, ensure the following line in "/etc/inittab" features a "3" as shown:
  3075. # id:3:initdefault:
  3076. end
  3077. # STIG Viewer Link: http://www.stigviewer.com/check/V-38675
  3078. it "V-38675 Process core dumps must be disabled unless needed." do
  3079. # Check: To verify that core dumps are disabled for all users, run the following command:
  3080. # $ grep core /etc/security/limits.conf
  3081. # The output should be:
  3082. # * hard core 0
  3083. # If it is not, this is a finding.
  3084. expect( command("grep '^* hard core 0' /etc/security/limits.conf")).not_to return_stdout ""
  3085. # Fix: To disable core dumps for all users, add the following line to "/etc/security/limits.conf":
  3086. # * hard core 0
  3087. end
  3088. # STIG Viewer Link: http://www.stigviewer.com/check/V-38676
  3089. it "V-38676 The xorg-x11-server-common (X Windows) package must not be installed, unless required." do
  3090. # Check: To ensure the X Windows package group is removed, run the following command:
  3091. # $ rpm -qi xorg-x11-server-common
  3092. # The output should be:
  3093. # package xorg-x11-server-common is not installed
  3094. # If it is not, this is a finding.
  3095. expect( command("rpm -qi xorg-x11-server-common")).to return_stdout "package xorg-x11-server-common is not installed"
  3096. # Fix: Removing all packages which constitute the X Window System ensures users or malicious software cannot start X. To do so, run the following command:
  3097. # # yum groupremove "X Window System"
  3098. end
  3099. # STIG Viewer Link: http://www.stigviewer.com/check/V-38677
  3100. it "V-38677 The NFS server must not have the insecure file locking option enabled." do
  3101. # Check: To verify insecure file locking has been disabled, run the following command:
  3102. # # grep insecure_locks /etc/exports
  3103. # If there is output, this is a finding.
  3104. if property[:roles].include? 'nfsServer'
  3105. expect( command("grep insecure_locks /etc/exports")).to return_stdout ""
  3106. else
  3107. pending( "Not applicable" )
  3108. end
  3109. # Fix: By default the NFS server requires secure file-lock requests, which require credentials from the client in order to lock a file. Most NFS clients send credentials with file lock requests, however, there are a few clients that do not send credentials when requesting a file-lock, allowing the client to only be able to lock world-readable files. To get around this, the "insecure_locks" option can be used so these clients can access the desired export. This poses a security risk by potentially allowing the client access to data for which it does not have authorization. Remove any instances of the "insecure_locks" option from the file "/etc/exports".
  3110. end
  3111. # STIG Viewer Link: http://www.stigviewer.com/check/V-38678
  3112. it "V-38678 The audit system must provide a warning when allocated audit record storage volume reaches a documented percentage of maximum audit record storage capacity." do
  3113. # Check: Inspect "/etc/audit/auditd.conf" and locate the following line to determine whether the system is configured to email
  3114. # the administrator when disk space is starting to run low:
  3115. # # grep space_left /etc/audit/auditd.conf
  3116. # space_left = [num_megabytes]
  3117. # If the "num_megabytes" value does not correspond to a documented value for remaining audit partition capacity
  3118. # or if there is no locally documented value for remaining audit partition capacity, this is a finding.
  3119. expect( command("grep ^space_left /etc/audit/auditd.conf ")).not_to return_stdout ""
  3120. maxFileRegex = '^space_left = (?<value>\d+)$'
  3121. maxLogFile = command("grep '^space_left = [0-9]' /etc/audit/auditd.conf").stdout.strip
  3122. parts = maxLogFile.match(maxFileRegex)
  3123. expect( Integer(parts['value']) ).to equal($environment['auditSpaceLeftInMegabytes'])
  3124. # Fix: The "auditd" service can be configured to take an action when disk space starts to run low. Edit the file
  3125. # "/etc/audit/auditd.conf". Modify the following line, substituting [ACTION] appropriately:
  3126. # space_left = [num_megabytes]
  3127. # The "num_megabytes" value should be set to a fraction of the total audit storage capacity available that will allow
  3128. # a system administrator to be notified with enough time to respond to the situation causing the capacity issues.
  3129. # This value must also be documented locally.
  3130. end
  3131. # STIG Viewer Link: http://www.stigviewer.com/check/V-38679
  3132. it "V-38679 The DHCP client must be disabled if not needed." do
  3133. # Check: To verify that DHCP is not being used, examine the following file for each interface.
  3134. # # /etc/sysconfig/network-scripts/ifcfg-[IFACE]
  3135. # If there is any network interface without a associated "ifcfg" file, this is a finding.
  3136. # Look for the following:
  3137. # BOOTPROTO=static
  3138. # Also verify the following, substituting the appropriate values based on your site's addressing scheme:
  3139. # NETMASK=[local LAN netmask]
  3140. # IPADDR=[assigned IP address]
  3141. # GATEWAY=[local LAN default gateway]
  3142. # If it does not, this is a finding.
  3143. property[:networks].each do |nic|
  3144. expect( file("/etc/sysconfig/network-scripts/ifcfg-eth#{nic['device_id']}#{nic['vlan_id']}")).to be_file
  3145. if nic['boot_protocol'] == "dhcp"
  3146. expect( command("grep -i '^BOOTPROTO=#{nic['boot_protocol']}' /etc/sysconfig/network-scripts/ifcfg-eth#{nic['device_id']}#{nic['vlan_id']}")).not_to return_stdout ""
  3147. else
  3148. expect( command("grep -i '^BOOTPROTO=#{nic['boot_protocol']}' /etc/sysconfig/network-scripts/ifcfg-eth#{nic['device_id']}#{nic['vlan_id']}")).not_to return_stdout ""
  3149. expect( command("grep -i '^PREFIX=#{nic['prefix']}' /etc/sysconfig/network-scripts/ifcfg-eth#{nic['device_id']}#{nic['vlan_id']}")).not_to return_stdout ""
  3150. expect( command("grep -i '^IPADDR=#{nic['ip_address']}' /etc/sysconfig/network-scripts/ifcfg-eth#{nic['device_id']}#{nic['vlan_id']}")).not_to return_stdout ""
  3151. end
  3152. end
  3153. # Fix: For each interface [IFACE] on the system (e.g. eth0), edit "/etc/sysconfig/network-scripts/ifcfg-[IFACE]" and
  3154. # make the following changes.
  3155. # Correct the BOOTPROTO line to read:
  3156. # BOOTPROTO=static
  3157. # Add or correct the following lines, substituting the appropriate values based on your site's addressing scheme:
  3158. # NETMASK=[local LAN netmask]
  3159. # IPADDR=[assigned IP address]
  3160. # GATEWAY=[local LAN default gateway]
  3161. end
  3162. # STIG Viewer Link: http://www.stigviewer.com/check/V-38680
  3163. it "V-38680 The audit system must identify staff members to receive notifications of audit log storage volume capacity issues." do
  3164. # Check: Inspect "/etc/audit/auditd.conf" and locate the following line to determine if the system is configured to send email to an account when it needs to notify an administrator:
  3165. # action_mail_acct = root
  3166. # If auditd is not configured to send emails per identified actions, this is a finding.
  3167. expect( command("grep -i '^action_mail_acct = root' /etc/audit/auditd.conf")).not_to return_stdout ""
  3168. # Fix: The "auditd" service can be configured to send email to a designated account in certain situations. Add or correct the following line in "/etc/audit/auditd.conf" to ensure that administrators are notified via email for those situations:
  3169. # action_mail_acct = root
  3170. end
  3171. # STIG Viewer Link: http://www.stigviewer.com/check/V-38681
  3172. it "V-38681 All GIDs referenced in /etc/passwd must be defined in /etc/group" do
  3173. # Check: To ensure all GIDs referenced in /etc/passwd are defined in /etc/group, run the following command:
  3174. # # pwck -rq
  3175. # There should be no output.
  3176. # If there is output, this is a finding.
  3177. expect( command("pwck -rq")).to return_stdout ""
  3178. # Fix: Add a group to the system for each GID referenced without a corresponding group.
  3179. end
  3180. # STIG Viewer Link: http://www.stigviewer.com/check/V-38682
  3181. it "V-38682 The Bluetooth kernel module must be disabled." do
  3182. # Check: If the system is configured to prevent the loading of the "bluetooth" kernel module, it will contain lines inside any file in "/etc/modprobe.d" or the deprecated"/etc/modprobe.conf". These lines instruct the module loading system to run another program (such as "/bin/true") upon a module "install" event. Run the following command to search for such lines in all files in "/etc/modprobe.d" and the deprecated "/etc/modprobe.conf":
  3183. # $ grep -r bluetooth /etc/modprobe.conf /etc/modprobe.d
  3184. # If the system is configured to prevent the loading of the "net-pf-31" kernel module, it will contain lines inside any file in "/etc/modprobe.d" or the deprecated"/etc/modprobe.conf". These lines instruct the module loading system to run another program (such as "/bin/true") upon a module "install" event. Run the following command to search for such lines in all files in "/etc/modprobe.d" and the deprecated "/etc/modprobe.conf":
  3185. # $ grep -r net-pf-31 /etc/modprobe.conf /etc/modprobe.d
  3186. # If no line is returned, this is a finding.
  3187. expect( command("grep -r bluetooth /etc/modprobe.d")).not_to return_stdout ""
  3188. expect( command("grep -r net-pf-31 /etc/modprobe.d")).not_to return_stdout ""
  3189. # Fix: The kernel's module loading system can be configured to prevent loading of the Bluetooth module. Add the following to the appropriate "/etc/modprobe.d" configuration file to prevent the loading of the Bluetooth module:
  3190. # install net-pf-31 /bin/true
  3191. # install bluetooth /bin/true
  3192. end
  3193. # STIG Viewer Link: http://www.stigviewer.com/check/V-38683
  3194. it "V-38683 All accounts on the system must have unique user or account names" do
  3195. # Check: Run the following command to check for duplicate account names:
  3196. # # pwck -rq
  3197. # If there are no duplicate names, no line will be returned.
  3198. # If a line is returned, this is a finding.
  3199. expect( command("pwck -rq")).to return_stdout ""
  3200. # Fix: Change usernames, or delete accounts, so each has a unique name.
  3201. end
  3202. # STIG Viewer Link: http://www.stigviewer.com/check/V-38684
  3203. it "V-38684 The system must limit users to 10 simultaneous system logins, or a site-defined number, in accordance with operational requirements." do
  3204. # Check: Run the following command to ensure the "maxlogins" value is configured for all users on the system:
  3205. # # grep "maxlogins" /etc/security/limits.conf
  3206. # You should receive output similar to the following:
  3207. # * hard maxlogins 10
  3208. # If it is not set to 10 or a documented site-defined number, this is a finding.
  3209. expect( command("grep '^* hard maxlogins 10' /etc/security/limits.conf")).not_to return_stdout ""
  3210. # Fix: Limiting the number of allowed users and sessions per user can limit risks related to denial of service attacks. This addresses concurrent sessions for a single account and does not address concurrent sessions by a single user via multiple accounts. To set the number of concurrent sessions per user add the following line in "/etc/security/limits.conf":
  3211. # * hard maxlogins 10
  3212. # A documented site-defined number may be substituted for 10 in the above.
  3213. end
  3214. # STIG Viewer Link: http://www.stigviewer.com/check/V-38685
  3215. it "V-38685 Temporary accounts must be provisioned with an expiration date." do
  3216. # Check: For every temporary account, run the following command to obtain its account aging and expiration information:
  3217. # # chage -l [USER]
  3218. # Verify each of these accounts has an expiration date set as documented.
  3219. # If any temporary accounts have no expiration date set or do not expire within a documented time frame, this is a finding.
  3220. pending( "Manual step" )
  3221. # Fix: In the event temporary accounts are required, configure the system to terminate them after a documented time period. For every temporary account, run the following command to set an expiration date on it, substituting "[USER]" and "[YYYY-MM-DD]" appropriately:
  3222. # # chage -E [YYYY-MM-DD] [USER]
  3223. # "[YYYY-MM-DD]" indicates the documented expiration date for the account.
  3224. end
  3225. # STIG Viewer Link: http://www.stigviewer.com/check/V-38686
  3226. it "V-38686 The systems local firewall must implement a deny-all, allow-by-exception policy for forwarded packets." do
  3227. # Check: Run the following command to ensure the default "FORWARD" policy is "DROP":
  3228. # grep ":FORWARD" /etc/sysconfig/iptables
  3229. # The output must be the following:
  3230. # # grep ":FORWARD" /etc/sysconfig/iptables
  3231. # :FORWARD DROP [0:0]
  3232. # If it is not, this is a finding.
  3233. if property[:roles].include? 'router'
  3234. pending("Not applicable")
  3235. else
  3236. expect( file('/etc/sysconfig/iptables')).to contain /^\:FORWARD DROP \[0\:0\]/
  3237. if $environment['ipv6Enabled']
  3238. expect( file('/etc/sysconfig/ip6tables')).to contain /^\:FORWARD DROP \[0\:0\]/
  3239. end
  3240. end
  3241. # Fix: To set the default policy to DROP (instead of ACCEPT) for the built-in FORWARD chain which processes packets that will be forwarded from one interface to another, add or correct the following line in "/etc/sysconfig/iptables":
  3242. # :FORWARD DROP [0:0]
  3243. end
  3244. # STIG Viewer Link: http://www.stigviewer.com/check/V-38687
  3245. it "V-38687 The system must provide VPN connectivity for communications over untrusted networks." do
  3246. # Check: Run the following command to determine if the "openswan" package is installed:
  3247. # # rpm -q openswan
  3248. # If the package is not installed, this is a finding.
  3249. if property[:roles].include? 'VPN'
  3250. expect( package("openswan")).to be_installed
  3251. else
  3252. pending( "Not applicable" )
  3253. end
  3254. # Fix: The Openswan package provides an implementation of IPsec and IKE, which permits the creation of secure tunnels over untrusted networks. The "openswan" package can be installed with the following command:
  3255. # # yum install openswan
  3256. end
  3257. # STIG Viewer Link: http://www.stigviewer.com/check/V-38688
  3258. it "V-38688 A login banner must be displayed immediately prior to, or as part of, graphical desktop environment login prompts." do
  3259. # Check: To ensure a login warning banner is enabled, run the following:
  3260. # $ gconftool-2 -g /apps/gdm/simple-greeter/banner_message_enable
  3261. # Search for the "banner_message_enable" schema. If properly configured, the "default" value should be "true".
  3262. # If it is not, this is a finding.
  3263. if property[:gnomeInstalled]
  3264. expect( command("gconftool-2 -g /apps/gdm/simple-greeter/banner_message_enable")).to return_stdout "true"
  3265. else
  3266. pending("Not applicable")
  3267. end
  3268. # Fix: To enable displaying a login warning banner in the GNOME Display Manager's login screen, run the following command:
  3269. # sudo -u gdm gconftool-2 \
  3270. # --type bool \
  3271. # --set /apps/gdm/simple-greeter/banner_message_enable true
  3272. # To display a banner, this setting must be enabled and then banner text must also be set.
  3273. end
  3274. # STIG Viewer Link: http://www.stigviewer.com/check/V-38689
  3275. it "V-38689 The Department of Defense (DoD) login banner must be displayed immediately prior to, or as part of, graphical desktop environment login prompts." do
  3276. # Check: To ensure login warning banner text is properly set, run the following:
  3277. # $ gconftool-2 -g /apps/gdm/simple-greeter/banner_message_text
  3278. # If properly configured, the proper banner text will appear within this schema.
  3279. # The DoD required text is either:
  3280. # "You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only. By using this IS (which includes any device attached to this IS), you consent to the following conditions:
  3281. # -The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM), law enforcement (LE), and counterintelligence (CI) investigations.
  3282. # -At any time, the USG may inspect and seize data stored on this IS.
  3283. # -Communications using, or data stored on, this IS are not private, are subject to routine monitoring, interception, and search, and may be disclosed or used for any USG-authorized purpose.
  3284. # -This IS includes security measures (e.g., authentication and access controls) to protect USG interests -- not for your personal benefit or privacy.
  3285. # -Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching or monitoring of the content of privileged communications, or work product, related to personal representation or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product are private and confidential. See User Agreement for details."
  3286. # OR:
  3287. # "I've read & consent to terms in IS user agreem't."
  3288. # If the DoD required banner text is not appear in the schema, this is a finding.
  3289. if property[:gnomeInstalled]
  3290. expect( command("gconftool-2 -g /apps/gdm/simple-greeter/banner_message_text")).not_to return_stdout ""
  3291. else
  3292. pending("Not applicable")
  3293. end
  3294. # Fix: To set the text shown by the GNOME Display Manager in the login screen, run the following command:
  3295. # sudo -u gdm gconftool-2 \
  3296. # --type string \
  3297. # --set /apps/gdm/simple-greeter/banner_message_text \
  3298. # "[DoD required text]"
  3299. # Where the DoD required text is either:
  3300. # "You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only. By using this IS (which includes any device attached to this IS), you consent to the following conditions:
  3301. # -The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM), law enforcement (LE), and counterintelligence (CI) investigations.
  3302. # -At any time, the USG may inspect and seize data stored on this IS.
  3303. # -Communications using, or data stored on, this IS are not private, are subject to routine monitoring, interception, and search, and may be disclosed or used for any USG-authorized purpose.
  3304. # -This IS includes security measures (e.g., authentication and access controls) to protect USG interests -- not for your personal benefit or privacy.
  3305. # -Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching or monitoring of the content of privileged communications, or work product, related to personal representation or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product are private and confidential. See User Agreement for details."
  3306. # OR:
  3307. # "I've read & consent to terms in IS user agreem't."
  3308. # When entering a warning banner that spans several lines, remember to begin and end the string with """. This command writes directly to the file "/var/lib/gdm/.gconf/apps/gdm/simple-greeter/%gconf.xml", and this file can later be edited directly if necessary.
  3309. end
  3310. # STIG Viewer Link: http://www.stigviewer.com/check/V-38690
  3311. it "V-38690 Emergency accounts must be provisioned with an expiration date." do
  3312. # Check: For every emergency account, run the following command to obtain its account aging and expiration information:
  3313. # # chage -l [USER]
  3314. # Verify each of these accounts has an expiration date set as documented.
  3315. # If any emergency accounts have no expiration date set or do not expire within a documented time frame, this is a finding.
  3316. pending( "Manual step" )
  3317. # Fix: In the event emergency accounts are required, configure the system to terminate them after a documented time period. For every emergency account, run the following command to set an expiration date on it, substituting "[USER]" and "[YYYY-MM-DD]" appropriately:
  3318. # # chage -E [YYYY-MM-DD] [USER]
  3319. # "[YYYY-MM-DD]" indicates the documented expiration date for the account.
  3320. end
  3321. # STIG Viewer Link: http://www.stigviewer.com/check/V-38691
  3322. it "V-38691 The Bluetooth service must be disabled." do
  3323. # Check: To check that the "bluetooth" service is disabled in system boot configuration, run the following command:
  3324. # # chkconfig "bluetooth" --list
  3325. # Output should indicate the "bluetooth" service has either not been installed, or has been disabled at all runlevels, as shown in the example below:
  3326. # # chkconfig "bluetooth" --list
  3327. # "bluetooth" 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  3328. # Run the following command to verify "bluetooth" is disabled through current runtime configuration:
  3329. # # service bluetooth status
  3330. # If the service is disabled the command will return the following output:
  3331. # bluetooth is stopped
  3332. # If the service is running, this is a finding.
  3333. expect( service('bluetooth')).not_to be_enabled
  3334. expect( service('bluetooth')).not_to be_running
  3335. # Fix: The "bluetooth" service can be disabled with the following command:
  3336. # # chkconfig bluetooth off
  3337. # # service bluetooth stop
  3338. end
  3339. # STIG Viewer Link: http://www.stigviewer.com/check/V-38692
  3340. it "V-38692 Accounts must be locked upon 35 days of inactivity." do
  3341. # Check: To verify the "INACTIVE" setting, run the following command:
  3342. # grep "INACTIVE" /etc/default/useradd
  3343. # The output should indicate the "INACTIVE" configuration option is set to an appropriate integer as shown in the example below:
  3344. # # grep "INACTIVE" /etc/default/useradd
  3345. # INACTIVE=35
  3346. # If it does not, this is a finding.
  3347. expect( command("grep -i '^INACTIVE=35' /etc/default/useradd")).not_to return_stdout ""
  3348. # Fix: To specify the number of days after a password expires (which signifies inactivity) until an account is permanently disabled, add or correct the following lines in "/etc/default/useradd", substituting "[NUM_DAYS]" appropriately:
  3349. # INACTIVE=[NUM_DAYS]
  3350. # A value of 35 is recommended. If a password is currently on the verge of expiration, then 35 days remain until the account is automatically disabled. However, if the password will not expire for another 60 days, then 95 days could elapse until the account would be automatically disabled. See the "useradd" man page for more information. Determining the inactivity timeout must be done with careful consideration of the length of a "normal" period of inactivity for users in the particular environment. Setting the timeout too low incurs support costs and also has the potential to impact availability of the system to legitimate users.
  3351. end
  3352. # STIG Viewer Link: http://www.stigviewer.com/check/V-38693
  3353. it "V-38693 The system must require passwords to contain no more than three consecutive repeating characters." do
  3354. # Check: To check the maximum value for consecutive repeating characters, run the following command:
  3355. # $ grep pam_cracklib /etc/pam.d/system-auth
  3356. # Look for the value of the "maxrepeat" parameter. The DoD requirement is 3.
  3357. # If maxrepeat is not found or not set to the required value, this is a finding.
  3358. expect( command("grep pam_cracklib /etc/pam.d/system-auth-ac | grep 'maxrepeat=3' ")).not_to return_stdout ""
  3359. # Fix: The pam_cracklib module's "maxrepeat" parameter controls requirements for consecutive repeating characters. Edit the "/etc/pam.d/system-auth" file to include the following line prior to the "password include system-auth-ac" line:
  3360. # password required pam_cracklib.so maxrepeat=3
  3361. end
  3362. # STIG Viewer Link: http://www.stigviewer.com/check/V-38694
  3363. it "V-38694 The operating system must manage information system identifiers for users and devices by disabling the user identifier after an organization defined time period of inactivity." do
  3364. # Check: To verify the "INACTIVE" setting, run the following command:
  3365. # grep "INACTIVE" /etc/default/useradd
  3366. # The output should indicate the "INACTIVE" configuration option is set to an appropriate integer as shown in the example below:
  3367. # # grep "INACTIVE" /etc/default/useradd
  3368. # INACTIVE=35
  3369. # If it does not, this is a finding.
  3370. expect( command("grep -i '^INACTIVE=35' /etc/default/useradd")).not_to return_stdout ""
  3371. # Fix: To specify the number of days after a password expires (which signifies inactivity) until an account is permanently disabled, add or correct the following lines in "/etc/default/useradd", substituting "[NUM_DAYS]" appropriately:
  3372. # INACTIVE=[NUM_DAYS]
  3373. # A value of 35 is recommended. If a password is currently on the verge of expiration, then 35 days remain until the account is automatically disabled. However, if the password will not expire for another 60 days, then 95 days could elapse until the account would be automatically disabled. See the "useradd" man page for more information. Determining the inactivity timeout must be done with careful consideration of the length of a "normal" period of inactivity for users in the particular environment. Setting the timeout too low incurs support costs and also has the potential to impact availability of the system to legitimate users.
  3374. end
  3375. # STIG Viewer Link: http://www.stigviewer.com/check/V-38695
  3376. it "V-38695 A file integrity tool must be used at least weekly to check for unauthorized file changes, particularly the addition of unauthorized system libraries or binaries, or for unauthorized modification to authorized system libraries or binaries." do
  3377. # Check: To determine that periodic AIDE execution has been scheduled, run the following command:
  3378. # # grep aide /etc/crontab
  3379. # If there is no output or if aide is not run at least weekly, this is a finding.
  3380. if $environment['ids'] == 'ossec'
  3381. expect( service('ossec-hids')).to be_enabled
  3382. expect( service('ossec-hids')).to be_running
  3383. elsif $environment['ids'] == 'aide'
  3384. expect( command("grep aide /etc/crontab")).not_to return_stdout ""
  3385. else
  3386. fail("IDS variable set to unknown value")
  3387. end
  3388. # Fix: AIDE should be executed on a periodic basis to check for changes. To implement a daily execution of AIDE at 4:05am using cron, add the following line to /etc/crontab:
  3389. # 05 4 * * * root /usr/sbin/aide --check
  3390. # AIDE can be executed periodically through other means; this is merely one example.
  3391. end
  3392. # STIG Viewer Link: http://www.stigviewer.com/check/V-38696
  3393. it "V-38696 The operating system must employ automated mechanisms, per organization defined frequency, to detect the addition of unauthorized components/devices into the operating system." do
  3394. # Check: To determine that periodic AIDE execution has been scheduled, run the following command:
  3395. # # grep aide /etc/crontab
  3396. # If there is no output, this is a finding.
  3397. if $environment['ids'] == 'ossec'
  3398. expect( service('ossec-hids')).to be_enabled
  3399. expect( service('ossec-hids')).to be_running
  3400. elsif $environment['ids'] == 'aide'
  3401. expect( command("grep aide /etc/crontab")).not_to return_stdout ""
  3402. else
  3403. fail("IDS variable set to unknown value")
  3404. end
  3405. # Fix: AIDE should be executed on a periodic basis to check for changes. To implement a daily execution of AIDE at 4:05am using cron, add the following line to /etc/crontab:
  3406. # 05 4 * * * root /usr/sbin/aide --check
  3407. # AIDE can be executed periodically through other means; this is merely one example.
  3408. end
  3409. # STIG Viewer Link: http://www.stigviewer.com/check/V-38697
  3410. it "V-38697 The sticky bit must be set on all public directories." do
  3411. # Check: To find world-writable directories that lack the sticky bit, run the following command:
  3412. # # find / -xdev -type d -perm 002 ! -perm 1000
  3413. # If any world-writable directories are missing the sticky bit, this is a finding.
  3414. expect( command("find / -xdev -type d -perm 002 ! -perm 1000")).to return_stdout ""
  3415. # Fix: When the so-called 'sticky bit' is set on a directory, only the owner of a given file may remove that file from the directory. Without the sticky bit, any user with write access to a directory may remove any file in the directory. Setting the sticky bit prevents users from removing each other's files. In cases where there is no reason for a directory to be world-writable, a better solution is to remove that permission rather than to set the sticky bit. However, if a directory is used by a particular application, consult that application's documentation instead of blindly changing modes.
  3416. # To set the sticky bit on a world-writable directory [DIR], run the following command:
  3417. # # chmod +t [DIR]
  3418. end
  3419. # STIG Viewer Link: http://www.stigviewer.com/check/V-38698
  3420. it "V-38698 The operating system must employ automated mechanisms to detect the presence of unauthorized software on organizational information systems and notify designated organizational officials in accordance with the organization defined frequency." do
  3421. # Check: To determine that periodic AIDE execution has been scheduled, run the following command:
  3422. # # grep aide /etc/crontab
  3423. # If there is no output, this is a finding.
  3424. if $environment['ids'] == 'ossec'
  3425. expect( service('ossec-hids')).to be_enabled
  3426. expect( service('ossec-hids')).to be_running
  3427. elsif $environment['ids'] == 'aide'
  3428. expect( command("grep aide /etc/crontab")).not_to return_stdout ""
  3429. else
  3430. fail("IDS variable set to unknown value")
  3431. end
  3432. # Fix: AIDE should be executed on a periodic basis to check for changes. To implement a daily execution of AIDE at 4:05am using cron, add the following line to /etc/crontab:
  3433. # 05 4 * * * root /usr/sbin/aide --check
  3434. # AIDE can be executed periodically through other means; this is merely one example.
  3435. end
  3436. # STIG Viewer Link: http://www.stigviewer.com/check/V-38699
  3437. it "V-38699 All public directories must be owned by a system account." do
  3438. # Check: The following command will discover and print world-writable directories that are not owned by a system account, given the assumption that only system accounts have a uid lower than 500. Run it once for each local partition [PART]:
  3439. # # find [PART] -xdev -type d -perm 0002 -uid +500 -print
  3440. # If there is output, this is a finding.
  3441. expect( command("find / -xdev -type d -perm 0002 -uid +500 -print")).to return_stdout ""
  3442. # Fix: All directories in local partitions which are world-writable should be owned by root or another system account. If any world-writable directories are not owned by a system account, this should be investigated. Following this, the files should be deleted or assigned to an appropriate group.
  3443. end
  3444. # STIG Viewer Link: http://www.stigviewer.com/check/V-38700
  3445. it "V-38700 The operating system must provide a near real-time alert when any of the organization defined list of compromise or potential compromise indicators occurs." do
  3446. # Check: To determine that periodic AIDE execution has been scheduled, run the following command:
  3447. # # grep aide /etc/crontab
  3448. # If there is no output, this is a finding.
  3449. if $environment['ids'] == 'ossec'
  3450. expect( service('ossec-hids')).to be_enabled
  3451. expect( service('ossec-hids')).to be_running
  3452. elsif $environment['ids'] == 'aide'
  3453. expect( command("grep aide /etc/crontab")).not_to return_stdout ""
  3454. else
  3455. fail("IDS variable set to unknown value")
  3456. end
  3457. # Fix: AIDE should be executed on a periodic basis to check for changes. To implement a daily execution of AIDE at 4:05am using cron, add the following line to /etc/crontab:
  3458. # 05 4 * * * root /usr/sbin/aide --check
  3459. # AIDE can be executed periodically through other means; this is merely one example.
  3460. end
  3461. # STIG Viewer Link: http://www.stigviewer.com/check/V-38701
  3462. it "V-38701 The TFTP daemon must operate in secure mode which provides access only to a single directory on the host file system." do
  3463. # Check: Verify "tftp" is configured by with the "-s" option by running the following command:
  3464. # grep "server_args" /etc/xinetd.d/tftp
  3465. # The output should indicate the "server_args" variable is configured with the "-s" flag, matching the example below:
  3466. # # grep "server_args" /etc/xinetd.d/tftp
  3467. # server_args = -s /var/lib/tftpboot
  3468. # If it does not, this is a finding.
  3469. if property[:roles].include? 'tftpServer'
  3470. expect( command("find / -xdev -type d -perm 0002 -uid +500 -print")).to return_stdout ""
  3471. else
  3472. pending("Not applicable")
  3473. end
  3474. # Fix: If running the "tftp" service is necessary, it should be configured to change its root directory at startup. To do so, ensure "/etc/xinetd.d/tftp" includes "-s" as a command line argument, as shown in the following example (which is also the default):
  3475. # server_args = -s /var/lib/tftpboot
  3476. end
  3477. # STIG Viewer Link: http://www.stigviewer.com/check/V-38702
  3478. it "V-38702 The FTP daemon must be configured for logging or verbose mode." do
  3479. # Check: Find if logging is applied to the ftp daemon.
  3480. # Procedures:
  3481. # If vsftpd is started by xinetd the following command will indicate the xinetd.d startup file.
  3482. # # grep vsftpd /etc/xinetd.d/*
  3483. # # grep server_args [vsftpd xinetd.d startup file]
  3484. # This will indicate the vsftpd config file used when starting through xinetd. If the [server_args]line
  3485. # is missing or does not include the vsftpd configuration file, then the default config file (/etc/vsftpd/vsftpd.conf)
  3486. # is used.
  3487. # # grep xferlog_enable [vsftpd config file]
  3488. # If xferlog_enable is missing, or is not set to yes, this is a finding.
  3489. if property[:roles].include? 'ftpServer'
  3490. expect( command("grep xferlog_enable /etc/vsftpd/vsftpd.conf")).not_to return_stdout ""
  3491. else
  3492. pending("Not applicable")
  3493. end
  3494. # Fix: Add or correct the following configuration options within the "vsftpd" configuration file, located at "/etc/vsftpd/vsftpd.conf".
  3495. # xferlog_enable=YES
  3496. # xferlog_std_format=NO
  3497. # log_ftp_protocol=YES
  3498. end
  3499. end