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

TF-IDF and Cosine Similarity-Based Correlation of SQL Injection Attack Logs in OWASP Juice Shop for Automated Incident Reconstruction and Summarization Using Gemma 2 2B Instruct

Description

Modern web applications generate HTTP requests, responses, application events, and security-related logs during normal operation and security testing. These records can contain useful information about SQL Injection (SQLi) attempts, suspicious request parameters, database-related errors, unusual response patterns, and other activities associated with potential application attacks.

SQL Injection is a web application attack in which an attacker attempts to manipulate database queries through application inputs. If an application does not handle user-controlled input securely, malicious input may affect database query execution and potentially expose or modify information.

During a SQL Injection attack, relevant evidence may appear across multiple records, including HTTP requests, application logs, security-tool alerts, and response information. Individually, these records may provide only partial information about the activity. Investigators must correlate the available evidence to understand the sequence of events and reconstruct the incident.

In this use case, OWASP Juice Shop is deployed within an isolated cybersecurity laboratory. Kali Linux is used as the controlled security-testing environment, while Ubuntu Linux hosts the application and log-analysis workflow. OWASP ZAP is used to inspect HTTP traffic and preserve relevant request and response evidence during authorized testing.

Existing public web-application security data is considered as an additional data source where suitable records and metadata are available. The dataset is inspected to determine whether its records can support the proposed log-processing and similarity-analysis workflow. The dataset name is not fixed in this use case; the source is selected according to data availability, suitability, and permitted usage.

Python is used to preprocess collected log records and prepare textual representations. TF-IDF converts suitable log text into numerical vectors, while Cosine Similarity measures the textual similarity between selected log entries. The resulting similarity scores are combined with available information, such as timestamps, request identifiers, source addresses, HTTP methods, request paths, and attack-test context, to identify potentially related events.

The correlated events are organized chronologically to reconstruct the observed SQL Injection test activity. SQLite stores the relevant log records, similarity results, correlation relationships, and incident evidence.

Gemma 2 2B Instruct is executed locally through Ollama to summarize the correlated evidence and generate a structured incident investigation report. The generated report is verified against the original logs and controlled testing evidence before its conclusions are accepted.

The complete incident-reconstruction workflow is:

OWASP Juice Shop → Controlled SQL Injection Testing → HTTP Traffic and Log Collection → Existing Public Security-Data Review → Log Preprocessing → TF-IDF Feature Extraction → Cosine Similarity Calculation → Related Event Identification → Evidence-Based Event Correlation → SQLite Evidence Storage → Chronological Incident Reconstruction → Gemma 2 2B Instruct Analysis → Incident Summary Generation → Evidence Verification → Correlation Evaluation → Final Incident Report

Existing Security Problem

Application: OWASP Juice Shop

OWASP Juice Shop is the target web application in this use case. It provides intentionally vulnerable application functionality for authorized web application security testing and security research.

The application is deployed within an isolated laboratory environment. Kali Linux is used to perform controlled security testing, while OWASP ZAP supports inspection of HTTP requests and responses associated with the application.

The application provides the testing environment in which SQL Injection-related requests and their associated evidence can be collected and analyzed.

Existing Problem :

SQL Injection testing can generate multiple HTTP requests and responses containing different inputs, response characteristics, and application events. Security tools may also produce alerts related to suspicious requests.

When these records are examined independently, investigators may find it difficult to determine which events belong to the same attack sequence. Similar requests may occur at different times, while a single request may generate multiple related records.

Manual investigation can require reviewing request parameters, timestamps, response information, and application logs separately. This can increase investigation effort and make it harder to reconstruct the sequence of a controlled security incident.

Traditional string matching may identify records containing identical text, but it may fail to associate records that contain related terms with different wording. Text-similarity techniques can help identify potentially related records, although similarity alone cannot establish that an attack occurred.

The security problem is:
OWASP Juice Shop
→
Normal Web Application Activity
→
Controlled SQL Injection Test Activity
→
HTTP Requests and Application Events
→
Multiple Security-Relevant Log Records
→
Fragmented Incident Evidence
→
Manual Log Examination
→
Difficulty Correlating Related Events
→
Incomplete or Delayed Incident Reconstruction
→
Requirement for Similarity-Based Log Correlation
→
Requirement for Automated Incident Summarization

The proposed solution introduces a TF-IDF and Cosine Similarity-based log-correlation workflow to identify potentially related records. Event correlation uses additional available evidence to establish relationships between records and reconstruct the observed incident timeline.

Attack

Specific Attack: Controlled SQL Injection Attack Against OWASP Juice Shop

The controlled attack scenario evaluates whether HTTP traffic and related security evidence generated during a SQL Injection test can be collected, correlated, and reconstructed using the proposed similarity-based investigation workflow.

OWASP Juice Shop is deployed within the authorized laboratory environment. Kali Linux is used as the security-testing system, and OWASP ZAP is used to inspect the relevant HTTP communication.

A controlled SQL Injection test is performed against an appropriate test endpoint within the local application. The test is restricted to the laboratory environment and does not target external applications, production systems, or third-party data.

The resulting HTTP requests, responses, and available application or security-tool records are preserved as investigation evidence. The records are then processed using TF-IDF and Cosine Similarity to identify textual relationships between potentially related events.

The correlation results are combined with timestamps, request information, and other available evidence to reconstruct the observed test sequence.

Gemma 2 2B Instruct analyzes the resulting evidence and generates an incident summary. The summary is validated against the original records and known laboratory test conditions.

Attack Behavior :
Kali Linux Security-Testing Environment
→
OWASP Juice Shop Target Application
→
Controlled SQL Injection Test
→
HTTP Request Generation
→
Application Response and Available Log Generation
→
HTTP Traffic Inspection Using OWASP ZAP
→
Security Evidence Collection
→
Log Preprocessing
→
TF-IDF Feature Extraction
→
Cosine Similarity Calculation
→
Potentially Related Event Identification
→
Evidence-Based Event Correlation
→
Chronological Incident Reconstruction
→
Gemma 2 2B Instruct Investigation
→
Incident Summary and Report Generation
→
Evidence Verification and Final Evaluation

Security Concept

TF-IDF and Cosine Similarity-Based Security Log Correlation with LLM-Assisted Incident Reconstruction

TF-IDF and Cosine Similarity-Based Security Log Correlation with LLM-Assisted Incident Reconstruction

The first objective is to convert collected HTTP and security-related log text into numerical representations using TF-IDF. This technique assigns weights to terms based on their occurrence within a record and their distribution across the collection of records.

The second objective is to calculate Cosine Similarity between selected log representations. The resulting scores indicate how similar the textual representations are. These scores are used to identify potentially related records for further investigation.

The third objective is to combine similarity results with available contextual information, such as timestamps, request paths, HTTP methods, source information, and controlled test records. The resulting event relationships are organized chronologically to reconstruct the observed incident.

Gemma 2 2B Instruct then summarizes the correlated evidence, describes the observed sequence of events, and prepares a structured investigation report. Its conclusions are verified against the original records.

The assessment follows:
OWASP Juice Shop
→
Controlled SQL Injection Testing
→
HTTP Traffic and Log Collection
→
Log Preprocessing
→
TF-IDF Text Representation
→
Cosine Similarity Calculation
→
Potentially Related Log Identification
→
Contextual Event Correlation
→
Incident Timeline Reconstruction
→
SQLite Evidence Storage
→
Gemma LLM-Based Evidence Summarization
→
Incident Report Generation
→
Evidence Verification and Correlation Evaluation

Defensive Mechanism

The security concept defines the overall security strategy.

The following are the specific defensive mechanisms implemented.

HTTP Traffic and Security Log Collection :

HTTP requests, responses, and available security-related records are collected during legitimate application activity and controlled SQL Injection testing.

Purpose: Preserve the original evidence required for log analysis, event correlation, and incident reconstruction.

Public Security-Data Assessment

Existing public web-application security data is reviewed to determine whether it contains records suitable for the proposed analysis.

Purpose
  • Identify an appropriate additional data source without requiring a predefined dataset name or assuming that every public dataset contains compatible log records.

Consistent Log Preprocessing

Collected records are normalized into a consistent textual representation while retaining important contextual fields.

Purpose
  • Prepare comparable log records while preserving timestamps, request details, and other information needed for investigation.

TF-IDF Feature Extraction

TF-IDF converts suitable log text into numerical vectors representing the relative importance of terms within the collection of records.

Purpose
  • Provide a numerical representation of log text for similarity analysis.

Cosine Similarity Analysis

Cosine Similarity measures the similarity between TF-IDF vectors associated with selected log entries.

Purpose
  • Identify potentially related records for further contextual investigation.

Evidence-Based Event Correlation

Potential relationships identified through similarity analysis are evaluated using additional available information, such as timestamps, request paths, HTTP methods, request identifiers, and attack-test context.

Purpose
  • Associate related records using both textual similarity and supporting contextual evidence.

Incident Timeline Reconstruction

Correlated events are arranged chronologically using available timestamps and other reliable ordering information.

Purpose
  • Reconstruct the observed sequence of security-relevant events and support incident investigation.

Structured Evidence Storage

Relevant logs, similarity scores, correlation relationships, and incident findings are stored in SQLite.

Purpose
  • Relevant logs, similarity scores, correlation relationships, and incident findings are stored in SQLite.

LLM-Assisted Incident Summarization

Gemma 2 2B Instruct analyzes the correlated evidence and generates a structured summary of the observed incident.

Purpose
  • Reduce manual effort in preparing incident summaries and explaining the sequence of observed events.

Evidence Verification

The generated summary is compared with the original HTTP traffic, available application records, and controlled test information.

Purpose
  • Identify unsupported conclusions and ensure that reported findings remain traceable to collected evidence.

Correlation and Detection Evaluation

The correlation workflow is evaluated using known relationships from controlled test scenarios and manually verified evidence.

Purpose
  • Assess whether the workflow correctly identifies related events and identify false correlations, missed relationships, and investigation limitations.

Security Tools

Primary Vulnerable Application: OWASP Juice Shop

OWASP Juice Shop provides the web application environment used for controlled SQL Injection testing.

Purpose
  • Provide an intentionally vulnerable web application for authorized testing.
  • Generate application activity and HTTP traffic.
  • Support controlled SQL Injection test scenarios.
  • Provide a target for collecting security investigation evidence.

Security Testing Platform: Kali Linux

Kali Linux provides the controlled security-testing environment.

Purpose
  • Perform authorized application security testing.
  • Generate controlled test requests.
  • Support repeatable SQL Injection testing.
  • Preserve the relationship between the test activity and collected evidence.

Application and Analysis Environment: Ubuntu Linux

Ubuntu Linux hosts the application or analysis components according to the laboratory configuration.

Purpose
  • Support application deployment where required.
  • Execute the Python log-analysis workflow.
  • Run local investigation components.
  • Store collected evidence and analysis results.

Virtualization Platform: VirtualBox

VirtualBox provides the isolated laboratory environment.

Purpose
  • Host the Ubuntu and Kali Linux virtual machines.
  • Separate the target application from the security-testing environment.
  • Support controlled network communication.
  • Reduce the risk of unintended interaction with external systems.

HTTP Security Testing Tool: OWASP ZAP

OWASP ZAP is used to inspect HTTP requests and responses associated with the controlled testing activity.

Purpose
  • Inspect application HTTP traffic.
  • Preserve relevant request and response evidence.
  • Support identification of SQL Injection-related test activity.
  • Provide traffic records for subsequent analysis.

Programming and Automation Tool: Python

Python provides the main implementation environment for the project.

Purpose
  • Parse and preprocess log records.
  • Implement TF-IDF and Cosine Similarity analysis.
  • Correlate related events.
  • Reconstruct incident timelines.
  • Integrate evidence storage and LLM-based summarization.

Text Processing and Numerical Library: NumPy

NumPy supports numerical operations required by the text-analysis workflow.

Purpose
  • Support numerical data processing.
  • Assist with vector operations and result handling.
  • Prepare numerical information for analysis.

Text Feature Extraction Tool: Scikit-learn TF-IDF Vectorizer

Scikit-learn's TF-IDF Vectorizer converts suitable log text into numerical feature vectors.

Purpose
  • Represent log entries numerically.
  • Calculate term weights across the selected record collection.
  • Produce feature vectors for Cosine Similarity analysis.
  • Maintain consistent text transformation during repeated analysis.

Similarity Analysis Tool: Scikit-learn Cosine Similarity

Scikit-learn provides a function for calculating Cosine Similarity between numerical vectors.

Purpose
  • Compare TF-IDF representations of log entries.
  • Generate similarity scores.
  • Identify candidate relationships between records.
  • Support further contextual event correlation.

Data Processing Tool: Pandas

Pandas is used to organize log records, contextual fields, and correlation results.

Purpose
  • Load and organize structured records.
  • Filter and transform log information.
  • Manage timestamps and request attributes.
  • Prepare correlation results for storage and evaluation.

Local LLM Runtime: Ollama

Ollama provides the local runtime for executing the selected language model.

Purpose
  • Run the supported language model locally.
  • Receive structured investigation evidence.
  • Generate incident summaries.
  • Integrate LLM output with the Python workflow.

Large Language Model: Gemma 2 2B Instruct

Gemma 2 2B Instruct provides the LLM-assisted incident investigation capability.

Purpose
  • Summarize correlated security events.
  • Describe the observed incident sequence.
  • Generate a structured incident investigation report.
  • Suggest further investigation steps based on the supplied evidence.

Database: SQLite

SQLite provides local storage for security evidence and investigation results.

Purpose
  • Store collected log records and relevant metadata.
  • Record similarity scores and correlation relationships.
  • Maintain incident timeline information.
  • Store investigation summaries and verification results.

Evaluation Tool: Python-Based Evidence Review

Python scripts and manually verified controlled-test evidence are used to evaluate the correlation workflow.

Purpose
  • Compare identified relationships with known test events.
  • Examine false correlations and missed relationships
  • Evaluate incident timeline accuracy.
  • Verify the consistency of generated investigation reports.

Process

STEP 01

Prepare the Isolated Cybersecurity Laboratory

  • Create an isolated cybersecurity laboratory using VirtualBox.
  • Configure Ubuntu Linux as the application and analysis environment according to the planned architecture
  • Configure Kali Linux as the security-testing environment.
  • Establish controlled communication between the virtual machines using the intended laboratory network configuration.
  • Verify that the application and testing environments are reachable as required.
  • Confirm that testing is restricted to the authorized laboratory.
  • Record the virtual-machine configuration and relevant network details.
Tools: VirtualBox + Ubuntu Linux + Kali Linux
STEP 02

Deploy OWASP Juice Shop

  • Deploy OWASP Juice Shop within the isolated laboratory.
  • Configure the application and its required components.
  • Start the application services.
  • Verify that the application is operational.
  • Access the application through the authorized laboratory client.
  • Confirm that the application functions normally before security testing.
  • Record the application address, deployment configuration, and baseline status.
Tools: OWASP Juice Shop + Ubuntu Linux + VirtualBox
STEP 03

Establish the Normal Application Activity Baseline

  • Access the application using its intended functionality.
  • Perform legitimate application operations that generate normal HTTP requests and responses.
  • Inspect the resulting traffic using OWASP ZAP.
  • Record available request paths, HTTP methods, timestamps, response information, and other relevant metadata.
  • Verify that the application operates normally.
  • Preserve representative normal-activity records for comparison with controlled SQL Injection testing.
Tools: OWASP Juice Shop + OWASP ZAP + Python
STEP 04

Configure HTTP Traffic Inspection and Evidence Collection

  • Configure OWASP ZAP to inspect traffic associated with the local application.
  • Verify that the relevant HTTP requests and responses can be captured.
  • Determine which fields are available for subsequent analysis.
  • Preserve request and response records in an appropriate format.
  • Ensure that collected records can be associated with their source test activity where possible.
  • Record any fields that are unavailable or cannot be reliably extracted.
Tools: OWASP ZAP + OWASP Juice Shop + Python
STEP 05

Review Existing Public Web-Application Security Data

  • Identify existing public web-application security data that may support the project.
  • Review the available documentation, record structure, labels, usage permissions, and relevant fields.
  • Determine whether the data contains log records or metadata suitable for the planned correlation workflow.
  • Do not assume that a public dataset necessarily contains the same records or format generated by OWASP Juice Shop.
  • Use the public data as an additional analysis source only when its structure and purpose are appropriate.
  • Keep the dataset source configurable rather than fixing a specific dataset name in the project document.
Tools: Python + Pandas
STEP 06

Inspect and Preprocess the Collected Records

  • Load the collected HTTP traffic, application records, and other available security evidence into the Python environment.
  • Inspect the structure and consistency of the records.
  • Identify missing fields, malformed entries, duplicated records, and inconsistent timestamps.
  • Normalize the textual representation of the records while preserving important contextual information.
  • Retain fields such as timestamps, request paths, HTTP methods, source information, response information, and request identifiers when available.
  • Preserve the original records separately from the processed working data.
  • Record the preprocessing operations applied to each input source.
Tools: Python + Pandas + NumPy
STEP 07

Identify Relevant SQL Injection Test Events

  • Review the controlled testing records and identify entries associated with the SQL Injection test.
  • Use the known test time window, captured request information, and available application or security-tool evidence to identify the relevant records.
  • Separate known test events from normal application activity for evaluation.
  • Preserve the original record references and known test conditions.
  • Avoid treating a textual similarity score as proof that an event is malicious.
  • Prepare the records required for similarity analysis and later validation.
Tools: Python + Pandas + OWASP ZAP
STEP 08

Extract TF-IDF Features from the Log Text

  • Select the textual fields suitable for comparison, such as request paths, request parameters, alert descriptions, application messages, or other available log content.
  • Combine the selected fields into a consistent textual representation while retaining their original contextual metadata separately.
  • Configure the TF-IDF Vectorizer.
  • Fit the vectorizer on the selected corpus of records that is appropriate for the intended comparison.
  • Transform the records into numerical TF-IDF vectors.
  • Preserve the fitted vectorizer for subsequent analysis of compatible records.
  • Verify that the resulting feature matrix is valid and that the selected text contains sufficient information for meaningful comparison.
Tools: Python + Scikit-learn + Pandas + NumPy
STEP 09

Calculate Cosine Similarity Between Log Entries

  • Provide the TF-IDF vectors to the Cosine Similarity calculation.
  • Calculate similarity scores between selected log entries or candidate record pairs.
  • Record the scores together with the corresponding record identifiers.
  • Inspect representative high-similarity and low-similarity pairs.
  • Determine whether the selected textual fields provide useful relationships for the controlled test scenario.
  • Configure a similarity threshold based on observed validation results rather than assuming that one fixed score is universally correct.
  • Preserve the scores for subsequent contextual event correlation.
Tools: Python + Scikit-learn + NumPy
STEP 10

Define the Event-Correlation Logic

  • Implement a Python-based event-correlation workflow.
  • Use similarity scores to identify candidate relationships between records.
  • Combine the similarity results with available contextual fields, including timestamps, request paths, HTTP methods, request identifiers, source information, and controlled test context.
  • Apply reasonable time-window and record-association rules according to the available evidence.
  • Avoid linking unrelated records solely because they contain common words or similar text.
  • Record the reason each relationship was accepted or rejected.
  • Prepare the resulting event relationships for incident reconstruction.
Tools: Python + Pandas + Scikit-learn
STEP 11

Perform the Controlled SQL Injection Test

  • Use Kali Linux as the authorized security-testing environment.
  • Target only the OWASP Juice Shop instance deployed in the isolated laboratory.
  • Perform a controlled SQL Injection test against an appropriate test endpoint.
  • Keep the test limited to the requirements of the experiment.
  • Capture the associated HTTP request and response through the configured inspection workflow.
  • Record the test time and other available contextual information.
  • Avoid targeting external applications or production systems.
  • Preserve the test activity as known evidence for subsequent correlation evaluation.
Tools: Kali Linux + OWASP Juice Shop + OWASP ZAP
STEP 12

Capture and Validate the Test-Related Logs

  • Collect the HTTP traffic and available application or security-tool records generated during the controlled test.
  • Identify the records associated with the test using the recorded time window and available request details.
  • Preserve the original records.
  • Check that the collected records correspond to the intended test activity.
  • Inspect timestamps, request paths, HTTP methods, parameters, response information, and available alert details.
  • Record missing fields and other limitations that may affect event correlation.
  • Confirm that the evidence is suitable for the planned analysis.
Tools: OWASP ZAP + OWASP Juice Shop + Python + Pandas
STEP 13

Preprocess the Captured Test Records

  • Load the newly captured records into the Python analysis workflow.
  • Apply the established text-cleaning and field-normalization procedures.
  • Use the same fitted TF-IDF Vectorizer configuration where the records are compatible with the training corpus.
  • Do not independently fit a new vectorizer for every record or comparison, because the resulting feature spaces may not be directly comparable.
  • Retain the original timestamps and contextual fields for event correlation.
  • Verify that the processed records can be represented using the expected feature dimensions.
  • Preserve the resulting vectors and their original record identifiers.
Tools: Python + Pandas + NumPy + Scikit-learn
STEP 14

Identify Potentially Related Events

  • Calculate or retrieve the Cosine Similarity scores associated with the processed records.
  • Identify candidate pairs or groups of potentially related records.
  • Compare their textual content and similarity scores.
  • Review the available timestamps and request context.
  • Apply the defined correlation logic to determine which relationships are supported by the available evidence.
  • Preserve rejected relationships for analysis when useful.
  • Record the accepted candidate relationships and their supporting information.
Tools: Python + Scikit-learn + Pandas
STEP 15

Reconstruct the Incident Timeline

  • Collect the records and relationships accepted by the event-correlation workflow.
  • Arrange the events chronologically using their available timestamps.
  • Associate each event with its original record and relevant similarity results.
  • Identify the sequence of observed requests, responses, and related security events.
  • Distinguish directly observed events from inferred relationships.
  • Where timestamps or supporting fields are unavailable, mark the ordering or relationship as uncertain instead of inventing missing details.
  • Generate a structured incident timeline for investigation.
Tools: Python + Pandas + SQLite
STEP 16

Store the Evidence and Correlation Results

  • Create the SQLite database for the investigation workflow.
  • Define appropriate tables for collected records, record metadata, similarity scores, accepted event relationships, incident timelines, and investigation reports.
  • Store the original record references and processed results.
  • Maintain the known controlled-test information separately from similarity-based conclusions.
  • Preserve the reason for each accepted correlation where available.
  • Verify that records can be retrieved for later analysis and report generation.
Tools: Python + SQLite
STEP 17

Generate the LLM-Assisted Incident Investigation Report

  • Prepare the reconstructed incident timeline, correlated records, relevant similarity scores, and supporting evidence references.
  • Provide the structured information to Gemma 2 2B Instruct through Ollama.
  • Request an incident summary that describes the observed sequence, relevant request and response evidence, identified relationships, and possible explanations.
  • Require the report to distinguish observed facts from hypotheses and uncertain relationships.
  • Avoid asking the model to invent missing events or treat similarity scores as confirmed attack evidence.
  • Review the generated summary against the original records and known test conditions.
  • Correct or flag unsupported statements before saving the verified report in SQLite.
Tools: Python + Ollama + Gemma 2 2B Instruct + SQLite
STEP 18

Perform Final Correlation Validation and Security Review

  • Repeat the workflow using normal application activity and controlled SQL Injection test scenarios.
  • Review the TF-IDF representations and Cosine Similarity scores.
  • Compare the identified event relationships with the known controlled-test evidence.
  • Evaluate whether the workflow correctly associates relevant records and avoids linking unrelated activity.
  • Review the accuracy and completeness of the reconstructed timeline.
  • Verify the generated incident report against the original evidence.
  • Record false correlations, missed relationships, missing data, and other limitations.
  • Document the selected similarity threshold, correlation rules, and evaluation results so that the experiment can be repeated.
  • Finalize the security assessment with the validated incident timeline, correlation results, and evidence-supported report.
Tools: Python + Scikit-learn + Pandas + SQLite + Ollama + Gemma 2 2B Instruct + OWASP ZAP + OWASP Juice Shop

Outcome

OWASP Juice Shop is successfully deployed within an isolated cybersecurity laboratory to provide a controlled environment for web application security testing.

The HTTP traffic inspection workflow is configured using OWASP ZAP, enabling relevant requests, responses, and available security evidence to be collected during normal application activity and controlled SQL Injection testing.

Existing public web-application security data is reviewed as an additional source where suitable records are available. The project does not depend on a predefined dataset name and documents the suitability of any selected external data source.

Collected HTTP and security-related records are preprocessed into a consistent textual representation while preserving the contextual information required for investigation.

TF-IDF converts the selected log text into numerical feature vectors, providing a representation suitable for textual similarity analysis.

Cosine Similarity generates scores that indicate the degree of textual similarity between selected log entries. These scores are used to identify candidate relationships for further investigation rather than independently confirming an attack.

The event-correlation workflow combines similarity results with available timestamps, request paths, HTTP methods, request identifiers, source information, and controlled test context to identify potentially related security events.

Correlated records are arranged chronologically to reconstruct the observed sequence of events associated with the controlled SQL Injection test. The resulting timeline retains references to the original records and distinguishes observed facts from inferred relationships.

SQLite stores the collected evidence, similarity scores, event relationships, incident timeline, and investigation results in a structured format.

Gemma 2 2B Instruct analyzes the correlated evidence through Ollama and generates a readable incident summary containing the observed activity, supporting evidence, possible explanations, and recommended investigation steps.

The generated incident report is verified against the original HTTP traffic and available application or security-tool records, ensuring that unsupported statements are identified before the report is accepted.

Repeated testing with normal application activity and controlled SQL Injection scenarios provides evidence for evaluating the correlation workflow, including false correlations, missed relationships, timeline quality, and report accuracy.

The complete workflow of application deployment, controlled security testing, log collection, public-data assessment, TF-IDF feature extraction, Cosine Similarity calculation, contextual event correlation, incident reconstruction, evidence storage, LLM-assisted summarization, and final validation is demonstrated.

The final project provides a practical AI for Cybersecurity implementation focused on similarity-based security log correlation and LLM-assisted incident reconstruction. Its results demonstrate how text similarity and evidence-based analysis can assist incident investigation, while documenting the limitations of textual similarity and the need for contextual validation.