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

Isolation Forest-Based Detection of SQL Injection Attacks Against OWASP WebGoat Through HTTP Request Anomaly Analysis

Description

Web applications use HTTP requests to provide authentication, data retrieval, user interaction, and other application functionalities. These requests contain behavioral characteristics such as HTTP methods, URI structures, request parameters, header information, and payload characteristics that can be analyzed for security monitoring.

If malicious requests exhibit behavioral characteristics that differ from normal application traffic, detection mechanisms based only on predefined signatures or known attack patterns may fail to identify certain variations. Behavioral anomaly detection provides an additional approach by learning the characteristics of normal HTTP requests and identifying requests that significantly deviate from the established behavioral pattern.

In this use case, OWASP WebGoat is deployed within an isolated laboratory environment. WebGoat is an intentionally vulnerable web application designed for security education and controlled application security testing. It provides a suitable environment for generating legitimate requests and testing a designated SQL injection vulnerability scenario.

A public HTTP request dataset is used as the existing data source for the machine-learning stage. Normal HTTP request records are selected and processed to establish the behavioral characteristics required for model training. The dataset is obtained from an existing public source rather than manually created for this project.

Isolation Forest is used as the machine-learning algorithm because it can identify observations that differ from the learned normal behavioral population. The model is trained using the selected normal HTTP request behavior and is not directly trained on the controlled SQL injection requests used during validation.

A controlled SQL injection test is then performed against the designated WebGoat lesson in the local laboratory. The resulting HTTP request is captured and processed using the same feature-extraction procedure used for the training data. The trained Isolation Forest model evaluates the request and generates an anomaly prediction and anomaly score.

The purpose of this experiment is to evaluate whether the behavioral characteristics of controlled SQL injection requests differ from the learned normal HTTP request population. Isolation Forest identifies anomalous behavior; the security tester must correlate the model output with the known test request to determine whether the anomaly corresponds to the controlled SQL injection activity.

The complete behavioral-anomaly detection workflow is:

Public HTTP Request Dataset → Normal Request Selection → Data Preprocessing → Behavioral Feature Extraction → Isolation Forest Training → Normal HTTP Behavior Learning → OWASP WebGoat → Controlled SQL Injection Test → HTTP Request Capture → Feature Extraction → Isolation Forest Analysis → Anomaly Identification → SQL Injection Test Validation

Existing Security Problem

Application: OWASP WebGoat

OWASP WebGoat is the target web application in this use case. It provides intentionally vulnerable web functionality for learning, security testing, and controlled experimentation.

The application is deployed within an authorized, isolated laboratory environment. The designated SQL injection lesson is used to generate controlled test requests and evaluate the behavioral anomaly-detection workflow.

Existing Problem :

Web applications frequently accept user-supplied values through HTTP request parameters and other input fields. If application code handles these values unsafely, an attacker may attempt to manipulate database queries by supplying SQL syntax through an input field or request parameter.

Traditional detection mechanisms may rely on predefined signatures, known SQL injection patterns, or specific malicious strings. Such approaches may not identify every variation of an attack, particularly when a request uses an unfamiliar payload or differs from previously known patterns.

Behavioral anomaly detection provides an additional layer of analysis by evaluating the characteristics of incoming requests and identifying deviations from the learned normal request population.

The security problem is:
Web Application
→
Normal HTTP Request Activity
→
User-Supplied Input Processing
→
SQL Injection Test Request
→
Abnormal Request Characteristics
→
Potentially Malicious Input
→
Previously Unseen Request Variation
→
Security Detection Requirement

The proposed solution processes an existing public HTTP request dataset, selects normal request behavior, and trains an Isolation Forest model using the extracted behavioral features. Newly captured WebGoat requests are processed through the same feature-extraction workflow and evaluated by the trained model.

Attack

Specific Attack: Controlled SQL Injection Attack Against OWASP WebGoat

The controlled attack scenario evaluates whether an HTTP request containing SQL injection test input exhibits behavioral characteristics that differ from normal HTTP requests.

The test is performed only against the designated vulnerable lesson in the local WebGoat application. The objective is to generate a controlled request that can be captured, analyzed, and compared with the normal request behavior learned by the machine-learning model.

The experiment does not assume that every SQL injection request will automatically be classified as anomalous. The detection outcome depends on the features extracted from the requests, the normal training data, and the Isolation Forest model configuration.

Attack Behavior :
Authorized Test Client
→
OWASP WebGoat Application
→
Normal HTTP Request
→
Designated SQL Injection Lesson
→
Controlled SQL Injection Test Input
→
HTTP Request Generation
→
HTTP Request Capture
→
Behavioral Feature Extraction
→
Isolation Forest Analysis
→
Anomaly Prediction and Score
→
Comparison with Known Test Activity
→
Controlled Attack Detection Evaluation

Security Concept

Behavioral Anomaly Detection and Web Application Security Testing

The primary security concept is Behavioral Anomaly Detection combined with controlled Web Application Security Testing.

The first objective is to establish a behavioral representation of normal HTTP request activity using existing public request data. Relevant request characteristics are processed into numerical features that can be evaluated by a machine-learning algorithm.

The second objective is to identify HTTP requests that differ from the learned normal behavioral population. Isolation Forest evaluates the processed features and generates anomaly predictions and scores for new observations.

The third objective is to validate the model's output against a known SQL injection test performed in WebGoat. This comparison helps determine whether the model identifies the controlled attack requests as anomalous and reveals the limitations of using behavioral features for attack detection.

The assessment follows:
Public HTTP Request Data Review
→
Normal Request Selection
→
Data Preprocessing
→
Behavioral Feature Extraction
→
Isolation Forest Training
→
Normal HTTP Behavior Baseline
→
Web Application Security Testing
→
Controlled SQL Injection Request
→
Attack Request Feature Extraction
→
Anomaly Score Generation
→
Behavioral Anomaly Identification
→
Attack Validation

Defensive Mechanism

The security concept defines the overall security strategy.

The following are the specific defensive mechanisms implemented in this use case.

Normal Behavioral Baseline :

Normal HTTP request characteristics are processed to establish the behavioral representation required by the anomaly-detection model.

Purpose: Establish a reference representation of normal HTTP request behavior.

Isolation Forest Anomaly Detection

Isolation Forest evaluates request features and identifies observations that differ from the learned normal behavioral population.

Purpose
  • Identify HTTP requests that exhibit anomalous behavioral characteristics.

Consistent Feature Extraction

The same preprocessing and feature-extraction procedure is applied to the public training data and newly captured WebGoat requests.

Purpose
  • Ensure that training and detection requests are represented consistently.

HTTP Request Monitoring

HTTP requests generated during normal application activity and controlled SQL injection testing are captured for behavioral analysis.

Purpose
  • Provide request-level evidence for anomaly detection and validation.

Controlled Attack Validation

The model's anomaly predictions are compared with the known SQL injection test requests and their captured application responses.

Purpose
  • Evaluate whether the detected anomalies correspond to the controlled attack activity.

Detection Performance Evaluation

Normal and controlled attack requests are compared against the model predictions to identify correct detections, false positives, and missed attack requests.

Purpose
  • Measure the practical effectiveness and limitations of the anomaly-detection workflow.

Security Tools

Vulnerable Web Application: OWASP WebGoat

OWASP WebGoat provides the intentionally vulnerable web application environment used to generate normal HTTP activity and controlled SQL injection test requests.

Purpose
  • Provide the web application testing environment.
  • Generate legitimate application requests.
  • Perform the controlled SQL injection test.
  • Validate the application behavior during testing.

Machine-Learning Environment: Python

Python provides the primary environment for dataset processing, feature extraction, model training, anomaly scoring, and result analysis.

Purpose
  • Implement the machine-learning workflow.
  • Process HTTP request features.
  • Analyze anomaly-detection results.

Machine-Learning Library: Scikit-learn

Scikit-learn provides the Isolation Forest implementation used for behavioral anomaly detection.

Purpose
  • Configure and train the Isolation Forest model.
  • Generate anomaly predictions.
  • Calculate and analyze anomaly scores.

Data Processing Tool: Pandas

Pandas is used to load, filter, transform, and organize the existing public HTTP request records.

Purpose
  • Process request records.
  • Select normal behavioral data.
  • Prepare model input features.

Numerical Processing Tool: NumPy

NumPy supports the numerical transformations required during feature preparation and model processing.

Purpose
  • Perform numerical feature operations.
  • Prepare numerical model inputs.
  • Support efficient feature processing.

API and HTTP Testing Tool: OWASP ZAP

OWASP ZAP is used to inspect and capture HTTP communication during the controlled WebGoat security assessment.

Purpose
  • Inspect HTTP requests and responses.
  • Capture normal and controlled attack traffic.
  • Preserve HTTP traffic evidence for analysis.

HTTP Request Tool: cURL

cURL is used to generate and reproduce authorized HTTP requests against the local application where appropriate.

Purpose
  • Send legitimate HTTP requests.
  • Reproduce controlled test requests.
  • Inspect request and response behavior.

Security Testing Platform: Kali Linux

Kali Linux provides the controlled security-testing environment used to interact with the WebGoat application and inspect HTTP traffic.

Purpose
  • Execute authorized application security tests.
  • Generate controlled test requests.
  • Support request inspection and validation.

Application and Machine-Learning Platform: Ubuntu Linux

Ubuntu provides the local environment for running WebGoat and the machine-learning workflow, depending on the laboratory deployment configuration.

Purpose
  • Host the application environment.
  • Execute Python and machine-learning processing.
  • Support local security experimentation.

Virtualization Platform: VirtualBox

VirtualBox provides the isolated laboratory environment used to host the application and security-testing systems.

Purpose
  • Host isolated virtual machines.
  • Separate application and testing environments.
  • Restrict testing to the authorized laboratory network.

Data Source: Public HTTP Request Dataset

An existing public HTTP request dataset provides the request records used to establish the normal behavioral population for model training.

Purpose
  • Provide existing HTTP request records.
  • Support normal request selection.
  • Provide data for behavioral feature extraction and model training.

Visualization Tool: Matplotlib

Matplotlib is used to visualize anomaly scores and summarize the model's evaluation results.

Purpose
  • Visualize anomaly-score distributions.
  • Compare normal and controlled attack observations.
  • Present evaluation findings.

Process

STEP 01

Prepare the Isolated Web Application Security Testing Environment

  • Create an isolated cybersecurity laboratory using VirtualBox.
  • Configure Ubuntu as the application and machine-learning environment.
  • Configure Kali Linux as the controlled security-testing system.
  • Establish controlled network communication between the virtual machines where remote access is required.
  • Verify that the application can be accessed only through the intended laboratory network.
  • Confirm that all application security testing is restricted to the authorized environment.
Tools: VirtualBox + Ubuntu Linux + Kali Linux
STEP 02

Deploy the OWASP WebGoat Application

  • Deploy OWASP WebGoat within the controlled laboratory environment.
  • Configure the required application components using the selected installation method.
  • Start the WebGoat application.
  • Verify that the application is operational.
  • Confirm that the designated SQL injection lesson is available.
  • If Kali Linux must access WebGoat remotely, configure application binding and firewall restrictions for the private laboratory interface only. Do not expose the intentionally vulnerable application to the public internet.
  • Record the initial application configuration.
Tools: OWASP WebGoat + Ubuntu Linux + VirtualBox
STEP 03

Establish the Application Functionality Baseline

  • Access WebGoat using the authorized laboratory client.
  • Open the application functionality required for the security assessment.
  • Perform legitimate application operations.
  • Generate normal HTTP requests through the intended application functionality.
  • Observe the corresponding request and response behavior.
  • Use the captured requests to understand the structure of normal application traffic.
  • Preserve representative normal application requests for comparison during the experiment.
Tools: OWASP WebGoat + cURL + OWASP ZAP
STEP 04

Identify and Validate the Application Network Exposure

  • Identify the authorized WebGoat host within the laboratory network.
  • Perform controlled service discovery against the designated laboratory host.
  • Identify the application service port and verify whether it is reachable from the testing environment.
  • Confirm that the application is not unintentionally accessible through external network interfaces.
  • Record the application network configuration.
  • Compare the observed service exposure with the intended isolated laboratory architecture.
Tools: Nmap + Kali Linux + VirtualBox
STEP 05

Prepare the Public HTTP Request Dataset

  • Obtain the existing public HTTP request dataset required for the machine-learning experiment.
  • Load the available request records into the Python processing environment.
  • Review the available fields and determine which attributes can support request-level behavioral analysis.
  • Identify the information required for consistent feature extraction.
  • Preserve the original data structure before applying preprocessing.
  • Verify that the selected data contains sufficient information to establish a usable normal request population.
Tools: Python + Pandas
STEP 06

Select Normal HTTP Request Behavior

  • Review the available HTTP request records and identify records suitable for representing normal request behavior.
  • Select the normal records required to establish the behavioral baseline.
  • Exclude records identified as attacks from the normal training set when the dataset provides reliable labels or other evidence for identifying them.
  • Do not include the controlled SQL injection requests used during validation in the normal training data.
  • Preserve the request attributes required for feature extraction.
  • Record the selection criteria and the number of request records retained for training.
Tools: Python + Pandas
STEP 07

Preprocess the Request Data

  • Clean the selected HTTP request records before machine-learning processing.
  • Review missing, inconsistent, or malformed attributes.
  • Handle missing values and inconsistent representations where required.
  • Convert relevant categorical or textual attributes into numerical representations suitable for the selected feature-extraction approach.
  • Maintain a consistent preprocessing procedure for later application traffic.
  • Record the preprocessing configuration so the same transformations can be applied to captured WebGoat requests.
  • Verify that the processed data is suitable for feature extraction.
Tools: Python + Pandas + NumPy
STEP 08

Extract Behavioral Features

  • Identify relevant behavioral characteristics from the processed HTTP request records.
  • Depending on the fields available in the dataset, extract features such as HTTP method, URI structure, request length, parameter characteristics, and other request-level attributes.
  • Use a consistent feature representation that can also be produced from captured WebGoat traffic.
  • Convert the selected characteristics into numerical features.
  • Avoid assuming that every feature is available in every dataset or captured request.
  • Preserve the feature definitions and processing configuration.
  • Verify that the resulting feature matrix is suitable for Isolation Forest training.
Tools: Python + Pandas + NumPy
STEP 09

Train the Isolation Forest Model

  • Configure the Isolation Forest algorithm using Scikit-learn.
  • Provide the processed normal request features to the model.
  • Train the model using the selected normal HTTP request population.
  • Do not directly train the model on the controlled SQL injection request used for validation.
  • Configure relevant model parameters, including the contamination setting where appropriate for the selected experiment.
  • Generate anomaly predictions and scores for the training observations.
  • Review the model output and confirm that the training data can be processed successfully.
Tools: Python + Scikit-learn + NumPy
STEP 10

Establish the Normal Behavioral Baseline

  • Review the Isolation Forest results generated from the normal request data.
  • Examine the anomaly-score distribution and identify the model's behavior on the training observations.
  • Record the model configuration and preprocessing parameters.
  • Preserve the trained model for subsequent request analysis.
  • Confirm that the same feature-extraction process will be applied to newly captured WebGoat requests.
  • Document the limitations of using public HTTP request data to represent the behavior of a different application.
  • Establish the behavioral baseline for the controlled experiment.
Tools: Python + Scikit-learn + Matplotlib
STEP 11

Validate Normal WebGoat HTTP Activity

  • Use the authorized client to perform legitimate WebGoat application operations.
  • Capture the corresponding HTTP requests and responses.
  • Extract behavioral features from the legitimate application requests.
  • Apply the same preprocessing and feature-extraction procedure used for the training data.
  • Provide the processed requests to the trained Isolation Forest model.
  • Review the generated anomaly predictions and scores.
  • Record whether legitimate WebGoat requests are classified as anomalous.
  • This step establishes a practical comparison point for the controlled SQL injection test.
Tools: OWASP WebGoat + OWASP ZAP + Python + Scikit-learn
STEP 12

Perform the Controlled SQL Injection Test

  • Access the designated SQL injection lesson in the local WebGoat application.
  • Use the intended lesson functionality to generate a controlled SQL injection test request.
  • Keep the test within the authorized WebGoat environment.
  • Observe the HTTP request generated by the application interaction.
  • Capture the request using OWASP ZAP or the selected HTTP inspection method.
  • Record the relevant request and response information.
  • Do not perform the test against external or production applications.
Tools: OWASP WebGoat + Kali Linux + OWASP ZAP
STEP 13

Capture and Validate the SQL Injection Test Request

  • Inspect the captured HTTP request generated during the controlled test.
  • Record the available HTTP method, URI, parameters, request headers, and relevant response information.
  • Confirm that the request corresponds to the intended WebGoat SQL injection lesson.
  • Compare the request structure with representative legitimate application requests.
  • Preserve the captured traffic as controlled security-testing evidence.
  • Ensure that the captured request is suitable for the same feature-extraction procedure used during model training.
Tools: OWASP ZAP + OWASP WebGoat + Kali Linux
STEP 14

Extract Behavioral Features from the Test Request

  • Process the captured SQL injection test request using the same preprocessing procedure used for the training data.
  • Extract the behavioral characteristics supported by the captured request.
  • Convert the selected characteristics into the numerical feature representation required by the trained Isolation Forest model.
  • Maintain the same feature order and transformation procedure.
  • Handle unavailable attributes consistently rather than inventing values.
  • Verify that the resulting feature vector is compatible with the trained model.
  • Preserve the feature representation for anomaly analysis.
Tools: Python + Pandas + NumPy
STEP 15

Perform Isolation Forest Analysis

  • Provide the processed SQL injection test-request features to the trained Isolation Forest model.
  • Generate the anomaly prediction for the request.
  • Calculate the corresponding anomaly score.
  • Compare the result with the scores and predictions observed for normal request traffic.
  • Determine whether the controlled test request is classified as anomalous by the model.
  • Record the model output as detection evidence.
  • Do not interpret an anomaly prediction alone as proof that the request is a SQL injection attack.
Tools: Python + Scikit-learn + NumPy
STEP 16

Validate the Behavioral Anomaly Detection Result

  • Review the Isolation Forest prediction and anomaly score for the controlled test request.
  • Compare the model output with the captured request and the known test activity.
  • Determine whether the request was identified as anomalous.
  • Review the behavioral features associated with the observed deviation.
  • Check whether legitimate WebGoat requests also produce anomalous results.
  • Record any false positives or missed attack requests observed during testing.
  • Preserve the anomaly results and captured traffic as evidence for the evaluation.
Tools: Python + Scikit-learn + OWASP ZAP + OWASP WebGoat
STEP 17

Analyze and Correlate the Security Findings

  • Review the normal HTTP request data used for model training.
  • Review the legitimate WebGoat requests captured during application testing.
  • Review the controlled SQL injection test request.
  • Compare the extracted behavioral features and Isolation Forest anomaly scores.
  • Correlate the model output with the known test activity.
  • Identify whether the observed anomaly corresponds to the controlled SQL injection request or whether the result is inconclusive.
  • Document the technical findings, false positives, missed detections, and limitations associated with the selected dataset and feature representation.
Tools: Python + Pandas + Scikit-learn + Matplotlib + OWASP WebGoat
STEP 18

Perform Final Behavioral Detection Validation and Security Review

  • Repeat the normal application activity analysis where required.
  • Repeat the controlled SQL injection test within the authorized WebGoat environment.
  • Process the captured requests using the same feature-extraction workflow.
  • Compare the Isolation Forest results for normal and controlled attack traffic.
  • Review the captured HTTP evidence and anomaly-score distributions.
  • Evaluate whether the model distinguishes the test requests from the learned normal behavioral population.
  • Record the final detection results, false positives, missed detections, and technical limitations.
  • Document possible improvements to the dataset selection, feature extraction, model configuration, and evaluation process.
  • Finalize the behavioral anomaly-detection assessment.
Tools: OWASP WebGoat + OWASP ZAP + Python + Pandas + Scikit-learn + Matplotlib + Kali Linux + Ubuntu Linux + VirtualBox

Outcome

OWASP WebGoat is deployed within an isolated laboratory environment and provides the intentionally vulnerable application required for controlled SQL injection testing.

The application network exposure is identified and validated within the authorized laboratory, establishing a controlled environment for application security experimentation.

An existing public HTTP request dataset is processed without manually creating a training dataset, providing the request records required to establish the normal behavioral population for the machine-learning experiment.

Normal request characteristics are transformed into numerical behavioral features, creating a consistent representation suitable for Isolation Forest analysis.

The Isolation Forest model is trained using the selected normal request behavior and establishes a behavioral baseline without directly training on the controlled SQL injection request used for validation.

Normal WebGoat application requests are captured and processed using the same feature-extraction workflow, providing a practical assessment of the detection pipeline's compatibility with the target application.

A controlled SQL injection test is performed against the designated WebGoat lesson, and the resulting HTTP request is captured for behavioral analysis.

The captured test request is processed and evaluated by the trained Isolation Forest model to determine whether its behavioral characteristics differ from the learned normal request population.

The anomaly prediction is correlated with the known controlled test activity, and the results are reviewed for correct detections, false positives, and missed attack requests. The experiment evaluates anomaly detection rather than assuming that every SQL injection request will be identified.

The complete workflow of public HTTP request-data processing, normal behavior learning, Isolation Forest training, WebGoat testing, controlled SQL injection request capture, behavioral feature extraction, anomaly scoring, attack correlation, and final security validation is demonstrated within the isolated laboratory environment.