Building an Automated Containment Pipeline with Local Models and Shuffle
Series: Capstone
Building an Automated Containment Pipeline with Local Models and Shuffle
Introduction
Alright, welcome back to those following along with the series. If you’re not, that’s fine, but be prepared to be lacking some context. On the last post we had finally gotten our local model to be able to query some exported Security Onion logs through some read-only MPC tools we had developed. Now that we ironed out all of that for the most part, it’s time to start working on the response portion of this whole ordeal.
As we should all be aware by now, I am using Shuffle as my open-source SOAR solution. Shuffle gives us some pretty nice baked in MCP tools and API endpoints so hopefully we should be able to automate this all pretty nicely. Just to give you a little bit of the end result up front, the pipeline is pretty rudimentary, but it gets the job done.
Security Onion snapshot
-> read-only evidence MCP tools
-> local Qwen3.5-9B investigation
-> bounded containment recommendation
-> Shuffle containment app
-> Discord approval or decline
-> OPNsense external alias update
-> tested host's outbound IPv4 ICMP through OPNsense stopped
So our model will receive and investigate the Security Onion evidence, make a containment recommendation based off of the evidence and then by leveraging Shuffle we send the Discord approval message. Then depending on whether the analyst accepts or declines, an API call is made to our OPNsense firewall to update the rules and block any further outbound communication from the affected client.
And emphasis on recommend here. I am not giving a 9-billion-parameter model running on an old gaming laptop unsupervised access to my firewall. Again, the model here only recommends and invokes the Shuffle workflow, it is not reaching out to the firewall itself. Also something worth noting, I don’t have any super sophisticated access control to the Discord message for workflow approval/denial, it’s just a webhook that goes to a private channel. So yeah you need to be in the channel, but if you are then it’s free game.
Okay, with all that being said, let’s go ahead and get to work.
Building the Parent Containment Workflow
Before starting, I activated the Discord and OPNsense apps in my Shuffle workspace. Again with Discord carrying the approval request and OPNsense enforcing the block. Apps can be found under Discover Public Apps, where you can activate the integrations you want to use.

From there, go to Automate → Workflows.

Click Create Workflow, give it a name and description, select the Quarantine use case, and create it from scratch.


I named what would end up being our parent workflow Block Suspected Host. The overall workflow looks like this:
Start Request
-> Approve Host Block
-> Add Host to Block List
-> Containment Confirmation
The first action is Shuffle Tools’ repeat back to me action. It passes $exec, the current workflow run’s input, through to the later nodes. For our parent workflow, this will eventually contain the target address, containment reason, and supporting information from the model.

The second node is a User Input trigger named Approve Host Block. This pauses the parent workflow while a person decides whether the firewall change should continue. I enabled the subflow option so the approval request is sent through a separate Discord notification workflow.
I initially tried formatting the entire approval message inside this node’s Information field to then be passed to the Discord workflow. That eventually produced invalid JSON when Shuffle inserted the value into the Discord request, so I stopped trying to make this field do all the work.

The information field is intentionally simple:
$exec
Passing the data through and doing the presentation work inside the Discord body ended up being much more reliable.
Sending the Approval Request to Discord
The child workflow is named Request Containment Approval. It receives the User Input trigger’s data from the parent and runs a Discord Send a message action.
I started with the smallest possible test body:
{
"content": "Shuffle test",
"allowed_mentions": {
"parse": []
}
}
Shuffle said the action succeeded, but that didn’t mean anything actually appeared in Discord…

But it did, so yippee, that’s neat.

Amazing. With the basic webhook working, I replaced the test message with an approval card. The working body looks like this:
{
"content": "**Host containment approval requested**\n\n**Target IP:** `$exec.information.target_ip`\n\n**Reason for containment:**\n$exec.information.reason\n\n**Proposed action:**\nBlock this endpoint's routed IPv4 network access through OPNsense.\n\n[Approve immediately](http://192.168.50.52:3001$exec.api_continue)\n[Decline immediately](http://192.168.50.52:3001$exec.api_abort)\n\nClicking a link immediately submits your decision.",
"allowed_mentions": {
"parse": []
}
}
The difference between $exec in the two workflows is worth pointing out. In the parent, $exec.target_ip refers to the original containment request. In the child, $exec is the payload passed by the User Input trigger, so the request data sits under $exec.information and the approval callbacks are available as $exec.api_continue and $exec.api_abort.
The direct links immediately submit the decision. They do not open a nice approval form, and the browser returns a small JSON acknowledgement after you click one.
I originally tried using Shuffle’s native approval form, but it was unreliable in this installation. One attempt referenced the Docker-only shuffle-backend:5001 hostname, and even after fixing browser reachability I could get a disabled form while the parent workflow was still waiting. The direct API links were ugly, but they worked consistently, so that is what I used for the proof of concept.
My Shuffle console is still using LAN-only HTTP, the callback is effectively an authorization-bearing link, and clicking it immediately records the decision. That is acceptable for this lab demonstration, but not something I would expose to an untrusted network.

I manually tested both paths. Approve allowed the parent workflow to continue, while Decline ended the request without reaching the firewall action.


At this point the human-in-the-loop plumbing worked, but approving the request still did not actually contain anything. Time to connect OPNsense.
Creating the OPNsense Block Alias
My original plan involved host isolation through leveraging Elastic Agent, but that feature is not available in the free version. So, for this proof of concept, I am using OPNsense to block the selected host’s routed network access instead.
That is obviously not the same as complete endpoint isolation. This rule affects IPv4 traffic routed through OPNsense. It does not block East-West traffic, it does not cover IPv6, and existing stateful connections may need their states removed before a new block takes effect. I am deliberately calling this routed IPv4 containment rather than pretending I built a full EDR isolation feature… cause I didn’t.
In OPNsense, I created an external alias named SOAR_BLOCKED_HOSTS.

An external alias is a useful fit here because its contents can be managed by another system through the API. I then created a LAN firewall rule with SOAR_BLOCKED_HOSTS as the source and placed it above the normal LAN allow rules.

The rule blocks traffic from addresses currently present in the alias. The alias contents only exist during runtime and do not survive an OPNsense reboot, which is useful for a temporary lab control so it works for this, but I wanted to highlight is not a permanent solution.
Calling OPNsense from Shuffle
So the community OPNsense app ended up calling a different /firewall endpoint than the alias-util endpoint exposed by my installation, so I switched to Shuffle’s raw HTTP action. Also, my working OPNsense management/API endpoint is on port 8443; port 443 produced a TLS handshake error in this environment.
The endpoints used in this lab are:
GET https://192.168.50.1:8443/api/firewall/alias_util/aliases
GET https://192.168.50.1:8443/api/firewall/alias_util/list/SOAR_BLOCKED_HOSTS
POST https://192.168.50.1:8443/api/firewall/alias_util/add/SOAR_BLOCKED_HOSTS
POST https://192.168.50.1:8443/api/firewall/alias_util/delete/SOAR_BLOCKED_HOSTS
OPNsense API credentials use HTTP Basic authentication, with the API key as the username and the API secret as the password. Those values stay in Shuffle’s saved authentication configuration and do not belong in the workflow body, screenshots, or this post.
For these lab calls, I also had certificate verification disabled in Shuffle’s HTTP action because the app runtime did not trust my internal CA. That is another lab shortcut, not the desired final configuration.
For a documentation-only test, I used the reserved address 192.0.2.10:
{
"address": "192.0.2.10"
}
The add request returned HTTP 200 with:
{
"status": "done"
}


That is some pretty neat stuff.
I followed that with a GET request to list the alias contents and confirmed that the test address was present.

One small issue caught me here. For GET requests with an empty body, sending Content-Type: application/json caused OPNsense to try parsing an empty JSON body and return Invalid JSON syntax. Using only this header resolved the readback request:
Accept: application/json
POST requests with JSON bodies still use Content-Type: application/json.
Once the direct API calls worked, I added the HTTP action after the approval node in the parent workflow. Its body uses the target supplied at runtime:
{
"address": "$exec.target_ip"
}
The only change to the earlier path is that an approved decision now feeds the OPNsense HTTP action before the confirmation step.

Testing the Actual Network Effect
A successful API response proves that OPNsense accepted the request. It does not prove that the firewall rule affected the host. So I used a lab server at 192.168.50.166 and checked outbound IPv4 connectivity before running the workflow.

The host could reach 8.8.8.8 before containment: four packets transmitted, four received, and zero percent loss.

I started the parent workflow with:
{
"target_ip": "192.168.50.166",
"reason": "Approval-gated alias integration test"
}
After the message arrived in Discord, I approved it. Shuffle completed the HTTP action and OPNsense returned status: done.

The same host then failed its outbound test: six packets transmitted, zero received, and 100 percent loss.

Amazing.
So the block worked for this test: routed outbound IPv4 ICMP stopped after approval. Just to reiterate, this does not mean complete network isolation. The blocked address can still communicate within your subnet, which is still absolutely a security concern.
Turning the Workflow into a Model-Visible App
The workflow worked manually, but it did not automatically become a model-callable tool. My first probe could list saved workflows through Shuffle’s REST API and list actions from selected app scopes through MCP. What it did not show was the saved workflow magically appearing as a callable tool. The MCP scope exposed app actions, not every saved workflow.
Instead of creating another custom MCP server, I made a small OpenAPI definition named capstone_containment.openapi.json. I gave it one job: POST a request to the parent workflow’s execution endpoint. I imported that definition under Automate → Apps → Create an App → Upload.


After reviewing the generated fields, I saved the app and waited for Shuffle to build it.


The resulting app is named Capstone_Containment. Its model-facing action is:
post_request_host_containment_approval
The wrapped workflow expects an execution_argument, and that value is itself a JSON-encoded string. Conceptually, the request looks like this:
{
"execution_argument": "{\"target_ip\":\"192.0.2.10\",\"reason\":\"Approval integration test\"}"
}
Yes, nested serialization is as fun as it looks.
The imported app also generated a generic custom_action, but I exclude that action from model access. The client only offers the specifically named containment operation.
What the Model Actually Calls
This is the point where the term “Shuffle MCP integration” can become misleading, so here is the actual sequence:
- The Python client initializes a connection to Shuffle’s MCP interface.
- It lists the actions in the known
Capstone_Containmentapp scope. - It selects only
post_request_host_containment_approvaland supplies that live schema to Qwen. - Qwen generates a structured function call containing the target and reason.
- The client validates the tool name, target network, nested JSON, transport fields, evidence references, and other arguments.
- The client runs the selected app through Shuffle’s REST app-action endpoint.
- The app starts the existing parent workflow, which still pauses for human approval.
MCP initialize + tools/list
-> model structured call
-> client validation
-> REST app action
-> parent workflow
-> Discord approval
-> OPNsense
Native MCP tools/call execution was not proven here. Discovery was also deliberately scoped to one known app, and only one action was offered to the model. This is not an autonomous agent wandering through every playbook in Shuffle and deciding what it feels like running.
The first dummy model-to-approval test used 192.0.2.10. Qwen produced the expected structured arguments, the client submitted the app action once, Shuffle created a parent execution, and the Discord approval message arrived.


That test verified the invocation and formatting path. It did not prove that the model had detected malicious behavior because the target and reason were part of an integration test.
Combining Investigation and Response
The Security Onion investigation client already existed from the last post. The new work here was attaching its final recommendation stage to the containment action. The command used for the documented combined run was:
cd /home/kaleb/capstone/Custom-MCP
uv run --locked python snapshot_poc_v4.py \
--db /home/kaleb/capstone-data/duckdb/20261020T013000Z_20261020T020000Z.duckdb \
--output /home/kaleb/capstone-data/poc-results \
--label qwen3.5-9b-combined-v4 \
--max-result-rows 3 \
--submit-containment
The local model server was running Qwen3.5-9B with an 8,192-token context:
./llama-server \
-hf 'bartowski/Qwen_Qwen3.5-9B-GGUF' \
-c 8192 \
-np 1 \
--jinja \
--host 127.0.0.1 \
--port 8001 \
--reasoning-budget 256
The combined client performs two model tasks. First, it investigates the bounded Security Onion snapshot through seven read-only tools, with up to six targeted calls and small result sets. Then it gives the model a bounded set of the retrieved event rows and asks whether containment is warranted. A valid recommendation includes:
- the target IPv4 address;
- an optional hostname;
- a reason describing the suspected malicious activity;
- the model’s confidence in malicious activity;
- one to three references to retrieved event rows; and
- important limitations or uncertainty.
The client checks that the target is inside the configured lab network and that the selected IP and any supplied hostname occur in the cited event rows. That is a consistency check, not proof that the hostname or endpoint process generated the cited network activity. The client also validates the expected containment action and its nested request format.
The output directory preserves manifest.json, transcript.json, final.md, summary.json, and containment.json, so I can separately inspect the investigation, decision, and submission status afterward.

When a valid request reaches Shuffle, Discord receives the model’s target, rationale, evidence references, limitations, and a run reference.

Now that is pretty cool. It is also where the model immediately reminded me why all these guardrails are necessary.
The first recorded combined run had a transport problem before the decision even reached Discord. The app request waited about 45 seconds, returned no usable acknowledgement, and the client recorded submission_outcome_unknown. I checked Shuffle and found no new parent execution. A later rerun delivered the dynamic recommendation after the Shuffle host had been rebooted, but I did not prove that the reboot fixed the underlying problem.
The First Containment Decision Was Bad
The first recorded combined run investigated the historical October 20 snapshot. Its final report said the retrieved sample did not support compromise, although it was still more confident in the benign interpretation than the limited evidence justified.
Then the decision step requested containment for 192.168.50.113 with low confidence.
That recommendation cited a Go user-agent connectivity alert, a small successful HTTP connection, and routine-looking Brave and Wazuh file activity. It also acknowledged that no high-severity alerts were present and that much of the alert population had not been reviewed. In other words, the model did not have a persuasive reason to isolate the host, said its confidence was low, and asked to isolate it anyway.
That is a failure, not a successful demo. The model’s report and requested action contradicted one another, and a confidence label does not become meaningful merely because the model included it in valid JSON.
I changed the client policy in a few ways:
- A containment request can only be submitted when the model reports high confidence in malicious activity.
- Low- and medium-confidence requests are preserved in
containment.jsonas policy violations but stopped before any Shuffle app execution. - The decision prompt makes
no_containmentthe default and separates alert severity from confidence in malicious activity. - The model is told to consider credible benign explanations rather than inflate its certainty to satisfy the rule.
I tested the client-side suppression locally, including replaying the exact low-confidence .113 request. The client retained the attempted recommendation and did not call the app. The revised policy has passed local and replay-based checks, but the new live-model baseline was still pending when I wrote these notes. No Discord message is currently sent when the model chooses no_containment or when the client suppresses a request; those outcomes stay in the local artifacts.
Human approval remains the final control even for a valid high-confidence request. The confidence threshold decides whether the proposal may reach Discord. It does not authorize the firewall change, and it definitely does not prove the underlying security interpretation is correct.
What This Build Proves
Here is the shortest honest version of what I tested and what is still missing:
| Tested | Not tested or not established |
|---|---|
| Discord approve and decline paths | Authenticated reviewer identity around the direct links |
| Approved OPNsense external-alias update | Complete endpoint isolation, same-subnet blocking, or IPv6 |
| Outbound IPv4 ICMP stopped for the manual test host | A clearly recorded rollback and connectivity restoration |
| Shuffle MCP discovery of the scoped app action | Native Shuffle MCP tools/call execution |
| Qwen produced the app’s structured request | Free selection among every Shuffle app or workflow |
| Low/medium-confidence requests were suppressed in local and replay tests | A completed live baseline using the revised confidence policy |
A high-confidence model label is also not a calibrated probability or proof of malicious activity, and the historical snapshot does not support a full detection-accuracy claim.
I am not trying to undersell the project here. I just do not want a cool proof of concept turning into claims I did not actually test.
Conclusion
The most important result here might actually be the failure. The first combined run produced a technically valid but unjustified low-confidence containment request. Without the client-side confidence policy and approval step, valid syntax could have turned weak reasoning into a real network change. That is exactly the problem this architecture is supposed to contain.
The next step is to stop testing against ordinary historical traffic and generate a small, reproducible piece of adversarial behavior in the lab. Then I can collect a fresh Security Onion snapshot, see whether the model finds the right evidence, and test the entire path from detection through human-approved containment and verified rollback.
So, time to go do something suspicious on purpose. I’ll see you all next time.
References
- Shuffle workflow documentation
- Shuffle API and MCP documentation
- Shuffle app documentation
- OPNsense firewall API reference
- OPNsense alias documentation