Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new rule no_nologin_in_shells #12835

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/pam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ rules:
- no_legacy_plus_entries_etc_passwd
- no_legacy_plus_entries_etc_shadow
- no_netrc_files
- no_nologin_in_shells
- no_password_auth_for_systemaccounts
- no_root_webbrowsing
- no_shelllogin_for_systemaccounts
Expand Down
5 changes: 3 additions & 2 deletions controls/cis_ubuntu2404.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2210,8 +2210,9 @@ controls:
levels:
- l2_server
- l2_workstation
status: planned
notes: TODO. Rule does not seem to be implemented, nor does it map to any rules in ubuntu2204 profile.
rules:
- no_nologin_in_shells
status: automated

- id: 5.4.3.2
title: Ensure default user shell timeout is configured (Automated)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low

if grep -q -E "^[^#]*/nologin\b.*$" /etc/shells; then
sed -i --follow-symlinks 's/^[^#]*\/nologin\b.*$/#&/g' /etc/shells
fi

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<def-group>
<definition class="compliance" id="{{{ rule_id }}}" version="1">
<metadata>
<title>Ensure nologin Shell is Not Listed in /etc/shells</title>
<affected family="unix">
<platform>multi_platform_all</platform>
</affected>
<description>The nologin shell should not be listed in /etc/shells.</description>
</metadata>
<criteria>
<criterion comment="nologin not in /etc/shells" test_ref="test_{{{ rule_id }}}" />
</criteria>
</definition>

<ind:textfilecontent54_test check="all" check_existence="none_exist"
comment="Check for nologin in /etc/shells"
id="test_{{{ rule_id }}}" version="1">
<ind:object object_ref="obj_{{{ rule_id }}}"/>
</ind:textfilecontent54_test>

<ind:textfilecontent54_object id="obj_{{{ rule_id }}}" version="1">
<ind:filepath>/etc/shells</ind:filepath>
<ind:pattern operation="pattern match">^[^#]*/nologin\b.*$</ind:pattern>
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
</ind:textfilecontent54_object>
</def-group>


Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
documentation_complete: true

title: 'Ensure nologin Shell is Not Listed in /etc/shells'

description: |-
The <tt>/sbin/nologin</tt> shell is used to restrict accounts from having login access
and should not be listed as a valid login shell in <tt>/etc/shells</tt>.
To verify that nologin is not listed in /etc/shells, run:
<pre>$ grep nologin /etc/shells</pre>
The command should return no output.

rationale: |-
The <tt>/etc/shells</tt> is consulted by various programs to evaluate
whether the user is somehow restricted. For example, the chsh utility will
consult the file to determine if the user is allowed to change their shell.

severity: medium

ocil_clause: 'nologin is listed in /etc/shells'

ocil: |-
To verify that nologin is not listed in /etc/shells, run:
<pre>$ grep nologin /etc/shells</pre>
The command should return no output.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

sed -i --follow-symlinks '/nologin/d' /etc/shells
echo "#/sbin/nologin" >> /etc/shells


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

sed -i --follow-symlinks '/nologin/d' /etc/shells
echo "/sbin/nologin" >> /etc/shells


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

sed -i --follow-symlinks '/nologin/d' /etc/shells


Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

sed -i --follow-symlinks '/nologin/d' /etc/shells
echo "/sbin/nologin" >> /etc/shells
echo "/usr/sbin/nologin" >> /etc/shells


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

sed -i --follow-symlinks '/nologin/d' /etc/shells
echo "/sbin/nologinormaybe" >> /etc/shells


Loading