IEEE Final
IEEE Final
With the dataset pre-processed, the next step involves training the
machine learning model using sequential data. Initially, a vanilla
Recurrent Neural Network (RNN) is used as a basic model to Figure 3: Data Preprocessing
process the input data. RNNs are designed to work with sequential
data, such as the sequence of characters in an API request, and are This Figure shows the user interface of a desktop application
capable of detecting patterns that may indicate injection attacks.
However, despite their usefulness, vanilla RNNs have limitations, designed for detecting injection attacks in APIs. The user uploads a
particularly in their ability to capture long-term dependencies due dataset of API requests or code samples using the "Upload
to the issue of vanishing gradients. This drawback can limit the
model’s capacity to learn from longer sequences of data, which is Injection Dataset" button. Presents a bar chart visualizing the
crucial for identifying complex attack patterns. distribution of different attack types and normal instances in the
To address the shortcomings of vanilla RNNs, the model is loaded dataset.
enhanced by using a Gated Recurrent Unit (GRU). The GRU is a
more advanced version of the RNN that incorporates gating
mechanisms to better control the flow of information through the
network. These gates allow the GRU to capture long-term
dependencies more effectively, overcoming the vanishing gradient
problem. As a result, the GRU improves both the accuracy and
efficiency of the model.
The performance of the two models, the vanilla RNN and the
GRU, is then compared using various metrics, including accuracy,
precision, recall, and F1-score. These metrics help assess the
models' ability to correctly classify legitimate and malicious
queries. By evaluating the models in terms of these performance Figure 4: Data splitting
indicators, the advantages of the GRU model in detecting injection
attacks become evident. It outperforms the vanilla RNN, The Figure describes the data splitting process, a crucial step in
demonstrating its ability to more accurately identify malicious
activity while minimizing false positives and false negatives. machine learning model development. Let's break down what it
means:
Finally, after the GRU model is trained, it is tested on new, unseen
API requests. The trained model processes the test data and
generates predictions that indicate the likelihood of each request Dataset Train & Test Split Details
being malicious. This final step allows the system to predict the
presence of injection attacks in real-time API interactions, This clearly indicates that the data has been divided into two sets: a
providing an effective tool for detecting and preventing security training set and a testing set. This is standard practice to evaluate
threats in web applications.
how well a machine learning model generalizes to unseen data.
4. EXPERIMENTAL ANALYSIS
80%: This is the proportion of the original dataset that has
been allocated to the training set.
3
20%: This is the proportion of the original dataset allocated to (no attack detected), "SQL Injection," or "XML/JSON Injection,"
the testing set. correctly identifying several SQL and XML/JSON injection
attempts while also classifying benign inputs as "Normal."
testing: The testing set is used to evaluate the performance of
However, some potentially malicious inputs, like those with script
the trained model. The model's predictions on this unseen data
tags or JavaScript alerts, are also classified as "Normal" or
are compared to the actual values to assess its accuracy and
"XML/JSON Injection" when they might represent other types of
generalization ability.
attacks (e.g., Cross-Site Scripting - XSS), indicating potential areas
for improvement in the model's detection capabilities.
5. CONCLUSION