question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kerberos principal username not supported by apache_access parser

See original GitHub issue

Description of problem:

pyparsing.alphanums is not sufficient to parse user names in the apache_access parser. For instance with mod_auth_gssapi the user name is a Kerberos principal (e.g. “pyllyukko@EXAMPLE.COM”). Another non-alphanum char I encountered was the underscore.

Plaso’s result in parsing my Apache logs:

************************** Plaso Storage Information ***************************                                                                              
            Filename : test-1.plaso                                                                                                                           
      Format version : 20210514                                                                                                                               
        Storage type : session                                                                                                                                
Serialization format : json                                                                                                                                   
--------------------------------------------------------------------------------                                                                              
                                                                                                                                                              
*********************************** Sessions ***********************************                                                                              
d6dcde46-8f50-494c-9768-be9dad3f2f53 : 2021-09-03T17:31:45.047702Z                                                                                            
--------------------------------------------------------------------------------                                                                              
                                                                                                                                                              
******************************** Event sources *********************************                                                                              
Total : 1                                                                                                                                                     
--------------------------------------------------------------------------------                                                                              
                                                                                                                                                              
No events stored.                                                                                                                                             
                                                                                                                                                              
No events labels stored.                                                                                                                                      
                                                                                                                                                              
No warnings stored.                                                                                                                                           
                                                                                                                                                              
No analysis reports stored.

After modifying apache_access as follows:

diff --git a/plaso/parsers/apache_access.py b/plaso/parsers/apache_access.py                                                                                  
index ec801ef6..4d7bffe0 100644                                                                                                                               
--- a/plaso/parsers/apache_access.py                                                                                                                          
+++ b/plaso/parsers/apache_access.py                                                                                                                          
@@ -109,7 +109,7 @@ class ApacheAccessParser(text_parser.PyparsingSingleLineTextParser):                                                                      
       pyparsing.Suppress('"'))                                                                                                                               
                                                                                                                                                              
   _USER_NAME = (                                                                                                                                             
-      pyparsing.Word(pyparsing.alphanums) |                                                                                                                  
+      pyparsing.Word(pyparsing.printables) |                                                                                                                 
       pyparsing.Literal('-')).setResultsName('user_name')                                                                                                    
                                                                                                                                                              
   # Defined in https://httpd.apache.org/docs/2.4/logs.html

The events got properly parsed (the log had 14717 lines in it):

************************* Events generated per parser **************************
Parser (plugin) name : Number of events
--------------------------------------------------------------------------------
       apache_access : 14716
               Total : 14716
--------------------------------------------------------------------------------

I’m not sure whether pyparsing.printables is the correct answer either, but that’s what I used to hack my way around this issue. The valid Kerberos principal chars could be a starting point though.

Command line and arguments:

log2timeline.py --hashers none --parsers apache_access test-2.plaso access_log.1-2

Source data:

192.168.0.64 - pyllyukko@EXAMPLE.COM [16/Nov/2019:09:46:42 +0200] "GET / HTTP/1.1" 200 8264

Plaso version:

20210606

Installation method:

Docker.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jleanizcommented, Nov 15, 2021

I reproduced the bug and will work on a fix. Thanks for reporting!

0reactions
pyllyukkocommented, Nov 16, 2021

Are all access log entries where you observed a Kerberos SPN of the same format for the username field?

Yes. The initial source where I stumbled upon this issue wasn’t actually Kerberos principals, but just arbitrary usernames. I used the Kerberos principal as an example to demonstrate that pyparsing.alphanums is insufficient.

Have you seen username\domain or others?

Nope. Sounds like Windows world 😃 (Or domain\username to be exact.) Doesn’t still mean that these kind of entries couldn’t exist, but I just haven’t seen one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java 11 Error with Kerberos Authentication principal
I am getting this exception when my HikariDataSource is attempting to establish a connection with my oracle database by using kerberos as the ......
Read more >
Chapter 24 Kerberos Error Messages and Troubleshooting
Cause: Authentication with checksum was not negotiated with the client. The client might be using an old Kerberos V5 protocol that does not...
Read more >
Plaso 20211229 released - Open Source DFIR
The Apache access parser has been updated to support username with Kerberos principal (#3831) with thanks to @jleaniz.
Read more >
syslog-ng Open Source Edition 3.22 - Administration Guide
When a filename resolved from the macros contains a character that HDFS does not support, syslog-ng OSE will not be able to create...
Read more >
Creating a Kerberos service principal name and keytab file - IBM
Procedure · Click Start > Programs > Administrative Tools > Active Directory Users and Computers. Use the name for WebSphere Application Server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found