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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...