CYBERSECURITY HOME LAB / WAZUH / LOCAL AI

Wazuh SIEM & AI-Powered SOC Lab

A hands-on defensive security lab connecting Wazuh SIEM and OpenSearch with Python, SQLite, LM Studio, and a local Qwen model. The workflow retrieves alerts, prevents duplicate processing, validates structured AI output, and produces reports for human review.

Scope: isolated and authorized personal lab work. This is not a production SOC, managed security service, autonomous response system, or claim of complete security assurance.

PROBLEM AND ENGINEERING GOAL

Making alert triage complete, repeatable, and reviewable.

The project began as a small proof of concept and evolved through audit, implementation, and verification.

01 / INGESTION

Avoid missing older alerts

The initial approach queried only the newest 20 matching alerts. A larger backlog could leave earlier events unseen. The current implementation uses the OpenSearch Scroll API to retrieve every match from a consistent snapshot, page by page.

Verified evidence: 152 matching alerts retrieved with 152 unique IDs and checked against an OpenSearch count snapshot.

02 / STATE

Prevent duplicate analysis and recover reports

A JSON-only processed-ID list was not enough for durable report state. SQLite now records event status and full report content transactionally before Markdown export, so a missing report file can be reconstructed after restart.

Verified evidence: 20 legacy processed IDs migrated without deleting processed_events.json; a synthetic report was restored from a temporary database.

03 / AI OUTPUT

Constrain local LLM responses

Free-form AI output can be incomplete or misleading. The assistant pins an explicit model ID, requests a defined JSON schema, rejects truncated or malformed responses, and checks required fields and selected factual anchors.

Boundary: validation improves consistency, but it does not prove that Qwen’s hypotheses or severity assessment are correct.

04 / OPERATIONS

Keep each run bounded and observable

Manual runs analyze five new events by default, configurable from one to twenty. Aggregate counts and run status are written to a local JSONL journal without storing raw alerts or report bodies in that log.

Outcome: failures remain retryable, processing is capped, and the operator can review what each run selected, completed, or failed.

LAB ARCHITECTURE

From endpoint telemetry to a human-reviewed report.

The Indexer is reached through an SSH tunnel with TLS verification and a restricted reader account.

Ubuntu + Wazuh Agent→Wazuh / OpenSearch→SSH tunnel + TLS→Python + SQLite→LM Studio / Qwen→Human review

WAZUH AND OPENSEARCH INTEGRATION

Read-only alert retrieval

Wazuh agents send security telemetry to the Manager and Indexer. The Python client queries wazuh-alerts-* over a verified tunnel, iterates the scroll cursor until no hits remain, and attempts to release the scroll context.

  • Indexer port bound to loopback in the documented design
  • Local CA certificate used for TLS verification
  • Restricted reader credentials entered interactively
  • Pagination failures remain visible

EVENT STATE AND DEDUPLICATION

SQLite event ledger

Each Wazuh event ID is checked against SQLite before it can enter the AI batch. Completed reports are committed to the database first and exported afterward, reducing the chance that a crash loses completed work.

  • Idempotent migration from the preserved JSON list
  • Completed, failed, and retryable states
  • Report content available for export recovery
  • Local state and reports excluded from Git

LOCAL LLM SECURITY MONITORING

Qwen alert triage through LM Studio.

The model assists with structured analysis; it receives no remediation tools and cannot change monitored systems.

Explicit local model selection

The Python client calls LM Studio’s OpenAI-compatible API and requires an exact SOC_MODEL_ID. A missing or different model stops the run instead of silently selecting another model.

JSON report validation

Qwen must return the required event ID, disposition, severity, confidence, observed facts, hypotheses, read-only investigation steps, and a true human-review flag. Invalid JSON, mismatched IDs, or truncated completions are rejected.

Untrusted-log guardrails

Log fields are bounded before prompting. Selected claims are checked against the source event, and a conservative filter rejects recommendations containing known mutating actions such as blocking an address.

Human-review safeguards

Generated findings remain unverified until an analyst reviews the source alert. The workflow performs no firewall changes, account actions, or automated incident response.

Verified live-model example: with Qwen 3.5 4B Instruct and thinking disabled in LM Studio, one synthetic failed-SSH event produced a schema-valid report. That test demonstrates the integration path—not factual reliability, production readiness, or broad prompt-injection resistance.

TEST EVIDENCE

Evidence separated from claims.

Results below are documented in the public repository and were rechecked against the current main branch.

152/152Matching alert IDs retrieved
31Offline unit tests passed
3.10 + 3.12Python CI versions
TEST 01

Pagination completeness

The integration record documents 152 alerts, 152 unique IDs, a matching count snapshot, and successful scroll cleanup after targeted read permissions were added.

TEST 02

Durable event state

SQLite integrity returned ok; 20 previous IDs migrated, and one synthetic report was recovered from a disposable database.

TEST 03

Structured Qwen response

One synthetic SSH event completed JSON parsing, schema validation, factual checks, and Markdown rendering through the local model API.

TEST 04

Automated regression suite

Thirty-one mocked and offline tests cover ingestion, bounded runs, event storage, output contracts, log guardrails, and run summaries.

What these tests do not prove: continuous ingestion, concurrent-run safety, complete Indexer authorization boundaries, universal prompt-injection resistance, calibrated AI confidence, production reliability, or the accuracy of every generated hypothesis.

KNOWN LIMITATIONS

Security boundaries and open work.

A credible cybersecurity home lab should make its constraints visible.

Manual snapshot workflow

OpenSearch Scroll reads a snapshot; it is not continuous ingestion or a durable time checkpoint. New alerts wait for the next manually initiated run.

AI output remains untrusted

Qwen may hallucinate patterns, infer unsupported intent, or assign the wrong severity. One successful hostile-log test is not comprehensive prompt-injection protection.

Lab network exposure needs review

The repository documents LM Studio listening on a network interface for a separate Hermes experiment. Effective firewall reachability and source restrictions were not fully verified.

No production or commercial claim

This work demonstrates integration and defensive engineering practice in an isolated lab. It is not a penetration test, managed SOC offering, or proof of all effective permissions.

RELATED TECHNICAL WORK

Infrastructure, automation, and source evidence.

Continue from the security case study into the systems and local-AI work behind it.

01

Infrastructure services

Linux and Windows Server administration, VPS operations, Nginx, DNS, HTTPS, troubleshooting, and automation.

02

AI & Automation Lab

Local Qwen, LM Studio, Python workflows, VMware experiments, and the boundaries of local AI tooling.

03

Technical portfolio

Return to the project overview for Wazuh, Hermes OSINT, infrastructure, and cybersecurity work.

04

GitHub repository ↗

Inspect the implementation, tests, documentation, sanitized evidence, and acknowledged limitations.

ORIGINAL LAB EVIDENCE

Security monitoring in practice.

These screenshots document lab interfaces and experiments, not a production security service.