From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8F70C2D0F8 for ; Wed, 13 May 2020 00:36:56 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D3B420753 for ; Wed, 13 May 2020 00:36:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ffkrMyge" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D3B420753 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-audit-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589330215; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mDMfSIe1+suqzeADGWBsZDbc53WPpA1ohKLmzBgDhrY=; b=ffkrMygeVwp1orw3qhjXJBK2YorIDQhP6UNlp7Jcl1BYJHOebX1V4YtFoxRr6kXg9ta9zw Xb3He3iq+wDSmFIQlynaB3hUoR3fefX5o9j8Rr54QpSgWLD3ZNBW2R+Vs/4ZMDU1oh+FLm 7zQyAPwOf/QbzLyFfGiHl1w+8TxGNRY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-61LvviT-PIy-8kzPWLOumA-1; Tue, 12 May 2020 20:36:52 -0400 X-MC-Unique: 61LvviT-PIy-8kzPWLOumA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B46151009600; Wed, 13 May 2020 00:36:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9924539E; Wed, 13 May 2020 00:36:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 617E21809543; Wed, 13 May 2020 00:36:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04D0aleB002566 for ; Tue, 12 May 2020 20:36:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF58F52FB4; Wed, 13 May 2020 00:36:47 +0000 (UTC) Received: from x2.localnet (ovpn-112-105.phx2.redhat.com [10.3.112.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8A926E6EB; Wed, 13 May 2020 00:36:44 +0000 (UTC) From: Steve Grubb To: Joe Nall Subject: Re: reactive audit proposal Date: Tue, 12 May 2020 20:36:43 -0400 Message-ID: <1718624.Kgxutyrx4h@x2> Organization: Red Hat In-Reply-To: References: <6360160.ZmnOHIC0Qm@x2> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: linux-audit@redhat.com Cc: linux-audit@redhat.com X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Tuesday, May 12, 2020 8:31:45 PM EDT Joe Nall wrote: > > On May 12, 2020, at 7:22 PM, Steve Grubb wrote: > > > > Hello, > > > > I wanted to run this by the crowd to see what people's reaction might be. > > > > The audit system sometimes needs to have rules applied when something > > happens. For example, if someone plugs in a USB flash drive, the system > > creates the device in /dev and then automatically mounts it under some > > circumstances. > > > > I would propose 2 new additions to the audit rule syntax: on-mount and > > on-login.These rules would be in a separate file from the main audit > > rules. When a file system is mounted, /proc/mounts changes and the mount > > table can be scanned to see if something new is there. In this way we > > can reliably detect newly mounted filesystems. We can then match against > > a specifier to see if this is a file system in which we want to apply > > new rules. If so, we send the new rules to the kernel. When the device > > is unmounted, the kernel drops all watches on that file system. So, we > > only need to worry about when a device is mounted. > > > > This works good for anything that gets mounted. But it is also possible > > for a USB flash drive to be accessed as a block device, such as the dd > > utility. If we had to detect device discovery, there is a netlink group, > > NETLINK_KOBJECT_UEVENT which we could monitor for events. The only thing > > is that we could only detect open/read/write/close/ioctl/lseek. And we > > probably do not want to monitor anything except block devices. > > > > It may also be possible to poll /sys/block to watch for changes. This > > might be easier as the names are more friendly. This would take some > > research to see if its even possible. > > > > The rule syntax could look something like: > > on=mount mount=/run/user/1000 : -a exit,always ... > > on=device device=/dev/sdd : -a exit,always ... > > > > The on-login event would simply watch the audit trail for any AUDIT_LOGIN > > events. That event can be parsed to get the new auid. If the auid matches > > any rules, then it will load them into the kernel. To remove the rules, > > we > > could watch for the AUDIT_USER_END event. The only issue is that we would > > need to track how many sessions the user has open and remove the rules > > only when the last session closes out. > > > > The rules for this might look something like this: > > on=login auid=1000 : -a exit,always ... > > > > The question is whether or not this should be done as part of the audit > > daemon or as a plugin for the audit daemon. One advantage of doing this > > as > > a plugin is that it will keep the audit daemon focused on getting events > > and distributing them. Any programming mistake in the plugin will crash > > it > > and not the daemon. The tradeoff is that it will get the event slightly > > after auditd sees it. This only matters for the on-login functionality. > > The device and mount events come from an entirely different source. And > > I'm sure that in every case, the program will react faster than a user > > possibily can winning the race evry time. > > > > Thoughts? > > Would bind mounts trigger these rules? I'm sitting next to a box with 10k > polyinstantiated bind mounts right now. If you do cat /proc/mounts do you see 10k entries? And do you want them or do you think they are harmful? -Steve -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit