Bug 91732 - [patch] 800.loginfail: fix log message grep expression
Summary: [patch] 800.loginfail: fix log message grep expression
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 6.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Christian Brueffer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-13 00:50 UTC by Daniel O'Connor
Modified: 2014-03-23 13:12 UTC (History)
0 users

See Also:


Attachments
file.diff (607 bytes, patch)
2006-01-13 00:50 UTC, Daniel O'Connor
no flags Details | Diff
patch_for_800.loginfail (420 bytes, text/plain)
2010-03-19 19:58 UTC, Alan Amesbury
no flags Details
smime.p7s (6.16 KB, application/pkcs7-signature)
2011-05-26 09:30 UTC, Christian Marg
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel O'Connor 2006-01-13 00:50:10 UTC
/etc/periodic/security/800.loginfail uses a simplistic grep expression to
find relevant log messages.  Unfortunately it misses some things that it
shouldn't and shows others that are superfluous.

eg. sasl-auth login failures don't show up, but sshd warnings about non-
matching forward/reverse lookups are.
Comment 1 spoier 2006-08-12 01:58:21 UTC
I noticed the same problem; although I was primarily worried about not
seeing ssh login failures in the security report.  I discovered it was
because "fail" no longer appears in the auth.log line on my FreeBSD
6.1 installation:

Aug 11 08:39:20 hostname sshd[48839]: error: PAM: authentication error
for someuser from somewhere.pacbell.net

I simply modified the grep in 800.loginfail to read:

        n=$(catmsgs | grep -ia "^$yesterday.*\(fail\|authentication error\)" |
            tee /dev/stderr | wc -l)
Comment 2 Alan Amesbury 2010-03-19 19:58:02 UTC
Although it's been a few years since Daniel O'Connor submitted his bug 
report, it looks like this problem hasn't yet been fixed.  I've also run 
into problems with the simplistic expression used by 'egrep' in 
800.loginfail, and have come up with my own correction (patch attached) 
to correct for it based on a minimal approach to change.  In my case the 
simplistic nature of the regexp is causing it to match hashes that are 
also being placed in the logs that 800.loginfail examines.  Thus it 
matches on things like

Mar 17 00:07:29 [REDACTED] [REDACTED][25063]:        sha256: 
9e0e0cb645a4cfabadc402fd7e6a38b297b04ac90fa3d4acdc14f027facbb5e7


because that hash happens to have the sequence "bad" in it.

PR conf/120263 seems related to this.  What can I do to help get this 
patched in -CURRENT and MFC'ed back to 8.0-RELEASE?


-- 
Alan Amesbury
OIT Security and Assurance
University of Minnesota
Comment 3 Christian Marg 2011-05-26 09:30:34 UTC
This is a multi-part message in MIME format.
Comment 4 dfilter service freebsd_committer freebsd_triage 2014-02-20 23:43:58 UTC
Author: brueffer
Date: Thu Feb 20 23:43:49 2014
New Revision: 262273
URL: http://svnweb.freebsd.org/changeset/base/262273

Log:
  Further refine the auth fail regex to catch more auth failures and
  reduce false positives.
  
  The committed patch was provided by Christian Marg.
  
  PR:		91732
  Submitted by:	Daniel O'Connor <doconnor at gsoft.com.au>
  		Skye Poier <spoier at gmail.com>
  		Alan Amesbury <amesbury at umn.edu>
  		Christian Marg <marg at rz.tu-clausthal.de>
  MFC after:	1 month

Modified:
  head/etc/periodic/security/800.loginfail

Modified: head/etc/periodic/security/800.loginfail
==============================================================================
--- head/etc/periodic/security/800.loginfail	Thu Feb 20 23:18:30 2014	(r262272)
+++ head/etc/periodic/security/800.loginfail	Thu Feb 20 23:43:49 2014	(r262273)
@@ -64,7 +64,7 @@ if check_yesno_period security_status_lo
 then
 	echo ""
 	echo "${host} login failures:"
-	n=$(catmsgs | egrep -ia "^$yesterday.*: .*(fail|invalid|bad|illegal)" |
+	n=$(catmsgs | egrep -ia "^$yesterday.*: .*\b(fail(ures?|ed)?|invalid|bad|illegal|auth.*error)\b" |
 	    tee /dev/stderr | wc -l)
 	[ $n -gt 0 ] && rc=1 || rc=0
 fi
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 5 Christian Brueffer freebsd_committer freebsd_triage 2014-02-20 23:44:29 UTC
State Changed
From-To: open->patched

Christian's patch seemed to be a good way forward, so I committed it to HEAD. 
Sorry this took so long, some kind of improvement should have been committed 
long ago. 


Comment 6 Christian Brueffer freebsd_committer freebsd_triage 2014-02-20 23:44:29 UTC
Responsible Changed
From-To: freebsd-bugs->brueffer

MFC reminder.
Comment 7 dfilter service freebsd_committer freebsd_triage 2014-03-23 12:58:52 UTC
Author: brueffer
Date: Sun Mar 23 12:58:48 2014
New Revision: 263661
URL: http://svnweb.freebsd.org/changeset/base/263661

Log:
  Further refine the auth fail regex to catch more auth failures and
  reduce false positives.
  
  The committed patch was provided by Christian Marg.
  
  PR:		91732
  Submitted by:	Daniel O'Connor <doconnor at gsoft.com.au>
    		Skye Poier <spoier at gmail.com>
    		Alan Amesbury <amesbury at umn.edu>
    		Christian Marg <marg at rz.tu-clausthal.de>

Modified:
  stable/10/etc/periodic/security/800.loginfail
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/etc/periodic/security/800.loginfail
==============================================================================
--- stable/10/etc/periodic/security/800.loginfail	Sun Mar 23 12:49:25 2014	(r263660)
+++ stable/10/etc/periodic/security/800.loginfail	Sun Mar 23 12:58:48 2014	(r263661)
@@ -64,7 +64,7 @@ if check_yesno_period security_status_lo
 then
 	echo ""
 	echo "${host} login failures:"
-	n=$(catmsgs | egrep -ia "^$yesterday.*: .*(fail|invalid|bad|illegal)" |
+	n=$(catmsgs | egrep -ia "^$yesterday.*: .*\b(fail(ures?|ed)?|invalid|bad|illegal|auth.*error)\b" |
 	    tee /dev/stderr | wc -l)
 	[ $n -gt 0 ] && rc=1 || rc=0
 fi
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 8 dfilter service freebsd_committer freebsd_triage 2014-03-23 13:03:50 UTC
Author: brueffer
Date: Sun Mar 23 13:03:46 2014
New Revision: 263662
URL: http://svnweb.freebsd.org/changeset/base/263662

Log:
  MFC: r262273
  
  Further refine the auth fail regex to catch more auth failures and
  reduce false positives.
  
  The committed patch was provided by Christian Marg.
  
  PR:		91732
  Submitted by:	Daniel O'Connor <doconnor at gsoft.com.au>
      		Skye Poier <spoier at gmail.com>
      		Alan Amesbury <amesbury at umn.edu>
      		Christian Marg <marg at rz.tu-clausthal.de>

Modified:
  stable/9/etc/periodic/security/800.loginfail
Directory Properties:
  stable/9/etc/   (props changed)

Modified: stable/9/etc/periodic/security/800.loginfail
==============================================================================
--- stable/9/etc/periodic/security/800.loginfail	Sun Mar 23 12:58:48 2014	(r263661)
+++ stable/9/etc/periodic/security/800.loginfail	Sun Mar 23 13:03:46 2014	(r263662)
@@ -59,7 +59,7 @@ case "$daily_status_security_loginfail_e
     [Yy][Ee][Ss])
 	echo ""
 	echo "${host} login failures:"
-	n=$(catmsgs | egrep -ia "^$yesterday.*: .*(fail|invalid|bad|illegal)" |
+	n=$(catmsgs | egrep -ia "^$yesterday.*: .*\b(fail(ures?|ed)?|invalid|bad|illegal|auth.*error)\b" |
 	    tee /dev/stderr | wc -l)
 	[ $n -gt 0 ] && rc=1 || rc=0;;
     *)	rc=0;;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 9 dfilter service freebsd_committer freebsd_triage 2014-03-23 13:06:31 UTC
Author: brueffer
Date: Sun Mar 23 13:06:27 2014
New Revision: 263663
URL: http://svnweb.freebsd.org/changeset/base/263663

Log:
  MFC: r262273
  
  Further refine the auth fail regex to catch more auth failures and
  reduce false positives.
  
  The committed patch was provided by Christian Marg.
  
  PR:		91732
  Submitted by:	Daniel O'Connor <doconnor at gsoft.com.au>
        		Skye Poier <spoier at gmail.com>
        		Alan Amesbury <amesbury at umn.edu>
        		Christian Marg <marg at rz.tu-clausthal.de>

Modified:
  stable/8/etc/periodic/security/800.loginfail
Directory Properties:
  stable/8/etc/   (props changed)

Modified: stable/8/etc/periodic/security/800.loginfail
==============================================================================
--- stable/8/etc/periodic/security/800.loginfail	Sun Mar 23 13:03:46 2014	(r263662)
+++ stable/8/etc/periodic/security/800.loginfail	Sun Mar 23 13:06:27 2014	(r263663)
@@ -59,7 +59,7 @@ case "$daily_status_security_loginfail_e
     [Yy][Ee][Ss])
 	echo ""
 	echo "${host} login failures:"
-	n=$(catmsgs | egrep -ia "^$yesterday.*: .*(fail|invalid|bad|illegal)" |
+	n=$(catmsgs | egrep -ia "^$yesterday.*: .*\b(fail(ures?|ed)?|invalid|bad|illegal|auth.*error)\b" |
 	    tee /dev/stderr | wc -l)
 	[ $n -gt 0 ] && rc=1 || rc=0;;
     *)	rc=0;;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 10 Christian Brueffer freebsd_committer freebsd_triage 2014-03-23 13:12:34 UTC
State Changed
From-To: patched->closed

Merge to stable branches done.