Splunk Enterprise Security

Splunk Enterprise Security: How to set a custom risk score based on stats results?

stevenjluke
Explorer

I would like to set a custom risk score based on the number of failed authentication attempts by a user. I created the search:

index=msadauth EventID=4771 OR EventID=4768 OR EventID=4776 action=failure | eval app="Active Directory" | stats count by user,src,app | lookup dnslookup clientip as src OUTPUT clienthost as src_resolved | eval src=if(isnull(src_resolved),src,src_resolved) |rename count as failed_auth_count| fields user,src,app,failed_auth_count |eval risk_score=failed_auth_count
| sendalert risk  param._risk_object=user param._risk_object_type="user" 

What is happening a single user account returns 2 results from stats. However, the sendalert for the risk creates multiple entries for each stats result in the risk index. I'm guessing that the send alert is running as the stats results reduce.

Is there a way to have stats finish reducing before it continues to the next search command?

0 Karma

LAntoniak
Explorer

I tend to use appendpipe to avoid race conditions, to my understanding it pauses the search while it processes everything up to that point before opening up the appendpipe.

| appendpipe [ | makeresults | fields - _time ]

https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Appendpipe

"Appends the result of the subpipeline to the search results. Unlike a subsearch, the subpipeline is not run first. The subpipeline is run when the search reaches the appendpipe command. "

0 Karma

stevenjluke
Explorer

I figured out a way that works but am wondering if there is a better way. I made the search a subsearch and appended the results to nothing. By doing it this way the risk events and the number out of the stats match.

 | append [search index=msadauth EventID=4771 OR EventID=4768 OR EventID=4776 action=failure | eval app="Active Directory" | stats count by user,src,app | lookup dnslookup clientip as src OUTPUT clienthost as src_resolved | eval src=if(isnull(src_resolved),src,src_resolved) |rename count as failed_auth_count| fields user,src,app,failed_auth_count |eval risk_score=failed_auth_count  ] | sendalert risk  param._risk_object=user param._risk_object_type="user" 

Does anyone know of a better way to do this?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.


Introducing Unified TDIR with the New Enterprise Security 8.2

Read the blog

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...