Malicious Web Request Detection Using Character-level CNN

Rong Wei, Bowen Zhang, Xixiang LvarXiv 2018 · DOI

Abstract

Web parameter injection attacks are common and powerful. In this kind of attacks, malicious attackers can employ HTTP requests to implement attacks against servers by injecting some malicious codes into the parameters of the HTTP requests. Against the web parameter injection attacks, most of the existing Web Intrusion Detection Systems (WIDS) cannot find unknown new attacks and have a high false positive rate (FPR), since they lack the ability of re-learning and rarely pay attention to the intrinsic relationship between the characters. In this paper, we propose a malicious requests detection system with re-learning ability based on an improved convolution neural network (CNN) model. We add a character-level embedding layer before the convolution layer, which makes our model able to learn the intrinsic relationship between the characters of the query string. Further, we modify the filters of CNN and the modified filters can extract the fine-grained features of the query string. The test results demonstrate that our model has lower FPR compared with support vector machine (SVM) and random forest (RF).

Introduction

Web application attacks, particularly parameter injection attacks like SQL Injection (SQLi) and Cross-Site Scripting (XSS), constitute approximately 73% of security incidents. Traditional Web Intrusion Detection Systems (WIDS) typically rely on signature-based detection, which fails against zero-day threats, or anomaly-based detection, which often produces excessive false positives and lacks adaptability. To address these gaps, this research introduces a deep learning model that understands the "language" of query strings at the character level and adapts through a dynamic re-learning loop.

System Architecture and Re-learning

The proposed detection system is designed to be dynamic rather than static. It incorporates a "system background" loop that facilitates continuous improvement. When the detection model encounters samples with low confidence, these are flagged for manual review. Once labeled by experts, these new samples are added to a labeled database to retrain and update the model. This ensures the system evolves alongside emerging attack patterns.

Figure 1: Overview of the proposed detection system architecture, highlighting the re-learning loop within the system background.

CNN Model Design

The heart of the system is a modified CNN architecture optimized for text-based request parameters. Unlike standard image-based CNNs, this model employs specific layers to handle character sequences:

  • Character-level Embedding: The model maps 95 possible characters (letters, numbers, and symbols) into a $k$-dimensional vector space. This allows the network to learn functional similarities between characters based on their context. For instance, it can learn that = and & serve similar structural roles as separators.
  • Vertical Convolutional Filters: The filters are designed with a width equal to the embedding dimension. This constraint forces the filters to move "vertically" along the character sequence, ensuring that each character's vector is processed as a single, indivisible unit.
  • Feature Extraction: This architecture automatically learns fine-grained features from raw character sequences, eliminating the need for manual feature engineering like TF-IDF.
Figure 3: The character-level CNN architecture, showing the transition from the embedding layer to convolutional and pooling layers.

Experimental Results

The model was evaluated using a balanced dataset of 4,302 samples, including benign requests and various attack types (XSS, RFI, SQLi, and Directory Traversal). The CNN was compared against traditional machine learning models, including Random Forest (RF) and Support Vector Machines (SVM).

The CNN demonstrated superior performance across key metrics:

  • False Positive Rate (FPR): The CNN achieved a remarkably low FPR of 0.02%, significantly outperforming SVM (0.13%) and RF (0.38%).
  • Recall: The model reached 100% recall for Directory Traversal, RFI, SQLi, and XSS.
  • Precision: Precision remained at 100% for Benign, Directory Traversal, and XSS categories.

Conclusion and Future Work

By treating characters as the primary unit of meaning and utilizing a re-learning loop, the proposed system effectively reduces the "cry wolf" syndrome common in security monitoring. The model successfully identifies semantic relationships between punctuation marks and alphanumeric characters that are critical for detecting injection attacks.

Future research will focus on expanding the dataset size to further improve precision and exploring deeper architectures with multiple convolutional layers to extract even more complex features. Additionally, testing the system against high-volume, real-world production traffic will be essential to validate its robustness in practical environments.

Summary updated

BibTeX
@misc{wei2018malicious,
  author = {Rong Wei and Bowen Zhang and Xixiang Lv},
  title = {{Malicious Web Request Detection Using Character-level CNN}},
  year = {2018},
  eprint = {1811.08641},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.08641},
}
Figure