-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10243 from marcusburghardt/cis_rhel_pass_past
Include rule for checking password last change in RHEL
- Loading branch information
Showing
7 changed files
with
58 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 39 additions & 31 deletions
70
...ts-restrictions/password_storage/accounts_password_last_change_is_in_past/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,59 @@ | ||
<def-group> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
{{{ oval_metadata("All password change date is in the past.") }}} | ||
<criteria> | ||
<criterion comment="passward last change was in the past" | ||
test_ref="test_accounts_password_last_change_time_secs"/> | ||
{{{ oval_metadata("All passwords last change date is in the past.") }}} | ||
<criteria operator="OR"> | ||
<criterion test_ref="test_accounts_password_last_change_is_in_past" | ||
comment="All passwords last change date is in the past"/> | ||
<criterion test_ref="test_accounts_password_last_change_is_in_past_no_pass" | ||
comment="There is no password defined in /etc/shadow"/> | ||
</criteria> | ||
</definition> | ||
|
||
<local_variable id="var_accounts_password_last_change_time_secs" datatype="int" version="1" | ||
comment="last change component of password entry"> | ||
<unix:shadow_state id="state_accounts_password_all_chage_past_has_no_password" version="1"> | ||
<unix:password operation="pattern match">^(!|!!|!\*|\*|!locked)$</unix:password> | ||
</unix:shadow_state> | ||
|
||
<unix:shadow_object id="object_accounts_password_all_chage_in_past" version="1"> | ||
<unix:username operation="pattern match">.*</unix:username> | ||
<filter action="exclude">state_accounts_password_all_chage_past_has_no_password</filter> | ||
</unix:shadow_object> | ||
|
||
<local_variable id="var_accounts_password_last_change_time_secs" version="1" | ||
datatype="int" comment="last change field of shadow entry in seconds"> | ||
<arithmetic arithmetic_operation="multiply"> | ||
<object_component object_ref="object_accounts_password_all_chage_in_past" | ||
item_field="chg_lst"/> | ||
item_field="chg_lst"/> | ||
<literal_component datatype="int">86400</literal_component> | ||
</arithmetic> | ||
</arithmetic> | ||
</local_variable> | ||
|
||
<local_variable id="var_accounts_password_last_change_time_diff" datatype="int" version="1" | ||
comment="last change component of password entry compared to current time"> | ||
comment="time difference between the last change field of shadow entry and the current time"> | ||
<time_difference format_2="seconds_since_epoch"> | ||
<variable_component var_ref="var_accounts_password_last_change_time_secs"/> | ||
<variable_component var_ref="var_accounts_password_last_change_time_secs"/> | ||
</time_difference> | ||
</local_variable> | ||
|
||
<ind:variable_object id="object_accounts_password_last_change_time_diff" version="1"> | ||
<ind:var_ref>var_accounts_password_last_change_time_diff</ind:var_ref> | ||
</ind:variable_object> | ||
|
||
<ind:variable_state id="state_accounts_password_last_change_time_diff" version="1"> | ||
<!-- With negative time I actually get very big number so instead | ||
of checking greater than zero I am checking if less than 1000 years --> | ||
<ind:value datatype="int" operation="less than or equal">86400000</ind:value> | ||
</ind:variable_state> | ||
|
||
<ind:variable_test check="all" check_existence="all_exist" | ||
id="test_accounts_password_last_change_time_secs" version="1" | ||
comment="Check if the password chage time is less than equal than today."> | ||
<ind:variable_test id="test_accounts_password_last_change_is_in_past" version="1" | ||
check="all" check_existence="all_exist" | ||
comment="Check if the password last chage time is less than or equal today."> | ||
<ind:object object_ref="object_accounts_password_last_change_time_diff"/> | ||
<ind:state state_ref="state_accounts_password_last_change_time_diff"/> | ||
</ind:variable_test> | ||
</ind:variable_test> | ||
|
||
<unix:shadow_object id="object_accounts_password_all_chage_in_past" version="1"> | ||
<unix:username operation="pattern match">.*</unix:username> | ||
<filter action="exclude">state_accounts_password_all_chage_past_has_no_password</filter> | ||
</unix:shadow_object> | ||
<unix:shadow_state id="state_accounts_password_all_chage_past_has_no_password" version="1"> | ||
<unix:password operation="pattern match">^(!|!!|!\*|\*|!locked)$</unix:password> | ||
</unix:shadow_state> | ||
<ind:variable_object id="object_accounts_password_last_change_time_diff" version="1"> | ||
<ind:var_ref>var_accounts_password_last_change_time_diff</ind:var_ref> | ||
</ind:variable_object> | ||
|
||
<ind:variable_state id="state_accounts_password_last_change_time_diff" version="1"> | ||
<!-- With negative time I actually get very big number so instead | ||
of checking greater than zero I am checking if less than 1000 years --> | ||
<ind:value datatype="int" operation="less than or equal">86400000</ind:value> | ||
</ind:variable_state> | ||
|
||
<unix:shadow_test id="test_accounts_password_last_change_is_in_past_no_pass" version="1" | ||
check="all" check_existence="none_exist" | ||
comment="Check the inexistence of users with a password defined"> | ||
<unix:object object_ref="object_accounts_password_all_chage_in_past"/> | ||
</unix:shadow_test> | ||
</def-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...ssword_storage/accounts_password_last_change_is_in_past/tests/no_password_defined.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
# remediation = none | ||
|
||
sed -E -i 's/(\w*:)(\$[^:]*)(:.*)/\1!!\3/' /etc/shadow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters