Location Research Breakthrough Possible @S-Logix pro@slogix.in

Local Large Language Model-Based Root-Cause Analysis of Cybersecurity Incidents Using Correlated Apache Security Logs and Multinomial Naive Bayes

Description

Web servers generate access and error logs containing information about HTTP requests, response status codes, timestamps, requested resources, client addresses, and server errors. These records provide important information about server activities and help security analysts investigate suspicious events.

When multiple related events occur, individual log entries may not provide sufficient context to understand the complete incident. Correlating relevant events and classifying log records can help identify relationships between requests and organize security information for further investigation.

In this use case, Apache HTTP Server is deployed on Ubuntu Linux within an isolated VirtualBox laboratory environment. Kali Linux is used to generate controlled HTTP requests against the local Apache server. The resulting access and error logs are collected and processed for security analysis.

An existing public cybersecurity log dataset is used for machine-learning training and evaluation. Multinomial Naive Bayes classifies suitable log records using available, verified labels. The trained model is subsequently used to classify compatible Apache log records after applying the corresponding preprocessing and feature-extraction procedures.

Gemma 2 2B Instruct, running locally through Ollama, analyzes correlated log evidence and generates a possible root-cause explanation. SQLite stores the incident information, while Streamlit presents the collected logs, classification results, correlated events, and generated explanations for review.

The complete workflow is:
Public Cybersecurity Log Dataset
→
Data Preprocessing
→
Feature Extraction
→
Multinomial Naive Bayes Training
→
Apache Log Collection
→
Log Classification
→
Event Correlation
→
Local LLM Analysis
→
Root-Cause Explanation
→
SQLite Storage
→
Streamlit Dashboard
→
Analyst Verification

Existing Security Problem

Application/Service: Apache HTTP Server

Apache HTTP Server is the web server used in this use case. It is deployed on Ubuntu Linux within the isolated laboratory environment and generates access and error logs during normal operations and controlled security testing.

Existing Problem :

Web servers process HTTP requests from different clients and generate log records containing information about these interactions. When suspicious requests or server errors occur, security analysts must examine the available records to understand the activities and identify potentially related events.

Manual log analysis becomes difficult when numerous records are generated. Individual entries may reveal only one part of an incident, while related activities may appear across different timestamps, request paths, and response codes.

The existing problem is:

Apache HTTP Server

↓

Incoming HTTP Requests

↓

Access and Error Log Generation

↓

Large Volumes of Log Records

↓

Manual Log Examination

↓

Difficulty Identifying Related Events

↓

Incomplete Incident Context

↓

Time-Consuming Root-Cause Investigation

The proposed solution combines Multinomial Naive Bayes-based log classification with event correlation and local LLM analysis. The classifier categorizes suitable log records, while the local language model examines the correlated evidence and generates a possible explanation of the incident for analyst verification.

Attack

Specific Attack: Controlled HTTP-Based Security Testing

Controlled HTTP requests are generated from Kali Linux against the Apache HTTP Server deployed within the isolated laboratory. These requests include legitimate requests and selected security-testing requests that produce observable server responses and corresponding log entries.

The purpose of the controlled testing is to generate identifiable log evidence for examining how the classification, correlation, and root-cause analysis workflow processes different server activities.

Attack Behavior :
Kali Linux Testing System
→
HTTP Request Generation
→
Local Apache Server Receives Requests
→
Apache Processes Requests
→
HTTP Responses Generated
→
Access and Error Logs Recorded
→
Log Records Collected
→
Multinomial Naive Bayes Classification
→
Related Events Correlated
→
Local LLM Root-Cause Analysis
→
Incident Evidence Reviewed

Security Concept

Machine-Learning-Based Security Log Classification and Local LLM-Assisted Root-Cause Analysis

The primary security concept combines machine-learning classification, event correlation, and local language-model analysis to support cybersecurity incident investigation.

Security Log Classification : Multinomial Naive Bayes learns patterns from the selected, labelled cybersecurity log records. The trained model predicts categories for compatible records generated during the Apache security assessment.

Event Correlation : Related log entries are examined using available information such as timestamps, client addresses, request paths, response status codes, and predicted categories. This helps organize individual records into a more meaningful sequence of events.

Local LLM-Assisted Analysis: Gemma 2 2B Instruct analyzes the correlated log evidence and produces a possible explanation of the observed incident. The explanation is checked against the original records before being accepted as an investigative finding.

The complete security-analysis flow is:

Public Cybersecurity Log Dataset

↓

Data Preprocessing

↓

Feature Extraction

↓

Multinomial Naive Bayes Training

↓

Apache Log Collection

↓

Log Classification

↓

Event Correlation

↓

Gemma 2 2B Instruct Analysis

↓

Possible Root-Cause Explanation

↓

Incident Evidence Storage

↓

Analyst Verification

Defensive Mechanism

The security concept defines the overall incident-analysis approach.

The following defensive mechanisms support the implementation.

Security Log Classification :

Multinomial Naive Bayes classifies suitable log records using the patterns learned from the labelled training data.

Purpose: Categorize security log records for further investigation.

Consistent Data Preprocessing

The training records and newly collected Apache logs are processed using compatible feature-extraction procedures.

Purpose
  • Maintain consistent input representations for model training and classification.

Event Correlation

Related records are examined using available log fields and event information.

Purpose
  • Identify relationships between log entries and organize incident evidence.

Local LLM-Based Root-Cause Analysis

Gemma 2 2B Instruct examines correlated records and generates an evidence-based explanation of the possible incident cause.

Purpose
  • Provide contextual analysis to support incident investigation.

Incident Evidence Storage

SQLite stores the collected incident information, classification results, and generated explanations.

Purpose
  • Maintain incident records for later review and analysis.

Security Monitoring Dashboard

Streamlit displays the relevant log records, predicted categories, correlated events, and root-cause explanations.

Purpose
  • Provide an interface for reviewing and verifying the analysis results.

Analyst Verification

The generated explanation is compared with the original Apache logs and associated classification results.

Purpose
  • Validate the findings against available evidence.

Security Tools

Web Server: Apache HTTP Server

Apache HTTP Server provides the application environment in which HTTP requests are processed and security logs are generated.

Purpose
  • Generate access and error logs.
  • Record HTTP request and response information.
  • Provide the target environment for controlled security testing.

Operating System: Ubuntu Linux

Ubuntu hosts Apache HTTP Server and supports the log-processing and machine-learning components.

Purpose
  • Run the local web server.
  • Execute Python and Ollama.
  • Support the incident-analysis workflow.

Security Testing Platform: Kali Linux

Kali Linux is used to generate controlled HTTP requests against the authorized laboratory server.

Purpose
  • Send legitimate and controlled security-testing requests.
  • Observe server responses.
  • Generate log evidence for analysis.

Virtualization Platform: VirtualBox

VirtualBox provides the isolated virtual-machine environment.

Purpose
  • Host the Ubuntu and Kali Linux virtual machines.
  • Separate the application and testing environments.
  • Support repeatable laboratory experiments.

Programming Environment: Python

Python integrates dataset processing, model training, log collection, classification, event correlation, and LLM analysis.

Purpose
  • Implement the analysis workflow.
  • Connect the machine-learning and LLM components.
  • Automate incident-data processing.

Data Processing Tool: Pandas

Pandas organizes and processes the existing cybersecurity log dataset and collected Apache logs.

Purpose
  • Prepare numerical feature representations.
  • Support data transformations.
  • Provide numerical arrays for machine-learning operations.

Machine-Learning Library: Scikit-learn

Scikit-learn provides the Multinomial Naive Bayes implementation and model-evaluation utilities.

Purpose
  • Train the classification model.
  • Generate predictions for compatible log records.
  • Evaluate model performance using appropriate metrics.

Local LLM Runtime: Ollama

Ollama runs the selected language model locally within the analysis environment

Purpose
  • Load and execute Gemma 2 2B Instruct.
  • Process correlated incident evidence.
  • Generate root-cause explanations without requiring a hosted LLM API.

Language Model: Gemma 2 2B Instruct

Gemma 2 2B Instruct is the local language model used for contextual incident analysis.

Purpose
  • Analyze correlated log information.
  • Summarize relevant security events.
  • Generate possible root-cause explanations based on supplied evidence.

Incident Database: SQLite

SQLite stores the incident information produced by the analysis workflow.

Purpose
  • Store relevant log records and classification results.
  • Preserve correlated event information.
  • Maintain generated explanations for later review.

Dashboard Framework: Streamlit

Streamlit provides the interface for displaying the analysis results.

Purpose
  • Present log classifications and correlated events.
  • Display generated root-cause explanations.
  • Support incident review and evidence verification.

HTTP Testing Tool: cURL

cURL generates HTTP requests against the local Apache server.

Purpose
  • Send controlled HTTP requests.
  • Observe response status codes.
  • Generate reproducible server-log entries.

Network Discovery Tool: Nmap

Nmap identifies services exposed by the authorized laboratory target.

Purpose
  • Discover the local Apache service.
  • Identify the relevant listening port.
  • Verify the expected laboratory service exposure.

API and Web Testing Tool: OWASP ZAP

OWASP ZAP can be used to inspect HTTP traffic during authorized web-server testing.

Purpose
  • Inspect requests and responses.
  • Support controlled HTTP testing.
  • Provide additional request evidence where required.

Visualization Library: Matplotlib or Plotly

Matplotlib or Plotly can be used to visualize classification and incident-analysis results.

Purpose
  • Present relevant event counts.
  • Display classification evaluation results.
  • Visualize incident-related information.

Process

STEP 01

Prepare the Isolated Laboratory Environment

  • Create the laboratory using VirtualBox.
  • Configure Ubuntu Linux as the application and analysis system.
  • Configure Kali Linux as the security-testing system.
  • Establish the intended laboratory network connectivity.
  • Verify that testing targets only the authorized local environment.
Tools: VirtualBox + Ubuntu Linux + Kali Linux
STEP 02

Deploy Apache HTTP Server

  • Prepare Apache HTTP Server on Ubuntu.
  • Configure the required local web service.
  • Start the Apache service.
  • Verify that the server responds to legitimate HTTP requests.
  • Confirm that access and error logging are available.
Tools: Ubuntu Linux + Apache HTTP Server
STEP 03

Establish Normal Server Activity

  • Access the local Apache server.
  • Generate legitimate HTTP requests.
  • Observe the corresponding response status codes.
  • Examine the access and error logs.
  • Preserve representative normal log records.
Tools: Apache HTTP Server + cURL
STEP 04

Identify the Exposed Laboratory Service

  • Identify the authorized Ubuntu laboratory target.
  • Perform controlled service discovery from Kali Linux.
  • Identify the Apache service port.
  • Verify the expected service exposure.
  • Record the observed laboratory service information.
Tools: Kali Linux + Nmap
STEP 05

Prepare the Public Cybersecurity Log Dataset

  • Obtain the existing public cybersecurity log dataset.
  • Load the available records into Python.
  • Inspect the dataset fields and record structure.
  • Identify available labels and classification categories.
  • Check whether the records support the intended training task.
Tools: Python + Pandas
STEP 06

Select Suitable Training Records

  • Review the available dataset records.
  • Identify records with usable classification labels.
  • Select records appropriate for the classification task.
  • Exclude unsuitable or unusable records where necessary.
  • Preserve the original labels for evaluation.
Tools: Python + Pandas
STEP 07

Preprocess the Dataset

  • Inspect missing or inconsistent values.
  • Clean unsuitable records where required.
  • Normalize the representation of relevant fields.
  • Convert compatible log information into numerical features.
  • Record the preprocessing procedure for reuse.
Tools: Python + Pandas + NumPy
STEP 08

Extract Classification Features

  • Identify the features supported by the selected dataset.
  • Select suitable textual or categorical log attributes.
  • Convert the attributes into numerical representations.
  • Prepare the feature matrix for Multinomial Naive Bayes.
  • Verify that the prepared features are compatible with the model.
Tools: Python + Pandas + Scikit-learn
STEP 09

Prepare Training and Evaluation Data

  • Separate the prepared records into training and evaluation sets.
  • Preserve the corresponding labels.
  • Avoid using evaluation records during model training.
  • Check the distribution of available classes.
  • Prepare the data for model evaluation.
Tools: Python + Scikit-learn + Pandas
STEP 10

Train the Multinomial Naive Bayes Model

  • Configure the Multinomial Naive Bayes classifier.
  • Provide the prepared training features and labels.
  • Train the model using the selected records.
  • Generate predictions for the evaluation records.
  • Preserve the trained model and configuration.
Tools: Python + Scikit-learn
STEP 11

Evaluate the Classification Model

  • Compare model predictions with the known evaluation labels.
  • Calculate accuracy where appropriate.
  • Calculate precision, recall, and F1-score where applicable.
  • Review incorrect predictions and class-specific performance.
  • Record the actual evaluation results.
Tools: Python + Scikit-learn + Pandas
STEP 12

Collect Apache Access and Error Logs

  • Generate legitimate requests against the local Apache server.
  • Perform authorized controlled HTTP security testing.
  • Observe the corresponding server responses.
  • collect the resulting access and error log records.
  • Preserve the logs for subsequent analysis.
Tools: Apache HTTP Server + cURL + Kali Linux
STEP 13

Preprocess the Collected Apache Logs

  • Load the collected Apache log records.
  • Inspect the available request and response fields.
  • Extract the information required for analysis.
  • Apply compatible feature-processing procedures.
  • Verify whether the extracted features match the trained model's input requirements.
Tools: Python + Pandas + NumPy
STEP 14

Classify the Apache Log Records

  • Load the trained Multinomial Naive Bayes model.
  • Provide compatible processed log features.
  • Generate the predicted category for each record.
  • Preserve the corresponding prediction results.
  • Review the classifications alongside the original log entries.
Tools: Python + Scikit-learn
STEP 15

Correlate Related Log Events

  • Collect the classified log records.
  • Examine timestamps and available request information.
  • Identify records that may be related to the same activity.
  • Organize the relevant events into a chronological sequence.
  • Preserve the correlated records for root-cause analysis.
Tools: Python + Pandas + SQLite
STEP 16

Perform Local LLM-Based Root-Cause Analysis

  • Start Ollama in the Ubuntu analysis environment.
  • Load Gemma 2 2B Instruct.
  • Provide the correlated log evidence and classification results.
  • Generate a possible root-cause explanation based on the supplied information.
  • Preserve the explanation alongside its supporting evidence.
Tools: Ubuntu Linux + Ollama + Gemma 2 2B Instruct
STEP 17

Store and Display Incident Information

  • Organize the collected incident records.
  • Store relevant logs and classification results in SQLite.
  • Store correlated event information and generated explanations.
  • Create Streamlit views for the available analysis results.
  • Verify that the stored information is displayed correctly.
Tools: Python + SQLite + Streamlit
STEP 18

Validate the Complete Analysis Workflow

  • Repeat the workflow with legitimate and controlled test requests.
  • Review the resulting Apache logs and model classifications.
  • Compare the correlated events with the original records.
  • Verify the LLM-generated explanations against the available evidence.
  • Document the results, limitations, and observed errors.
Tools: Apache HTTP Server + Kali Linux + Python + Scikit-learn + Ollama + SQLite + Streamlit

Outcome

Apache HTTP Server is deployed within an isolated Ubuntu and Kali Linux laboratory environment for controlled security testing.

An existing public cybersecurity log dataset is processed to prepare suitable labelled records for m achine-learning training and evaluation.

The Multinomial Naive Bayes model is trained and evaluated using the selected dataset, with actual classification metrics recorded to assess its performance.

Apache access and error logs are collected during normal application activity and controlled HTTP security testing.

Compatible Apache log records are processed and classified using the trained model, providing categorized information for further investigation.

Related log records are correlated using available event information, helping organize potentially connected activities into a chronological sequence.

Gemma 2 2B Instruct runs locally through Ollama and generates possible root-cause explanations from the correlated log evidence

SQLite stores the relevant incident records, classification results, correlated events, and generated explanations for subsequent review.

Streamlit presents the available analysis results through a dashboard, supporting examination of log classifications and possible incident causes.

The complete workflow demonstrates the integration of cybersecurity log classification, event correlation, local LLM-assisted root-cause analysis, incident storage, and analyst verification within a controlled laboratory environment.