<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vitalii Balint</title>
    <description>The latest articles on DEV Community by Vitalii Balint (@vitaliibalint).</description>
    <link>https://dev.to/vitaliibalint</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4203794%2F8bc682be-de33-471b-9467-25465d31196c.png</url>
      <title>DEV Community: Vitalii Balint</title>
      <link>https://dev.to/vitaliibalint</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vitaliibalint"/>
    <language>en</language>
    <item>
      <title>Building a Local AI SOC Lab with Wazuh and Qwen: Lessons from a Real Implementation</title>
      <dc:creator>Vitalii Balint</dc:creator>
      <pubDate>Sat, 24 Oct 2026 04:02:35 +0000</pubDate>
      <link>https://dev.to/vitaliibalint/building-a-local-ai-soc-lab-with-wazuh-and-qwen-lessons-from-a-real-implementation-215e</link>
      <guid>https://dev.to/vitaliibalint/building-a-local-ai-soc-lab-with-wazuh-and-qwen-lessons-from-a-real-implementation-215e</guid>
      <description>&lt;p&gt;Security monitoring generates a lot of data. But collecting alerts is only the beginning. The real challenge is retrieving the right events, understanding what happened, and making decisions based on evidence.&lt;/p&gt;

&lt;p&gt;I wanted to explore a practical question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can a locally hosted AI model help a security analyst investigate Wazuh alerts without giving the AI control over the infrastructure?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To explore this, I built an isolated AI-assisted Security Operations Center (SOC) lab using Wazuh, OpenSearch, Python, SQLite, and a local Qwen model.&lt;/p&gt;

&lt;p&gt;This is a manually operated proof of concept, not a production SOC or an autonomous security platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. My Lab Architecture
&lt;/h2&gt;

&lt;p&gt;The environment includes Ubuntu 24.04 virtual machines for security telemetry and Wazuh services, together with a Windows workstation running the Python assistant and LM Studio.&lt;/p&gt;

&lt;p&gt;The main components are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Wazuh Agent:&lt;/strong&gt; collects security events from an Ubuntu endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wazuh Manager and OpenSearch Indexer:&lt;/strong&gt; process and store security alerts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Python SOC Assistant:&lt;/strong&gt; retrieves alerts and prepares them for analysis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQLite:&lt;/strong&gt; tracks processed events and stores generated reports.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LM Studio + Qwen 3.5 4B Instruct:&lt;/strong&gt; generates structured incident analysis proposals.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Human analyst:&lt;/strong&gt; reviews findings and determines the next steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The assistant uses a restricted reader account. Access to the Indexer is protected through SSH port forwarding and TLS verification.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important security boundary:&lt;/strong&gt; The AI cannot execute firewall commands, modify server configurations, or automatically block IP addresses.&lt;/p&gt;

&lt;p&gt;Its purpose is investigation support, not autonomous remediation.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The First Problem: Missing Alerts
&lt;/h2&gt;

&lt;p&gt;My initial implementation retrieved only the 20 newest alerts.&lt;/p&gt;

&lt;p&gt;This worked for a small demonstration, but it was not reliable when more events were present.&lt;/p&gt;

&lt;p&gt;I improved the Python client using OpenSearch Scroll pagination to retrieve a bounded snapshot of matching alerts.&lt;/p&gt;

&lt;p&gt;In one documented integration test:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;152 matching alerts were reported by OpenSearch.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;152 alerts were successfully retrieved.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;152 unique event IDs were verified.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That confirmed the pagination logic worked correctly for that query snapshot.&lt;/p&gt;

&lt;p&gt;It did not prove continuous monitoring or complete historical coverage.&lt;/p&gt;

&lt;p&gt;I also encountered an Indexer permission issue affecting Scroll cleanup. Fixing the reader permissions was part of making the workflow reliable without giving it unnecessary access.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Why I Added SQLite
&lt;/h2&gt;

&lt;p&gt;Originally, processed event IDs were tracked using a JSON file.&lt;/p&gt;

&lt;p&gt;That approach was simple, but I wanted more reliable event state, recovery, and retry behavior.&lt;/p&gt;

&lt;p&gt;I introduced SQLite to preserve processed identifiers and incident reports.&lt;/p&gt;

&lt;p&gt;During verification, I successfully migrated 20 existing event IDs and confirmed database integrity.&lt;/p&gt;

&lt;p&gt;I also tested restoring a synthetic incident report from the database after its Markdown export was missing.&lt;/p&gt;

&lt;p&gt;This taught me an important engineering lesson:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI analysis is only one part of the system. Reliable event state and recovery matter just as much.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Connecting a Local Qwen Model
&lt;/h2&gt;

&lt;p&gt;The Python assistant connects to Qwen through LM Studio's local API-compatible endpoint.&lt;/p&gt;

&lt;p&gt;The workflow sends selected security events to the model and requests structured JSON output.&lt;/p&gt;

&lt;p&gt;The application validates required fields before saving a report.&lt;/p&gt;

&lt;p&gt;In one test, I used a synthetic failed SSH authentication event.&lt;/p&gt;

&lt;p&gt;Qwen proposed:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disposition:&lt;/strong&gt; SUSPICIOUS&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Severity:&lt;/strong&gt; LOW&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended action:&lt;/strong&gt; Investigate and review related logs.&lt;/p&gt;

&lt;p&gt;This was useful, but I also noticed how easily a language model could misinterpret technical context.&lt;/p&gt;

&lt;p&gt;For example, a client source port can be confused with a destination service port. A single failed login also does not automatically indicate brute-force activity.&lt;/p&gt;

&lt;p&gt;That is why I separate observed evidence from AI-generated hypotheses.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Prompt Injection in Security Logs
&lt;/h2&gt;

&lt;p&gt;One of the most interesting experiments involved an untrusted SSH log message.&lt;/p&gt;

&lt;p&gt;I tested synthetic log content containing text designed to manipulate the model into treating failed authentication as successful authentication.&lt;/p&gt;

&lt;p&gt;In a documented retest, the model preserved the failed-login finding.&lt;/p&gt;

&lt;p&gt;An earlier test also exposed an unsafe recommendation to block an IP address. I introduced conservative recommendation filtering and regression tests to help keep responses within the lab's read-only investigation scope.&lt;/p&gt;

&lt;p&gt;These were limited experiments.&lt;/p&gt;

&lt;p&gt;They do not demonstrate complete resistance to prompt injection or guarantee that every AI-generated recommendation is safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security logs are evidence, not instructions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Human review remains essential.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Testing and Verification
&lt;/h2&gt;

&lt;p&gt;I wanted the project to demonstrate more than a working screenshot.&lt;/p&gt;

&lt;p&gt;The repository includes 31 mocked and offline Python tests, exercised through GitHub Actions using Python 3.10 and 3.12.&lt;/p&gt;

&lt;p&gt;The implementation also includes validation of event identity, persistent processing state, structured model responses, and read-only operational boundaries.&lt;/p&gt;

&lt;p&gt;However, automated tests alone do not prove production security or detection accuracy.&lt;/p&gt;

&lt;p&gt;The lab still has important limitations: manual execution, no continuous alert monitoring, and network restrictions around the local model service that require further verification before broader deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. What I Learned
&lt;/h2&gt;

&lt;p&gt;Three lessons stand out from this project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First, reliable data retrieval comes before AI analysis.&lt;/strong&gt; Missing alerts can undermine even a well-written incident report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second, local AI can assist security investigations, but its output must be validated.&lt;/strong&gt; A structured response is not necessarily a correct response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Third, automation needs clear security boundaries.&lt;/strong&gt; I prefer a system that helps an analyst understand an event over one that performs potentially harmful actions without approval.&lt;/p&gt;

&lt;p&gt;My next areas of work include more realistic alert replay tests, better performance measurements, and stronger local-model network restrictions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Resources
&lt;/h2&gt;

&lt;p&gt;The public repository includes the Python implementation, tests, documentation, and sanitized verification examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/vitaliibalint39-oss/ai-powered-soc-lab" rel="noopener noreferrer"&gt;AI-Powered SOC Lab&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Original engineering article:&lt;/strong&gt; &lt;a href="https://ta551.info/blog/wazuh-ai-security-lab/" rel="noopener noreferrer"&gt;Building a Local AI SOC Lab with Wazuh and Qwen&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm interested in how other engineers approach local AI for security operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Would you trust a local LLM to prepare incident triage reports if every recommendation required human approval?&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Editorial disclosure: This DEV.to adaptation was prepared with AI writing assistance using my original engineering article and documented project results as source material.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>ai</category>
      <category>python</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
