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

Support Vector Machine-Based Detection of Reintroduced SQL Injection Vulnerabilities in OWASP Juice Shop Through Source-Code Patch Comparison

Description

Enterprise applications commonly use web frameworks and database queries to process user requests, authenticate users, and retrieve application data. OWASP Juice Shop is a deliberately vulnerable web application that can be used to study web application security weaknesses, including SQL Injection.

SQL Injection occurs when an application processes untrusted input in an unsafe manner while constructing database queries. Security protections such as parameterized queries help prevent this vulnerability. However, source-code modifications, incorrect changes to query-handling logic, or the reversal of a security patch may reintroduce a previously fixed vulnerability.

In this use case, OWASP Juice Shop is used as the target application, and source-code versions are compared to identify changes that may weaken SQL Injection protections. A public cybersecurity dataset containing suitable labelled vulnerability-related records is used for machine learning model development and evaluation.

A Support Vector Machine (SVM) classifier is developed using Python and Scikit-learn. Source-code comparison features are extracted using Git, while Semgrep Community Edition (CE) is used to identify potentially unsafe SQL Injection-related code patterns.

Controlled security testing is conducted against the locally deployed application. OWASP ZAP is used to examine application behaviour, and the resulting security findings are compared with the model's predictions. The extracted source-code features must be compatible with the model's training features to ensure meaningful predictions.

The detection workflow also includes dataset preprocessing, model evaluation, security finding verification, and result reporting. A Streamlit dashboard presents classification predictions, evaluation metrics, source-code changes, and security testing findings.

The complete security-validation workflow is:
OWASP Juice Shop
→
Source-Code Version Identification
→
Git Patch Comparison
→
Feature Extraction
→
Public Cybersecurity Dataset
→
SVM Model Training and Evaluation
→
Static Code Analysis
→
Dynamic Application Testing
→
Regression Risk Classification
→
Finding Validation
→
Security Dashboard

Existing Security Problem

Application/Service: OWASP Juice Shop

OWASP Juice Shop is the target web application used to assess SQL Injection security regressions. Its source code provides the basis for examining how modifications to application logic can affect existing security protections.

Existing Problem :

Previously fixed SQL Injection vulnerabilities may reappear when source-code modifications weaken or remove existing security controls. Changes to database query construction can introduce unsafe handling of user input, while inadequate patch verification may allow these changes to go undetected.

Traditional static analysis tools identify suspicious code patterns, but their findings do not necessarily establish whether a particular code modification has reintroduced a previously fixed vulnerability. Manual comparison of source-code versions can also make it difficult to identify subtle security regressions.

The security problem is:
OWASP Juice Shop
→
Existing SQL Injection Protection
→
Source-Code Modification or Patch Reversal
→
Potentially Unsafe Query-Handling Logic
→
Reintroduced SQL Injection Vulnerability
→
Potentially Unauthorized Database Operations
→
Application Security Impact

The proposed solution introduces source-code patch comparison, relevant feature extraction, SVM-based classification, static code analysis, controlled application testing, security finding verification, and post-remediation validation.

Attack

Specific Attack: SQL Injection Vulnerability Reintroduction Through Source-Code Patch Reversal or Modification

The controlled attack scenario evaluates whether modifying or reversing a security-related source-code change can reintroduce an SQL Injection vulnerability into the OWASP Juice Shop application.

The objective is to demonstrate how a source-code modification can weaken existing query-handling protections and determine whether the proposed detection workflow identifies the resulting security regression.

Attack Behavior :
Secured Source-Code Version
→
Identify SQL Injection Protection
→
Modify or Reverse the Relevant Security Patch
→
Introduce a Controlled Vulnerability
→
Compare Source-Code Versions Using Git
→
Analyse Modified Code Using Semgrep CE
→
Test Application Behaviour Using OWASP ZAP
→
Extract Relevant Source-Code Features
→
Classify Potential Regression Risk Using SVM
→
Validate Security Findings
→
Apply Corrective Changes
→
Perform Post-Remediation Testing

Security Concept

Source-Code Security Regression Detection and Machine Learning-Based Classification

The primary security concept is Source-Code Security Regression Detection combined with Machine Learning-Based Classification.

The assessment examines how source-code modifications can weaken existing SQL Injection protections. Git identifies changes between secured and modified source-code versions, while feature extraction prepares relevant code-change characteristics for classification. A Support Vector Machine (SVM) learns patterns from labelled training data and classifies prepared features according to their potential vulnerability risk.

Semgrep CE provides static analysis findings, and OWASP ZAP supports dynamic application testing. These findings help assess the model's predictions. The public dataset must contain suitable labelled records, and the training and prediction features must be compatible. The model's performance on the dataset and its ability to identify regressions in the target application are evaluated separately.

The assessment follows:
Application Architecture Review
→
SQL Injection Protection Identification
→
Source-Code Patch Comparison
→
Feature Extraction and Preparation
→
Public Dataset Preprocessing
→
SVM Model Training and Evaluation
→
Static Code Analysis
→
Dynamic Application Testing
→
Security Regression Classification
→
Finding Validation
→
Corrective Changes
→
Post-Remediation Validation

Defensive Mechanism

Source-Code Patch Comparison

Git compares secured and modified source-code versions to identify changes affecting SQL Injection protections.

Purpose
  • Identify potentially unsafe modifications to previously secured code.

Static Application Security Testing

Semgrep CE scans source code using applicable SQL Injection detection rules.

Purpose
  • Identify potentially unsafe query-handling patterns.

Machine Learning-Based Regression Detection

The SVM classifier analyses prepared source-code and patch-comparison features using patterns learned from labelled training data.

Purpose
  • Classify code changes according to their potential SQL Injection regression risk.

Dynamic Application Security Testing

OWASP ZAP examines the running application through controlled security tests.

Purpose
  • Validate suspected vulnerabilities by examining application behaviour.

Dataset and Model Validation

The labelled dataset, feature preparation process, training procedure, and model evaluation results are reviewed for consistency.

Purpose
  • Ensure that the classifier produces meaningful predictions and that its evaluation is reliable.

Security Finding Verification

SVM predictions are compared with Git differences, Semgrep CE findings, and OWASP ZAP results.

Purpose
  • Support verification of suspected security regressions and identify incorrect predictions.

Risk-Based Prioritization

Potential vulnerabilities are assessed according to their technical evidence, potential impact, and exploitability.

Purpose
  • Prioritize security findings that require corrective action.

SQL Injection Remediation

Unsafe query construction is corrected using appropriate secure query-handling practices, such as parameterized queries where supported.

Purpose
  • Eliminate the identified SQL Injection weakness.

Post-Remediation Validation

Source-code analysis and controlled application testing are repeated after corrective changes.

Purpose
  • Verify that the identified weakness has been addressed without disrupting legitimate application functionality.

Security Tools

Source-Code Version Control Tool: Git

Git is used to maintain source-code versions and compare secured and modified code.

Purpose
  • Maintain source-code version history.
  • Compare secured and modified code.
  • Identify changes affecting security protections.
  • Support source-code feature extraction.
  • Verify corrective changes.

Static Application Security Testing Tool: Semgrep Community Edition (CE)

Semgrep CE analyses source code using applicable security rules to identify potentially unsafe SQL Injection-related patterns.

Purpose
  • Scan source code for suspicious patterns.
  • Identify potentially unsafe query construction.
  • Compare findings across source-code versions.
  • Support security finding verification.
  • Reassess code after remediation.

Dynamic Application Security Testing Tool: OWASP ZAP

OWASP ZAP assesses the running web application to identify security weaknesses through controlled testing.

Purpose
  • Assess the locally deployed application.
  • Test selected application functionality.
  • Identify relevant SQL Injection indicators.
  • Record application-testing findings.
  • Support post-remediation validation.

Machine Learning Framework: Scikit-learn

Scikit-learn provides the SVM classifier and functions for training, prediction, and model evaluation.

Purpose
  • Implement the SVM classification algorithm.
  • Train the model using prepared labelled data.
  • Generate predictions for compatible feature inputs.
  • Evaluate classification performance.
  • Support repeatable model testing.

Programming Language: Python

Python integrates the dataset-processing, source-code feature preparation, machine learning, and reporting components.

Purpose
  • Implement the detection workflow.
  • Process dataset records.
  • Prepare classification features.
  • Integrate model predictions with security findings.
  • Support dashboard development.

Dataset Processing Libraries: Pandas and NumPy

Pandas and NumPy support dataset manipulation and numerical feature preparation.

Purpose
  • Process labelled cybersecurity records.
  • Handle missing and inconsistent values.
  • Prepare numerical features.
  • Support dataset transformation.
  • Assist model evaluation.

Cybersecurity Data Source: Public Cybersecurity Dataset

A suitable public cybersecurity dataset provides labelled vulnerability-related records for model development and evaluation.

Purpose
  • Provide labelled training examples.
  • Support model development.
  • Enable held-out testing.
  • Support classification performance measurement.
  • Help assess the limitations of the available training data.

Security Reporting Tool: Streamlit

Streamlit provides an interactive dashboard for displaying model predictions and security assessment results.

Purpose
  • Display classification predictions.
  • Present model evaluation metrics.
  • Show relevant source-code changes.
  • Display security-tool findings.
  • Summarize validation and remediation status.

Target Application: OWASP Juice Shop

OWASP Juice Shop provides the web application used for controlled SQL Injection security assessment.

Purpose
  • Provide the application under test.
  • Support examination of query-handling logic.
  • Enable controlled vulnerability testing.
  • Support comparison of secured and modified versions.
  • Verify application behaviour after remediation.

Development Platform: Ubuntu Linux

Ubuntu Linux provides the primary development environment for the application, dataset processing, and machine learning workflow.

Purpose
  • Run the development environment.
  • Execute Python-based analysis.
  • Support source-code inspection.
  • Run the required security tools.
  • Support dashboard development.

Security Testing Platform: Kali Linux

Kali Linux provides the security-testing environment for controlled application assessment.

Purpose
  • Execute authorized security tests.
  • Support network and application assessment.
  • Run OWASP ZAP where appropriate.
  • Inspect testing results.
  • Support post-remediation testing.

Virtualization Platform: Oracle VirtualBox

Oracle VirtualBox provides the virtualized laboratory environment for the target application and security-testing activities.

Purpose
  • Host the required virtual machines.
  • Isolate the application-testing environment.
  • Support Ubuntu and Kali Linux.
  • Provide a controlled testing setup.
  • Reduce unintended interaction with the host environment.

Process

STEP 01

Prepare the Testing Environment

  • Configure Ubuntu Linux and Kali Linux virtual machines using Oracle VirtualBox.
  • Install Python and the required development libraries in the appropriate environment.
  • Install Git for source-code version control and patch comparison.
  • Prepare Semgrep CE and OWASP ZAP for static and dynamic security testing.
  • Verify that the application-testing and machine learning environments are ready.
Tools: Oracle VirtualBox + Ubuntu Linux + Kali Linux + Python + Git
STEP 02

Set Up the Target Application

  • Obtain the OWASP Juice Shop source code from its official repository.
  • Use Git to inspect the repository and record the source-code version.
  • Deploy the application using its documented setup procedure.
  • Verify that the application starts and the relevant functionality is accessible.
  • Record the application version and confirm that the baseline environment is functioning correctly.
Tools: OWASP Juice Shop + Git + Ubuntu Linux
STEP 03

Identify the SQL Injection Security Scenario

  • Inspect the OWASP Juice Shop source code to identify a suitable SQL Injection-related scenario.
  • Review the relevant query-handling logic and existing security protections.
  • Use Git to identify the source-code files associated with the selected functionality.
  • Use Semgrep CE to identify potentially unsafe SQL Injection-related code patterns.
  • Record the baseline source-code version and the expected security behaviour.
Tools: OWASP Juice Shop + Git + Semgrep CE
STEP 04

Collect Public Cybersecurity Dataset Records

  • Obtain a public cybersecurity dataset containing labelled vulnerability-related records.
  • Use Pandas to load and inspect the dataset.
  • Examine the available features, labels, missing values, and duplicate records.
  • Assess whether the dataset supports the intended classification objective.
  • Record the dataset's suitability and limitations for source-code regression detection.
Tools: Python + Pandas + NumPy + Public Cybersecurity Dataset
STEP 05

Preprocess the Dataset

  • Use Pandas to handle duplicate records and inconsistent dataset values.
  • Use Pandas and NumPy to prepare the selected features and labels.
  • Apply suitable encoding to categorical features where required.
  • Use Scikit-learn preprocessing utilities to scale numerical features where appropriate.
  • Verify the prepared dataset and record the preprocessing operations.
Tools: Python + Pandas + NumPy + Scikit-learn
STEP 06

Prepare Source-Code Patch Samples

  • Use Git to preserve the original secured source-code version.
  • Identify the code section relevant to the selected SQL Injection scenario.
  • Create a controlled modification that weakens the relevant security protection in the isolated environment.
  • Maintain separate secured and modified versions using Git.
  • Record the relevant source-code changes for subsequent analysis.
Tools: OWASP Juice Shop + Git + Ubuntu Linux
STEP 07

Compare Source-Code Versions

  • Use Git diff to compare the secured and modified source-code versions.
  • Identify additions, deletions, and modifications affecting relevant query-handling logic.
  • Use Semgrep CE to examine potentially unsafe patterns in both versions.
  • Record the differences and associated static-analysis findings.
  • Prepare the comparison results for feature extraction using Python.
Tools: Git + Semgrep CE + Python
STEP 08

Extract Classification Features

  • Use Python to process the source-code patch information obtained through Git.
  • Use Pandas to organise the extracted source-code and patch-comparison features.
  • Use NumPy to prepare numerical feature representations where necessary.
  • Use Scikit-learn preprocessing utilities to transform the features into a suitable format.
  • Verify that the training and prediction features use compatible representations.
Tools: Python + Git + Pandas + NumPy + Scikit-learn
STEP 09

Prepare Training and Testing Data

  • Use Scikit-learn to separate the labelled dataset into training and testing subsets.
  • Select an appropriate splitting strategy to minimise data leakage.
  • Fit the required preprocessing transformations using the training data.
  • Apply the same fitted transformations to the testing data.
  • Verify feature dimensions, labels, and data consistency using Pandas and NumPy.
Tools: Python + Pandas + NumPy + Scikit-learn
STEP 10

Train the SVM Model

  • Import the SVM classifier from Scikit-learn.
  • Configure the classifier according to the selected dataset and classification requirements.
  • Train the model using the prepared training features and labels.
  • Use an appropriate validation procedure to select suitable model parameters.
  • Save the trained model and its preprocessing configuration for subsequent predictions.
Tools: Python + Scikit-learn + Pandas + NumPy
STEP 11

Evaluate the Model

  • Use the trained SVM model to generate predictions for the held-out testing data.
  • Calculate classification accuracy using Scikit-learn.
  • Calculate precision and recall using the corresponding evaluation functions.
  • Calculate the F1-score and generate a confusion matrix.
  • Record false positives, false negatives, and the overall evaluation results.
Tools: Python + Scikit-learn + Pandas + NumPy
STEP 12

Perform Static Code Analysis

  • Configure Semgrep CE to analyse the OWASP Juice Shop source code.
  • Select applicable SQL Injection detection rules.
  • Scan the secured source-code version and record the findings.
  • Scan the modified source-code version using the same applicable rules.
  • Compare the findings and correlate them with the Git patch differences.
Tools: Semgrep CE + Git + OWASP Juice Shop
STEP 13

Conduct Controlled Security Testing

  • Deploy the relevant OWASP Juice Shop functionality in the isolated testing environment.
  • Use OWASP ZAP to inspect the application's accessible endpoints and requests.
  • Perform controlled security tests against the selected functionality.
  • Compare the observed behaviour with the expected behaviour of the secured version.
  • Record the testing evidence and correlate it with the Git and Semgrep CE findings.
Tools: OWASP Juice Shop + OWASP ZAP + Kali Linux + Git
STEP 14

Validate Using OWASP ZAP

  • Configure OWASP ZAP to assess the locally deployed OWASP Juice Shop application.
  • Identify the endpoint and functionality relevant to the selected security scenario.
  • Perform appropriate controlled security tests.
  • Review alerts and application responses for evidence relevant to SQL Injection.
  • Record the findings and compare them with the static-analysis results.
Tools: OWASP ZAP + OWASP Juice Shop + Kali Linux
STEP 15

Classify Potential Security Regressions

  • Use Python to prepare source-code patch features for model prediction.
  • Apply the saved preprocessing configuration using Scikit-learn.
  • Submit the prepared features to the trained SVM classifier.
  • Record the predicted classification alongside the corresponding source-code change.
  • Identify predictions requiring further verification against Git, Semgrep CE, and OWASP ZAP evidence.
Tools: Python + Scikit-learn + Pandas + Git
STEP 16

Correlate Detection Results

  • Use Git to review the source-code changes associated with each prediction.
  • Compare the predictions with Semgrep CE static-analysis findings.
  • Compare the predictions with relevant OWASP ZAP testing results.
  • Use Python and Pandas to organise the predictions and validation evidence.
  • Record confirmed findings, conflicting results, false positives, false negatives, and cases requiring further investigation.
Tools: Git + Semgrep CE + OWASP ZAP + Python + Pandas
STEP 17

Develop the Streamlit Dashboard

  • Use Python and Streamlit to create the security assessment dashboard.
  • Display SVM predictions and model evaluation metrics generated using Scikit-learn.
  • Present relevant source-code changes obtained through Git.
  • Display Semgrep CE findings and relevant OWASP ZAP testing results.
  • Present the validation status, identified security issues, and recommended corrective actions.
Tools: Python + Streamlit + Scikit-learn + Git + Semgrep CE + OWASP ZAP
STEP 18

Perform Final Security Validation and Advisory Review

  • Execute the Semgrep CE analysis again and compare the initial and final static-analysis findings.
  • Review the original SQL Injection security finding and the implemented corrective changes.
  • Review the pre-remediation and post-remediation OWASP ZAP results.
  • Reassess the source-code patch differences using Git and verify that the intended security protections remain in place.
  • Update the findings in the Streamlit dashboard, mark successfully remediated issues, record residual security risks, and finalise the security assessment and recommendations.
Tools: Semgrep CE + Git + OWASP ZAP + Streamlit + Scikit-learn

Outcome

Automated Security Regression Classification Implements an SVM-based mechanism to classify prepared source-code features according to their potential SQL Injection regression risk.

Source-Code Change Identification Uses Git to compare secured and modified source-code versions, identifying changes that may weaken previously implemented SQL Injection protections.

Machine Learning Performance Evaluation Evaluates the SVM classifier using accuracy, precision, recall, F1-score, and confusion-matrix analysis to assess its ability to classify security regression risks.

Static Security Analysis Uses Semgrep CE to analyse source code, identify potentially unsafe SQL Injection-related patterns, and highlight suspicious changes requiring further investigation.

Dynamic Application Validation Uses OWASP ZAP to examine OWASP Juice Shop application behaviour and support the verification of suspected SQL Injection vulnerabilities through controlled security testing.

Security Finding Correlation Correlates SVM predictions with Git source-code differences, Semgrep CE findings, and OWASP ZAP results to support the investigation and verification of potential security regressions.

Interactive Security Dashboard Develops a Streamlit dashboard to display machine learning predictions, evaluation metrics, source-code changes, static analysis findings, dynamic testing results, and security assessment status.

Controlled Security Regression Assessment Establishes a repeatable testing workflow to examine secured and modified source-code versions, assess potential SQL Injection regression risks, and verify the effectiveness of existing security protections.

SQL Injection Remediation Verification Repeats source-code comparison, static analysis, and dynamic application testing after corrective changes to determine whether the identified weakness has been addressed.

Security Assessment Documentation Produces structured assessment records containing model evaluation results, identified source-code changes, security-tool findings, validation evidence, remediation status, residual risks, and recommended corrective actions.