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

BiLSTM-Based Detection of Cross-Site Request Forgery (CSRF) Attacks in OWASP NodeGoat Through Sequential HTTP Request Analysis and Controlled Attack Simulation

Description

Web applications allow authenticated users to perform operations such as updating profile information, modifying account settings, and managing personal resources. These operations are commonly performed through HTTP requests sent by the user's browser to the application server.

Cross-Site Request Forgery (CSRF) is a web application attack in which an attacker attempts to cause an authenticated user's browser to send an unwanted request to an application where the user is already logged in. If the application does not adequately validate the legitimacy of state-changing requests, the server may process the forged request using the victim's existing authentication session.

Individual HTTP requests may not always provide sufficient context to distinguish legitimate user activity from suspicious request sequences. An additional detection approach is to examine the order and characteristics of requests associated with an application session.

In this use case, OWASP NodeGoat is deployed within an isolated cybersecurity laboratory using Ubuntu Linux and Kali Linux virtual machines. NodeGoat provides an intentionally vulnerable Node.js web application that can be used for controlled web security testing.

A publicly available, labelled HTTP-request or web-attack dataset is investigated as the initial data source for machine-learning development. The dataset is inspected to verify whether its labels and request attributes are suitable for the intended classification task. The selected records are preprocessed and transformed into numerical representations of HTTP-request sequences.

A Bidirectional Long Short-Term Memory (BiLSTM) model is used to learn relationships within the prepared request sequences and classify them according to the categories supported by the training data.

A controlled CSRF attack is then performed against the local OWASP NodeGoat application. Nmap is used to identify and verify the expected laboratory service exposure, while Wireshark and OWASP ZAP support traffic inspection and evidence collection. The captured HTTP activity is processed through the same feature-extraction pipeline used during model development.

The trained BiLSTM model evaluates compatible request sequences. Its predictions are compared with the known laboratory test conditions to assess whether sequential HTTP-request analysis can help identify suspicious CSRF-related activity.

The complete workflow is:
Public HTTP-Request Dataset
→
Dataset Suitability Assessment
→
Request-Sequence Preparation
→
Data Preprocessing
→
Sequential Feature Extraction
→
BiLSTM Training
→
Model Evaluation
→
OWASP NodeGoat Deployment
→
Nmap Service Discovery
→
Normal HTTP Traffic Capture
→
Controlled CSRF Attack Simulation
→
HTTP Traffic Analysis
→
BiLSTM Classification
→
Detection Result Validation
→
Performance Evaluation

Existing Security Problem

Application: OWASP NodeGoat

OWASP NodeGoat is an intentionally vulnerable Node.js application designed for learning and testing web application security risks.

It provides a controlled environment for investigating web vulnerabilities, including CSRF-related scenarios supported by the deployed version.

The application is hosted on Ubuntu Linux within the authorized laboratory. Kali Linux is used as the security-testing system.

Existing Problem

Web applications commonly accept state-changing requests from authenticated users. If a server does not adequately validate whether a state-changing request was intentionally initiated by the user, an attacker may attempt to make the user's browser submit a forged request.

A CSRF request may contain ordinary HTTP methods, paths, and parameters. Consequently, examining an isolated request may not provide enough context to distinguish legitimate activity from suspicious activity.

Traditional security controls, including CSRF tokens, appropriate cookie settings, and origin validation, remain essential prevention mechanisms. Machine-learning-based detection provides an additional analysis approach rather than a replacement for these controls.

The security problem is :
Authenticated Web Application
→
Normal User Request Sequences
→
State-Changing HTTP Requests
→
Potential Forged Request
→
Possible Unauthorized State Change
→
HTTP Activity Recorded
→
Limited Context from Individual Requests
→
Sequential Request Analysis Required
→
Suspicious CSRF-Related Activity Detection

The proposed solution introduces a BiLSTM-based classification layer that evaluates request sequences, followed by controlled attack validation against the local application.

Attack

Specific Attack: Controlled Cross-Site Request Forgery (CSRF) Attack

The controlled attack evaluates whether a forged request can cause an authenticated user's browser to submit an unwanted state-changing operation to the deliberately vulnerable local OWASP NodeGoat application.

The attack is performed only inside the isolated VirtualBox laboratory using a dedicated test account and non-sensitive test data.

The test scenario uses the CSRF functionality available in the deployed NodeGoat version. The resulting request and response evidence is captured for subsequent analysis.

The known attack condition is recorded separately from the model prediction so that the detection result can be evaluated objectively.

Attack Behavior :
Controlled Laboratory Environment
→
Authenticated Test User
→
Legitimate NodeGoat Session
→
Normal Profile Request
→
Controlled CSRF Test Page
→
Forged State-Changing Request
→
Local NodeGoat Receives Request
→
Application Response Observed
→
Network and HTTP Traffic Captured
→
Sequential Feature Extraction
→
BiLSTM Classification
→
Prediction Compared with Test Ground Truth
→
Detection Result Recorded

Security Concept

Sequential HTTP Request Analysis Using BiLSTM

The primary security concept is sequential HTTP-request classification for CSRF-related attack detection.

The project investigates whether the order and characteristics of HTTP requests provide useful information for distinguishing normal request sequences from CSRF-related activity represented in the training and evaluation data.

HTTP Request-Sequence Representation : HTTP requests are collected from the selected dataset and the controlled laboratory application. Where the source data permits it, requests are grouped into meaningful sequences using available session identifiers, timestamps, client information, or other documented attributes.

BiLSTM-Based Classification : A Bidirectional Long Short-Term Memory model processes the numerical request sequences and learns relationships between sequence elements. The model produces predictions for the classification categories represented in its training data.

Controlled CSRF Attack Validation : The trained model is tested using traffic generated during the controlled CSRF scenario. Its predictions are compared with the known laboratory test conditions and verified labels.

The assessment follows:
Public HTTP-Request Dataset
→
Dataset Suitability Assessment
→
Normal and Supported Attack-Class Selection
→
Request-Sequence Construction
→
Data Preprocessing
→
Sequential Feature Extraction
→
BiLSTM Model Training
→
Model Evaluation
→
Controlled CSRF Attack Simulation
→
HTTP Traffic Capture
→
Sequence Feature Extraction
→
BiLSTM Prediction
→
Comparison with Ground Truth
→
Detection Performance Analysis

Defensive Mechanism

The security concept defines the overall detection strategy.

The following defensive mechanisms support the implementation.

HTTP Traffic Collection :

HTTP requests generated during legitimate application use and controlled testing are captured for analysis.

Purpose: Preserve the request evidence required for sequence preparation and detection evaluation.

Request-Sequence Construction

Compatible HTTP requests are organized into sequences using the available session and timing information.

Purpose
  • Represent request order and related characteristics for sequential analysis.

BiLSTM-Based Classification

The BiLSTM model classifies request sequences according to the categories represented in the verified training data.

Purpose
  • Evaluate whether sequential request characteristics can help identify suspicious activity.

Consistent Feature Extraction

The same fitted preprocessing and feature-extraction pipeline is applied to training records and compatible test traffic.

Purpose
  • Ensure that training and detection inputs use a consistent representation.

Network Service Discovery

Nmap identifies the expected application service and verifies its accessibility within the authorized laboratory.

Purpose
  • Confirm the laboratory application's expected network exposure.

Network Traffic Inspection

Wireshark captures and examines network traffic associated with normal activity and controlled testing.

Purpose
  • Provide supporting traffic evidence and help establish the sequence and timing of laboratory communication.

HTTP Request Inspection

OWASP ZAP and browser developer tools are used to inspect relevant HTTP requests and responses.

Purpose
  • Extract application-layer request information required for security analysis.

Controlled Attack Validation

The controlled CSRF scenario is compared with the model's predictions and the observed application behavior.

Purpose
  • Assess whether the detection workflow identifies the intended test activity.

Detection Performance Evaluation

The classifier is evaluated against appropriate held-out data and verified labels.

Purpose
  • Measure classification performance and identify false positives, false negatives, and limitations.

Security Tools

Primary Vulnerable Web Application: OWASP NodeGoat

OWASP NodeGoat provides the intentionally vulnerable Node.js application used for the controlled CSRF test.

Purpose
  • Provide the local web application.
  • Support controlled CSRF testing.
  • Generate legitimate and attack-related HTTP activity.
  • Provide an environment for validating the detection workflow.

Security Testing Platform: Kali Linux

Kali Linux is used as the controlled security-testing system.

Purpose
  • Access the authorized laboratory application.
  • Perform controlled CSRF testing.
  • Capture and review HTTP activity.
  • Preserve evidence for detection validation.

Application and Detection Environment: Ubuntu Linux

Ubuntu hosts the local application and supports the Python-based detection workflow.

Purpose
  • Run the application and analysis components.
  • Process captured HTTP traffic.
  • Execute model training and inference.

Virtualization Platform: VirtualBox

VirtualBox provides the isolated laboratory infrastructure.

Purpose
  • Host Ubuntu and Kali Linux virtual machines.
  • Separate the target application and testing system.
  • Support controlled network communication.

Network Discovery Tool: Nmap

Nmap identifies services exposed by the authorized laboratory target.

Purpose
  • Discover the local NodeGoat service.
  • Verify the expected application port.
  • Document laboratory service exposure.

Network Traffic Analysis Tool: Wireshark

Wireshark captures and examines network packets exchanged during laboratory testing.

Purpose
  • Capture authorized laboratory traffic.
  • Inspect packet timing and network-level communication.
  • Support comparison of normal and attack-test activity.

HTTP Traffic Inspection Tool: OWASP ZAP

OWASP ZAP supports inspection of HTTP requests and responses during authorized web application testing.

Purpose
  • Examine HTTP methods, paths, parameters, and responses.
  • Preserve application-layer traffic evidence.
  • Support analysis of the controlled CSRF scenario.

Browser Inspection Tool: Browser Developer Tools

Browser developer tools provide visibility into requests generated by the application and controlled test page.

Purpose
  • Inspect HTTP requests and responses.
  • Review request methods and parameters.
  • Associate application actions with their corresponding requests.

Programming Language: Python

Python provides the main implementation environment.

Purpose
  • Process the public dataset.
  • Construct request sequences.
  • Integrate preprocessing, model training, and classification.
  • Automate detection evaluation.

Machine-Learning Framework: PyTorch

PyTorch is used to implement and train the BiLSTM model.

Purpose
  • Define the BiLSTM architecture.
  • Train the model on prepared sequences.
  • Generate predictions for test sequences.

Data Processing Tool: Pandas

Pandas is used to load, inspect, filter, and organize request records and dataset metadata.

Purpose
  • Inspect dataset fields and labels.
  • Prepare records for model development.
  • Organize classification and evaluation results.

Numerical Processing Tool: NumPy

NumPy supports numerical transformations required for sequence preparation.

Purpose
  • Prepare numerical arrays.
  • Support feature transformations.
  • Assist with model-input preparation.

Dataset Evaluation Tool: Scikit-learn

Scikit-learn provides dataset-splitting utilities and classification metrics.

Purpose
  • Prepare training and evaluation partitions.
  • Calculate precision, recall, and F1-score.
  • Generate confusion-matrix results.

Local Data Storage: SQLite

SQLite can store request metadata, model predictions, and evaluation results.

Purpose
  • Preserve detection evidence.
  • Associate predictions with test records.
  • Support later comparison and review.

Process

STEP 01

Prepare the Isolated Laboratory Environment

  • Create the cybersecurity laboratory using VirtualBox.
  • Configure Ubuntu Linux as the application and detection environment.
  • Configure Kali Linux as the security-testing system.
  • Establish controlled network communication between the virtual machines.
  • Verify that Kali Linux can reach the authorized Ubuntu laboratory system.
  • Confirm that testing is restricted to the local environment.
Tools: VirtualBox + Ubuntu Linux + Kali Linux
STEP 02

Deploy OWASP NodeGoat

  • Obtain the official OWASP NodeGoat project and follow its documented local setup requirements.
  • Configure the application and its required database components.
  • Start the application.
  • Verify that the application loads successfully.
  • Confirm that the relevant profile functionality is available.
  • Record the application version and configuration used in the experiment.
Tools: OWASP NodeGoat + Ubuntu Linux + VirtualBox
STEP 03

Establish Normal Application Activity

  • Access NodeGoat using the designated laboratory account.
  • Perform legitimate application operations.
  • Generate normal navigation and profile-related requests.
  • Inspect the corresponding HTTP requests and responses.
  • Record available request methods, paths, timestamps, and other relevant attributes.
  • Preserve representative normal activity for comparison with the controlled attack.
Tools: OWASP NodeGoat + Browser Developer Tools + OWASP ZAP
STEP 04

Identify the Application's Network Exposure

  • Identify the authorized Ubuntu laboratory IP address.
  • Use Nmap to discover the expected NodeGoat service port.
  • Verify that the service is reachable from the intended laboratory network.
  • Record the detected service and port.
  • Compare the observed exposure with the intended laboratory configuration.
  • Do not scan external systems or networks.
Tools: Nmap + Kali Linux
STEP 05

Capture Baseline Network Traffic

  • Start Wireshark on the appropriate laboratory network interface.
  • Generate legitimate requests against NodeGoat.
  • Observe the corresponding network communication.
  • Record timestamps and other available packet metadata.
  • Where application-layer visibility is required, use OWASP ZAP or browser developer tools to inspect the HTTP requests.
  • Preserve the baseline evidence for subsequent analysis.
Tools: Wireshark + OWASP ZAP + Browser Developer Tools
STEP 06

Identify and Inspect the Public Dataset

  • Obtain an existing public HTTP-request or web-attack dataset.
  • Review the dataset documentation, licence, feature fields, and label definitions.
  • Determine whether it contains verified CSRF-labelled records or compatible request sequences.
  • Check whether the data includes timestamps, session identifiers, request ordering, or other sequence-related information.
  • Compare the dataset with the attributes obtainable from NodeGoat.
  • Document any differences that could affect training and detection.
Tools: Python + Pandas
STEP 07

Validate Dataset Suitability

  • Inspect the available normal and attack-related classes.
  • Confirm that the labels are supported by the dataset documentation or verified ground truth.
  • Determine whether CSRF is represented as a distinct classification category.
  • Do not relabel generic malicious requests as CSRF without independent evidence.
  • If suitable CSRF-labelled data is unavailable, document the limitation and obtain an appropriate public source before claiming CSRF-specific training.
Tools: Python + Pandas + Scikit-learn
STEP 08

Clean and Preprocess the Dataset

  • Load the selected records into Python.
  • Identify missing values, invalid records, duplicate entries, and inconsistent formatting.
  • Clean or exclude unsuitable records where necessary.
  • Normalize the supported request attributes.
  • Preserve the original labels and source records.
  • Document the preprocessing operations for reproducibility.
Tools: Python + Pandas + NumPy
STEP 09

Construct HTTP Request Sequences

  • Identify the fields available for establishing request order and grouping.
  • Use documented timestamps, session identifiers, or other valid grouping attributes.
  • Arrange related requests into chronological sequences.
  • Avoid grouping unrelated sessions into the same sequence.
  • Define a consistent sequence length and a strategy for handling shorter or longer sequences.
  • Preserve the association between each sequence and its original records.
Tools: Python + Pandas + NumPy
STEP 10

Extract Sequential Features

  • Identify relevant HTTP-request attributes supported by the selected data.
  • Depending on the available fields, features may include request method, normalized path characteristics, parameter presence, response status, timing intervals, and request-order indicators.
  • Convert the selected attributes into numerical representations.
  • Fit encoders and other preprocessing components using the training data only.
  • Apply the same fitted transformations to evaluation and laboratory traffic.
  • Verify that the resulting sequences are compatible with the BiLSTM input format.
Tools: Python + Pandas + NumPy
STEP 11

Prepare Training and Evaluation Data

  • Split the prepared dataset into training, validation, and test partitions.
  • Preserve the verified classification labels.
  • Where possible, use session-aware or group-aware splitting to reduce data leakage between related sequences.
  • Check the distribution of the available classes.
  • Ensure that test records are not used during model training.
  • Record the data-splitting and evaluation strategy.
Tools: Python + Scikit-learn + Pandas
STEP 12

Build and Train the BiLSTM Model

  • Implement the BiLSTM architecture using PyTorch.
  • Configure the input dimensions to match the prepared request sequences.
  • Define the recurrent layers and classification output.
  • Select an appropriate loss function and optimizer.
  • Train the model using the prepared training sequences and verified labels.
  • Monitor training and validation loss.
  • Save the trained model and fitted preprocessing components.
Tools: Python + PyTorch + NumPy
STEP 13

Evaluate the Trained Model

  • Provide the held-out test sequences to the trained model
  • Generate predictions and compare them with the known labels.
  • Calculate accuracy where appropriate, along with precision, recall, and F1-score.
  • Generate a confusion matrix to examine classification errors.
  • Review false positives and false negatives.
  • Record the actual evaluation results and document dataset limitations.
Tools: Python + PyTorch + Scikit-learn + Pandas
STEP 14

Capture Normal NodeGoat HTTP Traffic

  • Use the authorized laboratory account to perform normal NodeGoat operations.
  • Capture the associated traffic using Wireshark.
  • Inspect the application-layer requests and responses using OWASP ZAP or browser developer tools where required.
  • Record the relevant request attributes and timestamps.
  • Preserve the original traffic evidence.
  • Verify that the collected information is suitable for the established feature-extraction pipeline.
Tools: OWASP NodeGoat + Wireshark + OWASP ZAP + Browser Developer Tools
STEP 15

Perform the Controlled CSRF Attack Simulation

  • Use the local NodeGoat CSRF scenario and a dedicated laboratory test account.
  • Prepare the controlled test page according to the documented scenario.
  • Trigger the forged request only against the local application.
  • Observe whether the application processes the state-changing request.
  • Capture the resulting network traffic using Wireshark and inspect HTTP details using OWASP ZAP or browser developer tools.
  • Record the test time, relevant request details, application response, and known test condition.
Tools: OWASP NodeGoat + Kali Linux + Wireshark + OWASP ZAP
STEP 16

Process and Classify the Captured Traffic

  • Associate captured requests with the known laboratory test window.
  • Apply the same preprocessing and sequence-construction procedures used during model development.
  • Reuse the fitted feature-extraction components.
  • Verify that the laboratory traffic is compatible with the model's input representation.
  • Provide compatible sequences to the trained BiLSTM.
  • Record the predicted categories and available model scores.
  • Preserve references to the original HTTP evidence.
Tools: Python + Pandas + NumPy + PyTorch + OWASP ZAP
STEP 17

Validate the Detection Results

  • Compare model predictions with the known controlled test conditions.
  • Review the original request sequence and the application's response.
  • Record correct classifications, false positives, and false negatives.
  • Determine whether the model recognizes a class that it was actually trained to identify.
  • If the training data does not contain verified CSRF labels, report the result as a limited experiment rather than confirmed CSRF-specific detection.
  • Distinguish successful execution of the attack scenario from successful model detection.
Tools: Python + PyTorch + Scikit-learn + Pandas
STEP 18

Perform Final Security Review

  • Repeat testing with representative normal activity and controlled CSRF test activity.
  • Review dataset suitability, preprocessing consistency, sequence construction, and model evaluation.
  • Compare model predictions with known laboratory test conditions.
  • Examine false-positive and false-negative cases.
  • Review whether the model generalizes from the public dataset to NodeGoat traffic.
  • Document measured results, implementation limitations, and possible improvements.
  • Finalize the assessment without treating machine-learning predictions as a replacement for CSRF prevention controls.
Tools: Python + PyTorch + Scikit-learn + OWASP NodeGoat + Nmap + Wireshark + OWASP ZAP + SQLite

Outcome

OWASP NodeGoat is deployed within an isolated Ubuntu and Kali Linux laboratory, providing an authorized environment for controlled CSRF security testing.

Nmap is used to identify the expected laboratory application service and verify its network accessibility.

Wireshark captures network traffic associated with normal application activity and the controlled CSRF test, providing supporting evidence for traffic analysis.

A public HTTP-request or web-attack dataset is inspected to determine whether its labels and features are suitable for the proposed classification task.

The selected data is preprocessed and transformed into numerical request sequences compatible with the BiLSTM architecture.

The BiLSTM model is trained and evaluated using verified labels, and the actual classification metrics are recorded.

A controlled CSRF attack is performed against the local NodeGoat application using a dedicated test account and non-sensitive laboratory data.

The captured traffic is processed through the established feature-extraction pipeline, and compatible request sequences are evaluated by the trained BiLSTM model.

Detection results are compared with the known laboratory conditions to identify correct classifications, false positives, false negatives, and limitations in generalization.

The complete workflow demonstrates an experimental approach to BiLSTM-based sequential HTTP-request analysis for CSRF-related attack detection, combining public-data investigation, Nmap-based service discovery, Wireshark traffic capture, controlled attack simulation, machine-learning classification, and evidence-based validation.