Blame SOURCES/scap-security-guide-0.1.41-audit_passwd_log_writes.patch

7629ac
diff --git a/shared/checks/oval/audit_rules_etc_passwd_open.xml b/shared/checks/oval/audit_rules_etc_passwd_open.xml
7629ac
new file mode 100644
7629ac
index 0000000000..fd5c3efb28
7629ac
--- /dev/null
7629ac
+++ b/shared/checks/oval/audit_rules_etc_passwd_open.xml
7629ac
@@ -0,0 +1,96 @@
7629ac
+<def-group>
7629ac
+  <definition class="compliance" id="audit_rules_etc_passwd_open" version="1">
7629ac
+    <metadata>
7629ac
+      <title>Ensure auditd Collects Write Events to /etc/passwd</title>
7629ac
+      <affected family="unix">
7629ac
+        <platform>Red Hat Enterprise Linux 7</platform>
7629ac
+        <platform>multi_platform_fedora</platform>
7629ac
+      </affected>
7629ac
+      <description>Audit rules about the write events to /etc/passwd</description>
7629ac
+    </metadata>
7629ac
+
7629ac
+    <criteria operator="OR">
7629ac
+
7629ac
+      
7629ac
+      <criteria operator="AND">
7629ac
+        <extend_definition comment="audit augenrules" definition_ref="audit_rules_augenrules" />
7629ac
+        <criterion comment="audit rule to record write events to /etc/passwd" test_ref="test_audit_rules_etc_passwd_open_32bit_augenrules" />
7629ac
+
7629ac
+        <criteria operator="OR">
7629ac
+          
7629ac
+          <extend_definition comment="64-bit system" definition_ref="system_info_architecture_64bit" negate="true" />
7629ac
+          
7629ac
+          <criterion comment="audit rule to record write events to /etc/passwd" test_ref="test_audit_rules_etc_passwd_open_64bit_augenrules" />
7629ac
+        </criteria>
7629ac
+      </criteria>
7629ac
+
7629ac
+      
7629ac
+      <criteria operator="AND">
7629ac
+        <extend_definition comment="audit auditctl" definition_ref="audit_rules_auditctl" />
7629ac
+        <criterion comment="audit rule to record write events to /etc/passwd" test_ref="test_audit_rules_etc_passwd_open_32bit_auditctl" />
7629ac
+
7629ac
+        <criteria operator="OR">
7629ac
+          
7629ac
+          <extend_definition comment="64-bit_system" definition_ref="system_info_architecture_64bit" negate="true" />
7629ac
+          
7629ac
+          <criterion comment="audit rule to record write events to /etc/passwd" test_ref="test_audit_rules_etc_passwd_open_64bit_auditctl" />
7629ac
+        </criteria>
7629ac
+      </criteria>
7629ac
+
7629ac
+    </criteria>
7629ac
+  </definition>
7629ac
+
7629ac
+  
7629ac
+  <constant_variable id="var_audit_rule_32bit_open_write_etc_passwd_regex" version="1" datatype="string" comment="audit rule arch and syscal">
7629ac
+      <value>^[\s]*-a[\s]+always,exit[\s]+(?:-F[\s]+arch=b32[\s]+)(?:-S(?:[\s]+open[\s]+|(?:[\s]+|[,])open(?:[\s]+|[,])))[\S]*[\s]*(?:-F[\s]+a2&03)[\s]+(?:-F[\s]+path=/etc/passwd)[\s]+(?:-F\s+auid>={{{ auid }}}[\s]+)(?:-F\s+auid!=(unset|4294967295)[\s]+)(?:-k[\s]+|-F[\s]+key=)[\S]+[\s]*$</value>
7629ac
+  </constant_variable>
7629ac
+
7629ac
+  <constant_variable id="var_audit_rule_64bit_open_write_etc_passwd_regex" version="1" datatype="string" comment="audit rule arch and syscal">
7629ac
+      <value>^[\s]*-a[\s]+always,exit[\s]+(?:-F[\s]+arch=b64[\s]+)(?:-S(?:[\s]+open[\s]+|(?:[\s]+|[,])open(?:[\s]+|[,])))[\S]*[\s]*(?:-F[\s]+a2&03)[\s]+(?:-F[\s]+path=/etc/passwd)[\s]+(?:-F\s+auid>={{{ auid }}}[\s]+)(?:-F\s+auid!=(unset|4294967295)[\s]+)(?:-k[\s]+|-F[\s]+key=)[\S]+[\s]*$</value>
7629ac
+  </constant_variable>
7629ac
+
7629ac
+  
7629ac
+  
7629ac
+ comment="defined audit rule must exist" id="test_audit_rules_etc_passwd_open_32bit_augenrules" version="1">
7629ac
+    <ind:object object_ref="object_audit_rules_etc_passwd_open_32bit_augenrules" />
7629ac
+  </ind:textfilecontent54_test>
7629ac
+  <ind:textfilecontent54_object id="object_audit_rules_etc_passwd_open_32bit_augenrules" version="1">
7629ac
+    <ind:filepath operation="pattern match">/etc/audit/rules\.d/.*\.rules</ind:filepath>
7629ac
+    <ind:pattern operation="pattern match" var_ref="var_audit_rule_32bit_open_write_etc_passwd_regex" />
7629ac
+    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
7629ac
+  </ind:textfilecontent54_object>
7629ac
+
7629ac
+  
7629ac
+ comment="defined audit rule must exist" id="test_audit_rules_etc_passwd_open_64bit_augenrules" version="1">
7629ac
+    <ind:object object_ref="object_audit_rules_etc_passwd_open_64bit_augenrules" />
7629ac
+  </ind:textfilecontent54_test>
7629ac
+  <ind:textfilecontent54_object id="object_audit_rules_etc_passwd_open_64bit_augenrules" version="1">
7629ac
+    <ind:filepath operation="pattern match">/etc/audit/rules\.d/.*\.rules</ind:filepath>
7629ac
+    <ind:pattern operation="pattern match" var_ref="var_audit_rule_64bit_open_write_etc_passwd_regex" />
7629ac
+    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
7629ac
+  </ind:textfilecontent54_object>
7629ac
+
7629ac
+
7629ac
+
7629ac
+  
7629ac
+  
7629ac
+ comment="defined audit rule must exist" id="test_audit_rules_etc_passwd_open_32bit_auditctl" version="1">
7629ac
+    <ind:object object_ref="object_audit_rules_etc_passwd_open_32bit_auditctl" />
7629ac
+  </ind:textfilecontent54_test>
7629ac
+  <ind:textfilecontent54_object id="object_audit_rules_etc_passwd_open_32bit_auditctl" version="1">
7629ac
+    <ind:filepath>/etc/audit/audit.rules</ind:filepath>
7629ac
+    <ind:pattern operation="pattern match" var_ref="var_audit_rule_32bit_open_write_etc_passwd_regex" />
7629ac
+    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
7629ac
+  </ind:textfilecontent54_object>
7629ac
+
7629ac
+  
7629ac
+ comment="defined audit rule must exist" id="test_audit_rules_etc_passwd_open_64bit_auditctl" version="1">
7629ac
+    <ind:object object_ref="object_audit_rules_etc_passwd_open_64bit_auditctl" />
7629ac
+  </ind:textfilecontent54_test>
7629ac
+  <ind:textfilecontent54_object id="object_audit_rules_etc_passwd_open_64bit_auditctl" version="1">
7629ac
+    <ind:filepath>/etc/audit/audit.rules</ind:filepath>
7629ac
+    <ind:pattern operation="pattern match" var_ref="var_audit_rule_64bit_open_write_etc_passwd_regex" />
7629ac
+    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
7629ac
+  </ind:textfilecontent54_object>
7629ac
+
7629ac
+</def-group>
7629ac
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_etc_passwd_open.rule b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_etc_passwd_open.rule
7629ac
new file mode 100644
7629ac
index 0000000000..6e4aabcbe8
7629ac
--- /dev/null
7629ac
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_etc_passwd_open.rule
7629ac
@@ -0,0 +1,36 @@
7629ac
+documentation_complete: true
7629ac
+
7629ac
+prodtype: rhel7,fedora
7629ac
+
7629ac
+title: 'Record Events that Modify User/Group Information via open syscall - /etc/passwd'
7629ac
+
7629ac
+description: |-
7629ac
+    The audit system should collect write events to /etc/passwd file for all users and root.
7629ac
+    If the <tt>auditd</tt> daemon is configured
7629ac
+    to use the <tt>augenrules</tt> program to read audit rules during daemon
7629ac
+    startup (the default), add the following lines to a file with suffix
7629ac
+    <tt>.rules</tt> in the directory <tt>/etc/audit/rules.d</tt>:
7629ac
+    
-a always,exit -F arch=b32 -S open -F a2&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
7629ac
+    If the <tt>auditd</tt> daemon is configured to use the <tt>auditctl</tt>
7629ac
+    utility to read audit rules during daemon startup, add the following lines to
7629ac
+    <tt>/etc/audit/audit.rules</tt> file:
7629ac
+    
-a always,exit -F arch=b64 -S open -F a2&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
7629ac
+
7629ac
+rationale: |-
7629ac
+    Creation of users through direct edition of /etc/passwd could be an indicator of malicious activity on a system.
7629ac
+    Auditing these events could serve as evidence of potential system compromise.
7629ac
+
7629ac
+severity: medium
7629ac
+
7629ac
+references:
7629ac
+    ospp@rhel7: FAU_GEN.1.1.c
7629ac
+
7629ac
+{{{ complete_ocil_entry_audit_syscall(syscall="open") }}}
7629ac
+
7629ac
+warnings:
7629ac
+    - general: |-
7629ac
+        Note that these rules can be configured in a
7629ac
+        number of ways while still achieving the desired effect. Here the system calls
7629ac
+        have been placed independent of other system calls. Grouping system calls related
7629ac
+        to the same event is more efficient. See the following example:
7629ac
+        
-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F a2&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
7629ac
diff --git a/rhel7/profiles/ospp42-draft.profile b/rhel7/profiles/ospp42-draft.profile
7629ac
index 63b7223731..86fb0ff2fb 100644
7629ac
--- a/rhel7/profiles/ospp42-draft.profile
7629ac
+++ b/rhel7/profiles/ospp42-draft.profile
7629ac
@@ -161,3 +161,4 @@ selections:
7629ac
     - audit_rules_kernel_module_loading_modprobe
7629ac
     - audit_rules_kernel_module_loading_rmmod
7629ac
     - security_patches_up_to_date
7629ac
+    - audit_rules_etc_passwd_open