+++
Testing a Local Threat-Hunting Workflow Against Simulated Beaconing
Introduction
Hello once again everyone! In the [[06 - Building an Approval-Gated Containment Workflow with Shuffle|last post]], I finished connecting the major pieces of this project:
Alrighty everyone, here we are. The moment of truth for this whole project, can a local model triage through a snapshot of telemetry from a small network, detect potentially adversarial behavior and then leverage the correct tools to alert an analyst and recommend remediation?
I do kindly ask that if you haven’t at least skimmed the other entries in this series that you quick go give those a glance and then come back here for a sort of finale. With that being said, we are going to go ahead and plug all of the pieces we’ve developed throughout this process together and see if we can pull off our goal. A quick reminder of all our components at a high level:
Security Onion telemetry
-> snapshot export and DuckDB normalization
-> read-only MCP investigation tools
-> local Qwen3.5-9B threat hunt
-> bounded containment recommendation
-> human approval in Discord
-> routed IPv4 blocking through OPNsense
All of our plumbing works. The remaining question is whether the model can find something suspicious enough to use all these pieces appropriately.
So, naturally, we need to make something suspicious.
For this experiment I configured a Windows host to make a small, periodic HTTPS request to the public IP serving my website. The request itself was harmless, but the pattern was intended to resemble simple command-and-control check-in behavior over a web protocol. ATT&CK maps adversarial command-and-control over HTTP/S to T1071.001, Application Layer Protocol: Web Protocols.[1]
The important part is that I did not tell the model what host, destination, interval, or technique to hunt. I wanted to test the complete workflow as a broad, bounded hunt: could a 9-billion-parameter local model choose useful queries, retrieve the relevant connections, recognize their recurrence, and then make a defensible containment decision?
tl;dr: no.
Honestly? Not the ending I hoped for, but it is definitely the most useful result in this entire project.
What I Emulated
I created a PowerShell script named Check-in.ps1. Its only job was to send a GET request to my website. Instead of using the site’s hostname, I pointed the request directly at its public IP so the traffic would look a little less ordinary in the telemetry.
This was benign polling, not malware. The endpoint was mine, the Windows host was mine, and the exercise did not deliver commands or execute a payload. I was emulating one observable behavior associated with beaconing, not claiming to reproduce a complete command-and-control channel.
The PowerShell script will be in the GitHub repo where I post all the code related to this project. I’ll leave the link in the retrospective post I make for the project here soon, where I go more into detail about my own personal feelings about the project and things I would have changed in hindsight.
so, lets open Task Scheduler and create a new task.


We give the task a name and select Run whether user is logged on or not so the check-in can continue without an interactive session.

For the first experiment, we’ll trigger the program every five minutes.
One small note from the lab: leaving the trigger as a one-time schedule with a start time at midnight proved more reliable than the first configuration. My original task eventually began skipping executions. Resetting the start time resolved that behavior in this environment.

Under Actions, I configured the task to start powershell.exe and pass the script through the task’s arguments.

After that, I let the task run for roughly a day so the five-minute activity would be present alongside normal background traffic.
Exporting the Fresh Security Onion Snapshot
The collection path was the same one built earlier in this series:
- Export a bounded telemetry snapshot from Security Onion.
- Transfer the exported data to the model host.
- Normalize the Zeek and endpoint records.
- Build a snapshot-specific DuckDB database.
- Give the local model access through seven read-only MCP tools.
If you want the detailed export and normalization process, that is covered in [[Exporting Security Onion Telemetry for Local MCP Analysis]].




A few malformed records had to be skipped during this import. That is worth disclosing because the database is a normalized subset of the export, not a magical perfect copy of every raw event. The relevant test traffic was later verified directly in the resulting DuckDB database.
The first experiment database contained 10,129 queryable records:
| Evidence source | Records |
|---|---|
| Endpoint events | 5,080 |
| Zeek connections | 2,223 |
| Zeek DNS | 1,870 |
| Zeek TLS | 702 |
| Suricata alerts | 241 |
| Zeek HTTP | 13 |
| Detection documents | 0 |
| Total | 10,129 |
That is tiny compared with enterprise telemetry. It was still far more data than the model could inspect directly within an 8,192- or 12,288-token context window. The model had to use the MCP tools to decide what evidence was worth retrieving.
The Initial End-to-End Run
The first combined run used Qwen3.5-9B, an 8,192-token effective context, a maximum of six investigation calls, and no more than three rows per search result.
uv run --locked python llama_with_shuffle.py \
--db /home/kaleb/capstone-data/duckdb/experiment_1.duckdb \
--output /home/kaleb/capstone-data/poc-results \
--label qwen3.5-9b-combined-v4 \
--max-result-rows 3 \
--submit-containment
The --submit-containment flag did not mean the model could directly modify the firewall. It enabled the decision and submission path described in the previous post. A request still had to pass the client’s validation and confidence policy, reach Shuffle, and then receive human approval before OPNsense changed anything.



The model missed the check-in traffic.
It began with the telemetry overview, sampled medium-severity Suricata alerts, followed one alert into a Zeek connection, and then queried DNS. After five successful tool calls, the harness stopped evidence collection at its context guard. None of the ten returned event rows contained the test destination.
The model’s final report said the available evidence did not confirm malicious activity. That conclusion was not the main failure. The actual failure was earlier in the chain: the investigation never retrieved the controlled behavior, so the model never had a chance to assess its periodicity.
Detection and containment are separate outcomes here. A model should not isolate a host merely because an evaluator knows suspicious-looking test traffic exists somewhere in the database.
Changing the Investigation Order
My first suspicion was that the system prompt was pushing the model too strongly toward alerts. The original prompt told it to triage medium- or high-severity Suricata alerts before moving into targeted endpoint or Zeek searches.
That is reasonable SOC triage behavior, but this experiment was closer to threat hunting. The emulated polling did not create a convenient alert pointing directly at the behavior.
I removed the required alert-first order and told the model to choose its evidence sources based on what it retrieved. The user prompt, model, database, context, row limit, and tool budget stayed the same.
The path changed slightly, but the outcome did not. The model still began with the same medium alerts and the same unrelated connection. It later sampled endpoint events instead of making the earlier second DNS query, but it again retrieved none of the test traffic and stopped at the context guard.
That replay did not show an identification improvement.
Increasing the Context Window
Next I tried increasing the context window from 8,192 to 12,288 tokens.
./llama-server -hf 'bartowski/Qwen_Qwen3.5-9B-GGUF' \
-c 12288 \
-np 1 \
--jinja \
--host 127.0.0.1 \
--port 8001 \
--reasoning-budget 256
uv run --locked python llama_with_shuffle.py \
--db /home/kaleb/capstone-data/duckdb/experiment_1.duckdb \
--output /home/kaleb/capstone-data/poc-results \
--label qwen3.5-9b-e2-context12288 \
--context 12288 \
--max-tokens 1024 \
--max-tool-calls 6 \
--max-result-rows 3 \
--submit-containment
The result was still not much better. The model repeated the same first four queries and then exhausted its 1,024-token generation allowance while producing an incomplete report.
Alright, let’s try something else.
Reframing the Model as a Threat Hunter
At this point I changed the task framing more substantially. Instead of calling the model a SOC analyst, I described it as a threat hunter that should develop and test hypotheses. The new prompt explicitly said that Suricata alerts could be useful starting points but that relevant behavior might exist without an alert.


I first tested the threat-hunter prompt at an 8,192-token effective context.

This run finally retrieved one relevant connection:
{
"uid": "CaMj0N1sm3A8FNeF8",
"timestamp": "2026-11-06T00:45:02.557441+00:00",
"origin_ip": "192.168.50.113",
"responder_ip": "48.221.121.164",
"responder_port": 443,
"service": "ssl",
"duration": 0.475537,
"orig_bytes": 633,
"resp_bytes": 34046
}
That was progress in retrieval coverage, but it was not detection. One HTTPS connection does not establish beaconing, compromise, or even suspicious behavior by itself.
The model used its next call on DNS activity for the source host. It never retrieved a sequence of matching connections, never measured the timing, omitted the relevant flow from its final report, and correctly made no containment request.
I repeated the hunter condition with a verified 12,288-token context. The larger window allowed one additional endpoint query before the six-call ceiling. That query returned three ordinary logon events. The model still retrieved only the same single connection to the test destination and again did not mention it in the report.
So the larger context changed the stopping condition from the context guard to the tool-call limit. It did not change the detection outcome.
Making the Pattern Much Easier
The five-minute experiment may have been too sparse for a model that only receives three rows at a time, so I created a more favorable scenario:
- shorten the snapshot from roughly 30 minutes to 10 minutes;
- increase the check-in frequency from every five minutes to every minute; and
- retain the threat-hunter prompt and the same bounded tools.
The fresh database contained 3,035 records available through the investigation tools. A read-only ground-truth query later confirmed ten connections from the Windows test host to the test destination during the ten-minute window. Their nine displayed gaps ranged from 59.8 to 60.3 seconds, and the byte counts were nearly identical.
That is about as regular as I could reasonably make the behavior without putting the answer directly in the prompt.
At 8,192 tokens, the model used six request slots but only five calls executed because it repeated one low-alert query and hit the duplicate guard. Its only connection search followed a separate Go User-Agent alert to an unrelated destination. It retrieved zero of the ten check-ins.

I then repeated the fresh-snapshot experiment at 12,288 tokens.

All six calls executed this time. The last connection query searched broadly by source IP and returned the first three matching rows: DNS, multicast DNS, and NetBIOS traffic near the beginning of the window. More matches were available, but the model had reached the tool-call ceiling. It again retrieved zero check-ins.
The larger context did not solve the real bottleneck. The model needed a better retrieval strategy, a narrower hypothesis, a query that summarized recurrence, or some combination of the three.
An Informal Frontier-Model Comparison
I also did one deliberately informal comparison using GPT-5.6-sol in a temporary chat with personalization disabled. I attached the same experiment_1.duckdb database and gave it a prompt similar to the local model’s threat-hunter instructions:
Independently investigate the attached security telemetry snapshot as a threat hunter. Choose your own queries and assess whether the evidence supports suspicious activity or compromise. Consider credible benign explanations and describe any important coverage gaps.
Provide a concise assessment of up to 250 words. Cite the evidence IDs, timestamps, or fields that support your findings, and include the queries or reproducible analysis steps separately.
The frontier model identified the scheduled PowerShell activity and connected it to the recurring traffic much more directly than the local 9-billion-parameter workflow did.

This was not a controlled model benchmark. The frontier model had direct access to the database, a much larger operating context, different tooling, and a different execution environment. I did not preserve a complete standalone trial package with the same rigor as the local runs. The comparison therefore does not isolate model size or prove a general performance gap.
It did serve one useful purpose: it showed that the relevant telemetry was present and that a stronger system with broader access could connect the endpoint and network evidence. That made it less likely that the local result was purely a collection failure. The local workflow still had to operate through its seven bounded MCP tools, three-row results, six-call budget, and much smaller context window.
The Containment Guardrails Did Their Job
The two one-minute trials also produced a different failure.
In both runs, the model assessed the evidence at low confidence and still attempted to call the containment approval action for 192.168.50.113. Neither request was submitted:
- In the first run, the reason exceeded the validator’s maximum length.
- In the second, the requested hostname did not appear in the cited evidence row.
- More importantly, the client policy requires high confidence before a request may reach Shuffle.
No Discord approval request was sent, and no firewall change occurred.
That is a good outcome for the system even though it is a bad outcome for the model. Structured output is not the same as sound judgment. The model produced syntactically useful calls that contradicted its own low-confidence assessment. The validator and approval architecture existed specifically to prevent weak reasoning from becoming a real network action.
Results
Here is the condensed experiment history:
| Condition | Effective context | Relevant check-in traffic retrieved | Periodicity identified | Outcome |
|---|---|---|---|---|
| Original alert-first prompt | 8,192 | 0 rows | No | Stopped at context guard |
| Free investigation order | 8,192 | 0 rows | No | Stopped at context guard |
| Context increase, first attempt | 8,192 | 0 rows | No | Runner was still capped; report incomplete |
| Verified context retry | 12,288 | 0 rows | No | Same retrieval; report incomplete |
| Threat-hunter framing | 8,192 | 1 row | No | Relevant flow omitted from report |
| Threat-hunter framing | 12,288 | 1 row | No | Extra endpoint query; same miss |
| Ten-minute snapshot, one-minute check-ins | 8,192 | 0 of 10 rows | No | Duplicate consumed one request slot |
| Ten-minute snapshot, one-minute check-ins | 12,288 | 0 of 10 rows | No | Six calls executed; tool limit reached |
The five-minute snapshot and the later ten-minute snapshot are different datasets, so this table is a development history rather than a controlled benchmark where every row differs by one variable. Even within the replayed snapshot, these were single runs per condition. I am not claiming a universal detection rate for Qwen3.5-9B.
I am however, comfortable calling this an observed detection miss for the tested workflow and scenarios. The relevant traffic existed in the databases. The MCP tools could return it. The model either failed to retrieve it, retrieved too little to establish recurrence, or failed to carry the relevant row into its final assessment.
Why the Hunt Failed
The easy explanation would be that the model was too small. That is probably part of the story, but it is not the entire story.
The actual system constrained the hunt in several interacting ways:
- The task was broad. The model was asked to assess an entire mixed telemetry snapshot without being given any semblance of a starting point.
- The evidence budget was small. It had six request slots and generally received no more than three rows per search. This was an attempt to help budget context, but may have created more issues than it solved.
- The context was expensive. Tool schemas, instructions, prior calls, returned evidence, reasoning, and the final report all competed for the same window.
- The tools returned rows, not behavioral summaries. A source-IP connection search could return ordinary DNS and local service traffic before the relevant HTTPS sequence.
- Alerts were attractive distractions. Even the threat-hunter prompt repeatedly pulled the model toward existing Suricata findings that were easier to explain and correlate.
- The model did not consistently follow promising evidence. When it retrieved one relevant external connection, it did not search for more connections to the same destination or discuss the flow in its report.
This is a retrieval-and-reasoning failure across the complete workflow, not just a classification error at the end.
One detail from the reports also deserves correction: one run expanded Zeek connection state SF as “short fail.” Zeek defines SF as normal establishment and termination.[2] That mistake did not cause the missed beaconing, but it is another reminder that a polished security report can still contain basic technical errors.
What I Would Change
The clearest next experiment is also the one I should have planned from the beginning: give the model a more specific hunting objective.
Instead of asking:
Independently assess the available telemetry snapshot.
I would ask it to hunt for evidence associated with a defined technique, such as C2 via Application Layer Protocols [T1071], while still requiring it to consider benign explanations.
I wouldn’t specify a specific sub-technique, as I feel like that is closer to giving the model the answer. A more useful, targeted hunt can identify the behavior class without supplying the source host, destination, or timestamps. It gives the model a hypothesis around which to spend its limited query budget.
I would also improve the tools. A threat hunter should not have to assemble every behavioral pattern from three raw rows. Read-only summary operations could expose:
- repeated source and destination pairs;
- inter-arrival-time distributions;
- rare external destinations;
- stable byte-count patterns;
- first-seen and last-seen activity; and
- grouped connections by host, service, or destination.
These tools would help consolidate a lot of the duplicate or similar looking logs and help conserve context budget. I do feel like a large part of this project stems from engineering issues, which I feel like I could do significantly better on with that I learned from this experiment.
Finally, I would evaluate the system with multiple fresh benign and emulation snapshots after freezing the prompt, tool schemas, limits, and scoring rules. These development runs were useful for finding failure modes, but they are not enough to estimate sensitivity or false-positive rates.
Conclusion
I started this experiment hoping for the perfect demo: emulate beaconing, let a local model find it, receive a containment request in Discord, approve it, verify the OPNsense block, and then roll everything back.
That’s not quite what happened.
Instead, the 9-billion-parameter model repeatedly spent its limited budget on easier alert-driven paths. A threat-hunter prompt helped it retrieve one relevant connection in the first snapshot, but it never established recurrence. When I made the pattern substantially denser, the ground-truth query found ten nearly one-minute connections and the model retrieved none of them. Increasing context changed how far the investigation ran, but it did not fix the search strategy.
At the same time, the containment controls worked exactly as intended. Low-confidence, internally inconsistent requests did not reach the approval workflow or the firewall.
So the lesson is not that local models are useless for threat hunting. The lesson is that “point an LLM at the SIEM and let it investigate” is not a serious operational design. A small model needs a bounded hypothesis, tools that summarize the right behavior, explicit evidence requirements, and controls that assume the model will sometimes be confidently or syntactically wrong.
Honestly, that is a much better capstone result than a clean demo would have been.
I still owe this project one final post where I want to reflect on some specific pain points I encountered and just general reflections. Less so super technical talk and measurements and more so just some ramblings of mine. So thank you to anyone who’s actually trekked through all of this with me. We’ll wrap all this up next time, so take care till then.
Sources
[1] MITRE ATT&CK T1071.001: Web Protocols
[2] Zeek connection state documentation