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
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...