Re: Cannot disable kernel's audit system via auditctl

Samuel Bahr <[email protected]> Mon, 24 Jul 2023 16:06:02 -0500
Newsgroups com.redhat.linux-audit
Message-ID <CAG0SdGBHnFLf=DDMwvyYyctfq3YcA3RUzuEibMdDbxTCuwFxZA@mail.gmail.com>
--===============6575469510284832286==
Content-Type: multipart/alternative; boundary="000000000000097b93060141fc39"

--000000000000097b93060141fc39
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Steve,

`auditctl -D` does not make it go away (outputs `No rules`). auditd isn't
running at all and this behavior is happening purely from the kernel. These
systems were never set to enabled 2 (locked).

I went ahead and filed a Github issue for this thread:
https://github.com/linux-audit/audit-kernel/issues/146

The maintainer there suggested it's too difficult to debug due to eBPF
programs + AWS's modified kernel. I've resigned to asking Red Canary to
support eBPF mode with `audit=3D0` kernel parameter in their Linux EDR. Let
me know if you have any other ideas.

Regards,
Samuel Bahr
Pinterest Sr. Site Reliability Engineer

On Sun, Jul 23, 2023 at 7:17=E2=80=AFPM Steve Grubb <[email protected]> wro=
te:

> On Thursday, June 29, 2023 6:34:03 PM EDT Samuel Bahr wrote:
> > Hi linux-audit,
> >
> > I'm running a fleet of Linux hosts with Red Canary Linux EDR (Endpoint
> > Detection and Response) which uses eBPF for gathering telemetry in
> service
> > ` cfsvcd.service`. In an older configuration, it gathered data from the
> > kernel's audit system and everything was fine. However, when we switche=
d
> > cfsvcd to gathering data from eBPF instead, we noticed that the kernel
> > ring buffer was flooded with audit messages. This is because
> > cfsvcd.service now stops auditd.service, but leaves the kernel audit
> > system enabled.
> >
> > I've mitigated this issue by manually running `# auditctl -e 0` on our
> > hosts (via Puppet). However, I'm running into a strange issue where
> _some_
> > hosts (~0.5%) are still logging all audit events to the kernel ring
> buffer
> > even after I have disabled the audit system via `# auditctl -e 0`. A `#
> > auditctl -s` run shows `enabled 0`, yet audit logs continue to flood th=
e
> > kernel ring buffer.
> >
> > I'm running Linux kernel 5.4.0-1063-aws on Ubuntu 18.04 with auditctl
> > v2.8.2. `systemd-journald-audit.socket` is masked & inactive, `
> > auditd.service` is disabled & inactive.
> >
> > I cannot entirely disable the audit system via a kernel parameter becau=
se
> > Red Canary Linux EDR fails to start cfsvcd.service as it fails to run
> some
> > auditctl command due to no audit support in the kernel:
> >
> > Jun 28 20:41:04 systemd[1]: Started Canary Forwarder Service.
> >
> > > Jun 28 20:41:04 cfsvcd[105781]: Found config file at path
> > > '"/opt/redcanary/config.json"', continuing execution...
> > > Jun 28 20:41:12 cfsvcd[105781]: component: Sentry
> > > Jun 28 20:41:12 cfsvcd[105781]:  Jun 28 20:41:12.055 INFO Initializin=
g
> > > Sentry Config { version: "1.4.17.release.[...]", https_proxy: None,
> > > extra_tags: [("telemetry.source", "eBPF")], logging_enabled: true,
> > > metrics_enabled: true, [...]}
> > > Jun 28 20:41:12 cfsvcd[105781]: Failed to setup or configure host
> system:
> > > Linux Audit watcher failure: Netlink Error: IO Error: Protocol not
> > > supported (os error 93)
> > > Jun 28 20:41:12 cfsvcd[105781]: Received stop. Exiting
> > > unix::wait_for_signal. Signal: 0, done.is_signaled(): true
> > > Jun 28 20:41:12 cfsvcd[105781]: Joining async_agent_thread
> > > Jun 28 20:41:13 cfsvcd[105781]: Attempting to stop subscriber (Ebpf).
> > > Jun 28 20:41:13 cfsvcd[105781]: Shutting down due to termination sign=
al
> > > [...]
> > > Jun 28 20:41:15 cfsvcd[105781]: Subscriber stopped.
> > > Jun 28 20:41:15 auditctl[106733]: Error - audit support not in kernel
> > > Jun 28 20:41:15 auditctl[106733]: Cannot open netlink audit socket
> > > Jun 28 20:41:15 systemd[1]: cfsvcd.service: Service hold-off time ove=
r,
> > > scheduling restart.
> > > Jun 28 20:41:15 systemd[1]: cfsvcd.service: Scheduled restart job,
> > > restart
> > > counter is at 301.
> > > Jun 28 20:41:15 systemd[1]: Stopped Canary Forwarder Service.
> >
> > Here's the unit file for cfsvcd.service:
> > > [Unit]
> > > Description=3DCanary Forwarder Service
> > >
> > > DefaultDependencies=3Dno
> > > After=3Dlocal-fs.target systemd-tmpfiles-setup.service auditd.service
> > > Before=3Dsysinit.target shutdown.target
> > > # Replace the auditd service if it is running
> > > Conflicts=3Dauditd.service shutdown.target
> > >
> > > [Service]
> > > WorkingDirectory=3D/opt/redcanary
> > > ExecStart=3D/opt/redcanary/cfsvcd
> > > ExecStopPost=3D-/sbin/auditctl -D
> > > Restart=3Dalways
> > > TimeoutSec=3D15
> > >
> > > [Install]
> > > WantedBy=3Dmulti-user.target
> >
> > Is this a known issue?
>
> Not really. But this is a new capability. If you run auditctl -D, does it
> go
> away? Have any of the systems been setup with auditctl -e 2? This makes
> the
> configuration immutable.
>
> -Steve
>
> > Is there a workaround to stop the logging to the
> > kernel ring buffer? Is there any more information I can provide to help
> > debug?
>
>
>
>

--000000000000097b93060141fc39
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi Steve,=C2=A0<div><br></div><div>`auditctl -D` does not =
make it go away (outputs `No rules`). auditd isn&#39;t running at all and t=
his behavior is happening purely from the kernel. These systems were never =
set to enabled 2 (locked).</div><div><br></div><div>I went ahead and filed =
a Github issue for this thread:=C2=A0<a href=3D"https://github.com/linux-au=
dit/audit-kernel/issues/146">https://github.com/linux-audit/audit-kernel/is=
sues/146</a></div><div><br></div><div>The maintainer there suggested it&#39=
;s too difficult to debug due to eBPF programs=C2=A0+ AWS&#39;s modified ke=
rnel. I&#39;ve resigned to asking Red Canary to support eBPF mode with `aud=
it=3D0` kernel parameter in their Linux EDR. Let me know if you have any ot=
her ideas.</div><div><br></div><div>Regards,</div><div>Samuel Bahr</div><di=
v>Pinterest Sr. Site Reliability Engineer</div></div><br><div class=3D"gmai=
l_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sun, Jul 23, 2023 at 7:17=
=E2=80=AFPM Steve Grubb &lt;<a href=3D"mailto:[email protected]">sgrubb@red=
hat.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef=
t:1ex">On Thursday, June 29, 2023 6:34:03 PM EDT Samuel Bahr wrote:<br>
&gt; Hi linux-audit,<br>
&gt; <br>
&gt; I&#39;m running a fleet of Linux hosts with Red Canary Linux EDR (Endp=
oint<br>
&gt; Detection and Response) which uses eBPF for gathering telemetry in ser=
vice<br>
&gt; ` cfsvcd.service`. In an older configuration, it gathered data from th=
e<br>
&gt; kernel&#39;s audit system and everything was fine. However, when we sw=
itched<br>
&gt; cfsvcd to gathering data from eBPF instead, we noticed that the kernel=
<br>
&gt; ring buffer was flooded with audit messages. This is because<br>
&gt; cfsvcd.service now stops auditd.service, but leaves the kernel audit<b=
r>
&gt; system enabled.<br>
&gt; <br>
&gt; I&#39;ve mitigated this issue by manually running `# auditctl -e 0` on=
 our<br>
&gt; hosts (via Puppet). However, I&#39;m running into a strange issue wher=
e _some_<br>
&gt; hosts (~0.5%) are still logging all audit events to the kernel ring bu=
ffer<br>
&gt; even after I have disabled the audit system via `# auditctl -e 0`. A `=
#<br>
&gt; auditctl -s` run shows `enabled 0`, yet audit logs continue to flood t=
he<br>
&gt; kernel ring buffer.<br>
&gt; <br>
&gt; I&#39;m running Linux kernel 5.4.0-1063-aws on Ubuntu 18.04 with audit=
ctl<br>
&gt; v2.8.2. `systemd-journald-audit.socket` is masked &amp; inactive, `<br=
>
&gt; auditd.service` is disabled &amp; inactive.<br>
&gt; <br>
&gt; I cannot entirely disable the audit system via a kernel parameter beca=
use<br>
&gt; Red Canary Linux EDR fails to start cfsvcd.service as it fails to run =
some<br>
&gt; auditctl command due to no audit support in the kernel:<br>
&gt; <br>
&gt; Jun 28 20:41:04 systemd[1]: Started Canary Forwarder Service.<br>
&gt; <br>
&gt; &gt; Jun 28 20:41:04 cfsvcd[105781]: Found config file at path<br>
&gt; &gt; &#39;&quot;/opt/redcanary/config.json&quot;&#39;, continuing exec=
ution...<br>
&gt; &gt; Jun 28 20:41:12 cfsvcd[105781]: component: Sentry<br>
&gt; &gt; Jun 28 20:41:12 cfsvcd[105781]:=C2=A0 Jun 28 20:41:12.055 INFO In=
itializing<br>
&gt; &gt; Sentry Config { version: &quot;1.4.17.release.[...]&quot;, https_=
proxy: None,<br>
&gt; &gt; extra_tags: [(&quot;telemetry.source&quot;, &quot;eBPF&quot;)], l=
ogging_enabled: true,<br>
&gt; &gt; metrics_enabled: true, [...]}<br>
&gt; &gt; Jun 28 20:41:12 cfsvcd[105781]: Failed to setup or configure host=
 system:<br>
&gt; &gt; Linux Audit watcher failure: Netlink Error: IO Error: Protocol no=
t<br>
&gt; &gt; supported (os error 93)<br>
&gt; &gt; Jun 28 20:41:12 cfsvcd[105781]: Received stop. Exiting<br>
&gt; &gt; unix::wait_for_signal. Signal: 0, done.is_signaled(): true<br>
&gt; &gt; Jun 28 20:41:12 cfsvcd[105781]: Joining async_agent_thread<br>
&gt; &gt; Jun 28 20:41:13 cfsvcd[105781]: Attempting to stop subscriber (Eb=
pf).<br>
&gt; &gt; Jun 28 20:41:13 cfsvcd[105781]: Shutting down due to termination =
signal<br>
&gt; &gt; [...]<br>
&gt; &gt; Jun 28 20:41:15 cfsvcd[105781]: Subscriber stopped.<br>
&gt; &gt; Jun 28 20:41:15 auditctl[106733]: Error - audit support not in ke=
rnel<br>
&gt; &gt; Jun 28 20:41:15 auditctl[106733]: Cannot open netlink audit socke=
t<br>
&gt; &gt; Jun 28 20:41:15 systemd[1]: cfsvcd.service: Service hold-off time=
 over,<br>
&gt; &gt; scheduling restart.<br>
&gt; &gt; Jun 28 20:41:15 systemd[1]: cfsvcd.service: Scheduled restart job=
,<br>
&gt; &gt; restart<br>
&gt; &gt; counter is at 301.<br>
&gt; &gt; Jun 28 20:41:15 systemd[1]: Stopped Canary Forwarder Service.<br>
&gt; <br>
&gt; Here&#39;s the unit file for cfsvcd.service:<br>
&gt; &gt; [Unit]<br>
&gt; &gt; Description=3DCanary Forwarder Service<br>
&gt; &gt; <br>
&gt; &gt; DefaultDependencies=3Dno<br>
&gt; &gt; After=3Dlocal-fs.target systemd-tmpfiles-setup.service auditd.ser=
vice<br>
&gt; &gt; Before=3Dsysinit.target shutdown.target<br>
&gt; &gt; # Replace the auditd service if it is running<br>
&gt; &gt; Conflicts=3Dauditd.service shutdown.target<br>
&gt; &gt; <br>
&gt; &gt; [Service]<br>
&gt; &gt; WorkingDirectory=3D/opt/redcanary<br>
&gt; &gt; ExecStart=3D/opt/redcanary/cfsvcd<br>
&gt; &gt; ExecStopPost=3D-/sbin/auditctl -D<br>
&gt; &gt; Restart=3Dalways<br>
&gt; &gt; TimeoutSec=3D15<br>
&gt; &gt; <br>
&gt; &gt; [Install]<br>
&gt; &gt; WantedBy=3Dmulti-user.target<br>
&gt; <br>
&gt; Is this a known issue?<br>
<br>
Not really. But this is a new capability. If you run auditctl -D, does it g=
o <br>
away? Have any of the systems been setup with auditctl -e 2? This makes the=
 <br>
configuration immutable.<br>
<br>
-Steve<br>
<br>
&gt; Is there a workaround to stop the logging to the<br>
&gt; kernel ring buffer? Is there any more information I can provide to hel=
p<br>
&gt; debug?<br>
<br>
<br>
<br>
</blockquote></div>

--000000000000097b93060141fc39--

--===============6575469510284832286==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
Linux-audit mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/linux-audit

--===============6575469510284832286==--