<html dir="ltr" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>.EmailQuote {
        BORDER-LEFT: #800000 2px solid; PADDING-LEFT: 4pt; MARGIN-LEFT: 1pt
}
</style><style id="owaParaStyle">P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</style>
</head>
<body ocsi="0" fPStyle="1">
<div style="FONT-FAMILY: Tahoma; DIRECTION: ltr; COLOR: #000000; FONT-SIZE: 10pt">
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><font face="Consolas">I applied this patch, built an RPM, and ran a scan on a test RHEL6 system.<span style="mso-spacerun: yes">&nbsp;
</span>It failed initially because I didn't have all of the SUID/SGID rules in place (the command I was using to generate the rules wasn't checking /lib and /lib64, and was looking for 6000 instead of 2000, so it missed some).<o:p></o:p></font></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><o:p><font face="Consolas">&nbsp;</font></o:p></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><font face="Consolas">I'm using the same audit configuration on RHEL7 as we're developing it, so once the check is available for RHEL7, I'll be happy to test that too.<o:p></o:p></font></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><o:p><font face="Consolas">&nbsp;</font></o:p></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><font face="Consolas">One note: the XCCDF specifies the following command:<o:p></o:p></font></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><o:p><font face="Consolas">&nbsp;</font></o:p></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><font face="Consolas">find / -xdev -type f -perm -4000 -o -perm -2000 2&gt;/dev/null<o:p></o:p></font></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><o:p><font face="Consolas">&nbsp;</font></o:p></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><font face="Consolas">This is not quite right, as it will find SGID directories too.<span style="mso-spacerun: yes">&nbsp;
</span>It should be one of:<o:p></o:p></font></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><o:p><font face="Consolas">&nbsp;</font></o:p></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><font face="Consolas">find / -xdev -type f -perm -4000 -o -type f -perm -2000 2&gt;/dev/null<o:p></o:p></font></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><font face="Consolas">find / -xdev -type f -a \( -perm -4000 -o -perm -2000 \) 2&gt;/dev/null<o:p></o:p></font></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><o:p><font face="Consolas">&nbsp;</font></o:p></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText"><font face="Consolas">whichever appeals more.<span style="mso-spacerun: yes">&nbsp;
</span>The OVAL is fine, though, and does not appear to find SGID directories; once I updated my script to use the second command when generating rules, a second scan caused this check to pass.<o:p></o:p></font></p>
<p style="MARGIN: 0in 0in 0pt" class="MsoPlainText">&nbsp;</p>
<div>
<div style="FONT-FAMILY: Tahoma; FONT-SIZE: 13px">
<div style="FONT-FAMILY: Tahoma; FONT-SIZE: 13px">--<br>
Ray Shaw (Contractor, STG)<br>
Army Research Laboratory<br>
CISD, Unix Support </div>
</div>
</div>
<div>
<hr tabindex="-1">
<div id="x_divRplyFwdMsg"><font color="#000000" size="2" face="Tahoma"><b>From:</b> scap-security-guide-bounces@lists.fedorahosted.org [scap-security-guide-bounces@lists.fedorahosted.org] on behalf of Jan Lieskovsky [jlieskov@redhat.com]<br>
<b>Sent:</b> Thursday, July 03, 2014 6:24 AM<br>
<b>To:</b> scap-security-guide@lists.fedorahosted.org<br>
<b>Subject:</b> [PATCH 2/2] [RHEL/6] (Re-)Implement audit_rules_privileged_commands OVAL check &amp; start using it<br>
</font><br>
</div>
<div></div>
</div>
<font size="2"><span style="FONT-SIZE: 10pt">
<div class="PlainText"><br>
Re-implement (the currently incorrect &amp; unreferenced / unused) <br>
audit_rules_privileged_commands<br>
RHEL-6 check.<br>
<br>
The idea behind the check is roughly as follows -- the check works on <br>
comparing of two sets:<br>
* set A originally contains list of all privileged (setuid or setgid bit <br>
set) files found on the system<br>
&nbsp;&nbsp; (intentionally speaking about files, not executables above. Since <br>
former setuid / setgid can<br>
&nbsp;&nbsp; have the executable bit temporarily removed due some reason, we check <br>
- it's enough the file<br>
&nbsp;&nbsp; to have one of setuid / setgid set [IOW not checking if the file is <br>
executable])<br>
<br>
* for each item from set A we prefix it with: --a always, exit ... -F <br>
path= prefix, and suffix it<br>
&nbsp;&nbsp; with -F ... -k privileged suffix. In other words for each setuid / <br>
setgid file found on the system<br>
&nbsp;&nbsp; we generate the full / expanded form of audit rule, we expect to be <br>
found.<br>
<br>
* second set B contains list of instances, following / matching the <br>
expected audit rule pattern,<br>
&nbsp;&nbsp; we have retrieved by looking into /etc/audit/audit.rules file<br>
<br>
* for each instance found (item from set B) we compare it for match with <br>
each item<br>
&nbsp;&nbsp; (pregenerated full audit rule form) from set A<br>
<br>
* besides the above, we need to ensure the dimensions / cardinality of <br>
both sets matches<br>
&nbsp;&nbsp; (e.g. what could happen being /etc/audit/audit.rules would contain <br>
all expected audit rules<br>
&nbsp;&nbsp; for setuid files, but none rule for setgid files. Checking just that <br>
each audit.rules rule is<br>
&nbsp;&nbsp; present in pregenerated list would succeed in this case too, even <br>
when it should fail.<br>
&nbsp;&nbsp; Therefore we add second, variable_test which compares if the <br>
cardinality of set A matches<br>
&nbsp;&nbsp; the cardinality of set B. If so, the test succeeds [the count of <br>
found audit.rules matches<br>
&nbsp;&nbsp; and has expected form than count of various setuid / setgid files, <br>
present on the system],<br>
&nbsp;&nbsp; otherwise failure is returned).<br>
<br>
<br>
Regardless of the OVAL check being such complex already currently, there <br>
are three limitations<br>
I am aware of wrt to it:<br>
* it will return success only in case the audit.rules have exactly the <br>
form (meaning order of<br>
&nbsp;&nbsp; various arguments) as expected / defined in the comment. Will have a <br>
look at possible<br>
&nbsp;&nbsp; permutations of -F ... arguments in the future yet (so it would pass <br>
also in case the rules<br>
&nbsp;&nbsp; are present there, but have one of the permutated forms),<br>
<br>
* it doesn't check if there isn't &quot;Delete all rules&quot; statement present <br>
somewhere in between /<br>
&nbsp;&nbsp; behind the audit rules definition (resulting not all of the rules to <br>
be actually taking into account<br>
&nbsp;&nbsp; by auditd). This is again space for future enhancement (will have a <br>
look),<br>
<br>
* for now the check has been tested &amp; implemented just for RHEL-6. It's <br>
enhancement to<br>
&nbsp;&nbsp; cover RHEL-7 too will require more time &amp; more testing. Again to come <br>
in subsequent version.<br>
<br>
<br>
Testing status:<br>
-------------------<br>
The proposed check has been tested on RHEL-6 considering the following <br>
sub-cases that<br>
can happen &amp; returns expected / appropriate result in each of them:<br>
<br>
1) blank audit.rules file on the <br>
system&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; returns <br>
FAIL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; V<br>
2) audit.rules present, but no suid, no sgid rules <br>
defined&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; returns FAIL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; V<br>
3) audit.rules present, just suid audit rules <br>
defined&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; returns FAIL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; V<br>
4) audit.rules present, just sgid audit rules <br>
defined&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; returns FAIL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; V<br>
5) audit.rules present, both suid, sgid rules <br>
defined&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; returns PASS&nbsp;&nbsp;&nbsp; v<br>
6) audit.rules present, both suid / sgid, heading / trailing <br>
whitespace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; returns PASS&nbsp;&nbsp;&nbsp; v<br>
<br>
auditd doesn't allow comments in its config file (fails to restart if <br>
inline comment present) =&gt; this<br>
case isn't necessary to consider / cover.<br>
<br>
<br>
Please review.<br>
<br>
Thank you &amp;&amp; Regards, Jan.<br>
---<br>
Jan iankko Lieskovsky / Red Hat Security Technologies Team<br>
<br>
P.S.: Should you need to share testing scripts / scenario let me know.<br>
<br>
</div>
</span></font></div>
</body>
</html>