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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...