Next Article in Journal
Mechanical Response and Failure Mechanisms of Block Caving Bottom Structures Under Dynamic Conditions Induced by Slope Rockfalls
Previous Article in Journal
Research on the Evolutionary Pathway of Science–Technology Topic Associations: Discovering Collaborative and Symmetrical Effects
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

An Intelligent Ensemble-Based Detection of In-Vehicle Network Intrusion

1
Department of Computer Science, College of Computer Science and Engineering, Taibah University, Yanbu 46421, Saudi Arabia
2
Department of Electrical Engineering and Computer Science, Florida Atlantic University, 777 Glades Road, Boca Raton, FL 33431, USA
*
Author to whom correspondence should be addressed.
Appl. Sci. 2025, 15(12), 6869; https://doi.org/10.3390/app15126869
Submission received: 22 April 2025 / Revised: 28 May 2025 / Accepted: 16 June 2025 / Published: 18 June 2025

Abstract

The Controller Area Network (CAN) bus has been implemented in most modern Vehicles. Various attacks can be launched against the CAN bus protocol because it is designed without security mechanisms. It is essential to develop a highly accurate intrusion detection system (IDS) for CAN bus attacks. We design an effective ensemble learning-based IDS scheme for detecting and classifying DoS, fuzzing, replay, and spoofing attacks. These are common CAN bus attacks that can threaten the safety of a vehicle’s driver, passengers, and pedestrians. For this purpose, we utilize supervised machine learning in combination with ensemble methods. We first perform data balancing and feature selection. We build and fine-tune random forest, Xtreme gradient boosting, and decision tree supervised learning models. We then combine these models with voting, stacking, and bagging ensemble methods. The results obtained demonstrate the effectiveness of the proposed scheme when trained on real-life CAN traffic datasets to detect and classify these four attacks. The stacking method achieved the highest performance in terms of accuracy, precision, recall, F1-score, and area-under-the-curve receiver operator characteristic (ROC-AUC). The stacking method outperformed other recently proposed methods with an F1-score, precision, recall, and accuracy of 0.993, 0.993, 0.993, and 0.986, respectively.

1. Introduction

Vehicles are increasingly becoming a necessity in modern society. The emerging vehicular network technology supports inter-vehicle and vehicle-to-everything communication and has the potential to enhance the safety and efficiency of transportation systems [1,2,3,4,5,6,7,8]. In-vehicle networks (IVNs) support intra-vehicle communication between vehicle interconnected components [9,10]. To meet the growing need for advanced functionality, vehicles are becoming more equipped with electronic equipment. Electrical Control Units (ECUs) are significant pieces of equipment for monitoring and controlling various components. The average vehicle has between 70 and 100 ECUs, each of which transmits over 2500 signals to other units within the vehicle [11]. IVNs, which are comprised of various bus protocols, have been adopted as the framework for coordinating communication among ECUs. Enabled by actuators, sensors, and processors, IVNs facilitate information exchange services depending on the needs of drivers. Vehicle manufacturers adopt a high number of ECUs to enhance various functionalities [11,12,13]. For IVNs, the communication protocols utilized include Controller Area Network (CAN), Local Interconnect Network (LIN), FlexRay, Ethernet, and Media-Oriented Systems Transport (MOST). The common key feature among the protocols is the transmission of messages with pre-defined time limits and message delivery reports. IVNs mainly use the CAN bus protocol, which focuses on the reliability of communication and functional safety. CAN is often adopted for multiple functionalities and control, including real-time communication for engine management, brake controls, airbag control, and control of the body system. The protocol transmits packets between ECUs through interconnected buses.
It is essential to protect the communication within a vehicle since intra-vehicular communication affects the safety of drivers, passengers, and the vehicles themselves. The CAN protocol, designed for robustness, flexibility, speed, and low cost, has become a cause of concern due to a lack of security mechanisms. These mechanisms include a lack of authentication and encryption that let attackers disrupt the protocol and messages’ confidentiality, integrity, and availability. The authors in [14,15,16,17,18] reported that the CAN protocol’s weak security makes it a target for different attacks. The most common attack vectors include DoS, fuzzing, replay, and spoofing, which are critical due to how they can render the protocol system ineffective [19]. The protocol’s broadcast transmission technique, security vulnerabilities, and unsecured priority scheme are weaknesses that further expose the CAN protocol to cyber threats. Successful attacks against the CAN protocol through injection or other vectors can enable an attacker to take control of the bus system, disable the brakes, affect acceleration and steering, or turn the lights on/off, among others. As part of a hacking experiment, a Jeep Cherokee’s functions were hacked and controlled [20].
Various attacks can be launched against the CAN bus protocol because it was designed without security mechanisms. It is essential to develop highly accurate detection mechanisms for CAN bus attacks. Conventional security mechanisms, including authentication, firewalls, and encryption, are not suitable for CAN due to its structural limitations. These limitations include the absence of support for such security methods [21,22,23]. The 8-byte size of the CAN data frame poses limits on cryptographic message authentication. Another proposed method utilizes a convincing honeypot at the wireless gateway, but its efficacy depends on its ability to deceive assailants with its realism. In addition, a suggested firewall architecture for vehicular gateways may not offer complete protection against a variety of potential risks to the network [24]. Encryption and authentication-based IVN security solutions, firewall structures, and IVN Intrusion Detection Systems (IDSs) are security solutions discussed in [25]. Encryption and authentication are inapplicable due to the limited resources of IVNs, whereas firewalls are impracticable due to a long vehicle lifecycle and numerous attack surfaces. The authors recommend utilizing an IDS for IVNs to defend against intrusions in resource-constrained environments. According to the study in [26], automotive IDS, including those that utilize machine learning algorithms, have the capability to fulfill the requirements of the industry in terms of being cost-effective, lightweight, and working in real time. The study evaluates a variety of intrusion detection technologies, including machine learning approaches, and suggests their implementation in the automotive industry. One of the security mechanisms that has received attention among researchers is the use of IDSs. These mechanisms have been researched and created to advance security against the increasing number of attacks leveled against networks. IDSs monitor networks to identify malicious activities, such as information theft, censorship, or protocol tampering, with the major focus being the detection of anomalous behavior and recording information. IDSs are implemented as network-level defense mechanisms for computer resources. The characteristics and capabilities of IDSs make them suitable for detecting anomalies in common networks. However, in networks that face new and complicated cyberattacks, IDSs need integration with novel technologies to enhance their effectiveness and accuracy in the detection results. For instance, ensemble learning can be used to obtain better detection results for IDSs. The main objective of ensemble learning is to enhance the accuracy of classification by combining multiple classifiers into one model. The ensemble learning method allows for multiple mechanisms of learning with varying strengths to support one another, which leads to increased prediction reliability. In [18,27,28,29,30,31], the authors demonstrated that the utilization of ensemble methods has resulted in enhanced accuracy in intrusion detection compared to the utilization of individual classifiers.
In this study, we propose a scheme that utilizes well-tuned hyperparameters, feature selection, supervised models, and ensemble methods to build an effective IDS framework for classifying DoS, fuzzing, replay, and spoofing attacks on the CAN bus. We combine Random Forest (RF), Xtreme Gradient Boosting (XGBoost), and Decision Tree (DT) models using stacking, voting, and bagging methods. The following is an illustration of our contributions:
  • We develop and test three supervised models that include hyperparameter tuning, balancing of data, and feature selection. The models are RF, DT, and XGBoost.
  • With three different ensemble methods, we combine the three supervised models to enhance our scheme’s ability to detect DoS, fuzzing, replay, and spoofing attacks. These ensemble methods are stacking, voting, and bagging.
  • We evaluate our scheme’s performance using accuracy, precision, recall, F1-score, and area-under-the-curve receiver operator characteristic (ROC-AUC). Our scheme detected DoS, fuzzing, replay, and spoofing attacks with a higher detection accuracy score of 0.986 compared to the most recent study proposed for detecting attacks in the CAN bus.
This study’s remaining sections are organized as follows: Section 2 describes CAN’s background and attack types. Section 3 discusses the related work. The models proposed are illustrated in Section 4. Section 5 contains the results and analysis. Section 6 finally concludes the paper.

2. CAN’s Background and Types of Attacks

2.1. Background of CAN Bus

Robert Bosh GmbH developed the CAN for vehicles in 1986 [32]. The CAN bus protocol transmits data and messages to all network nodes using a broadcast technique. CAN has various advantages that make it suitable for IVNs. The CAN bus has a flexible design and is suitable for fast and low-latency real-time communication in vehicles. Moreover, it has a high level of reliability, noise resistance, and fault tolerance. CAN utilizes a priority-based strategy that prevents communications interruptions from lower-priority messages for higher-priority messages within the bus. CAN is essential and irreplaceable as the core of automotive IVN communication in modern vehicles. Replacing it would require a complete redesign of the IVN architecture [33,34,35].
A CAN packet has seven fields in its structure, which are explained in the following: Start of the Frame, which uses a single bit to indicate the start of CAN message transmission to all connected nodes; Arbitration Field, which is referred to as the CAN ID, and indicates the importance of the message received. The CAN ID message has a low value, indicating its high priority. Control Field, which contains a data length code (DLC), shows the data field’s total bytes. Data Field: the actual data transfer is the responsibility of this field. Cyclic Redundancy Check (CRC) Field: utilized in the process of validating data packets. Acknowledge (ACK) Field verifies that the receiver nodes in the network have successfully received the CAN packets. End of the Frame shows the completion of the message of CAN. Figure 1 depicts the CAN bus’s frame structure.

2.2. Attack Types

The CAN protocol is limited by a lack of authentication and encryption as key security features. The lack of authentication causes violations of integrity and priority-based arbitration and exposes every node in the network to all transmitted messages. An attacker can exploit this vulnerability by launching a sniffing attack on the CAN bus, analyzing the internal CAN data of a target vehicle, and launching injection attacks to control the vehicle. The CAN protocol also gives priority to the arbitration mechanism. The protocol uses an ID-based priority scheme, which attackers can exploit by injecting high-priority messages to launch denial-of-service (DoS) attacks and prevent access to other services. The simplicity and high adaptability of the CAN protocol are vulnerabilities. This allows an attacker to inject deceptive data into the bus network [36,37]. The authenticity of messages sent using the CAN protocol is also not guaranteed. As a message-based protocol, CAN sends messages without source or destination addresses since its frame format lacks sender/receiver information. Injection attacks are, therefore, easy to launch against the protocol. Such injection attacks typically exploit the onboard diagnostics II (OBD-II) interface to introduce malicious CAN messages into the vehicles and disable some functionalities. The attacks originate from internal sources such as the OBD or external sources such as Wi-Fi, cellular links, and Bluetooth devices [35,38]. The lack of encryption, on the other hand, violates the principle of confidentiality. CAN is not encrypted because of real-time communication requirements. The risk of having no encryption is that attackers can launch malicious code to monitor all bus-broadcast communications, analyze their content, and use the information to hack the IVN. A compromised ECU can further take advantage of the broadcast property of CAN by monitoring and listening to all CAN frames or sending any frame across the network.
CAN has security vulnerabilities that threaten the safety of vehicles, drivers, and passengers. The following are the security vulnerabilities in the CAN bus: Lack of Boundary Defense and Segmentation: The ECUs in IVNs are organized into sections, but these sections lack boundaries because gateways connect them. Therefore, a malicious user with access can take control of the system. Lack of Authentication: CAN has no authentication infrastructure, allowing any device to connect to the bus and join the network without the sender’s ID being verified. Each node that joins the network may use CAN’s broadcast communication feature to send malicious data to other nodes. Unencrypted Traffic: The messages exchanged between CAN nodes are in plain text, indicating that the protocol does not take the confidentiality requirement into account. Availability Check: Before allowing any message to be sent, the CAN protocols check to see if carriers are available. If any carrier is busy, the protocol prevents all ECUs from transmitting and rechecks the carriers after a certain period of time. This mechanism makes the protocol vulnerable to DoS attacks [15,16,18]. The authors in [39] evaluated classification techniques based on ML for the purpose of DoS detection. The implementation of machine learning techniques improved the performance of classification for detecting DoS attacks.
Attackers may target several security requirements in vehicular communication environments, including confidentiality, availability, authenticity, data integrity, and non-repudiation [40,41,42,43,44,45]. Table 1 depicts the type of attack and the affected security requirements.
Message injection attacks, including DoS, spoofing, replay, and fuzzing, are the most popular inter-vehicle attacks [41]. DoS: The attacker renders communication services unavailable by increasing the message frequency of the CAN bus. The attacker will inject high-frequency messages with a high priority that are either smaller than a normal message or have a CAN ID of 0x000. A malicious node can increase bus occupancy in order to cause delays or even prevent other communications. Figure 2 demonstrates an example of a DoS attack in which the attacker sends two messages with the high-priority CAN ID 0x000 to cause delays for the CAN ID 0x209 transmitted by ECU A.
Fuzzing: The attacker injects random ID, DLC, and data fields while impersonating legitimate traffic using CAN IDs that appear legitimate to compromise the CAN bus system, causing disruptions such as shaking of the steering wheel, irregular signal lights, and automated gear shifts [37]. This attack approach involves sending many randomly compromised IDs and data into the network at any time, disrupting regular communications without the victim node’s knowledge. The lack of authentication and data integrity in the CAN bus protocol led to this attack. Figure 3 shows an example of attacker-generated random messages with CAN IDs 0x200, 0x307, and 0x540, that are received by ECU B.
Replay: The objective of this type of attack is to capture legitimate CAN messages in transmission and then later re-transmit them into the vulnerable CAN bus. This is an influential Man in the Middle attack that intercepts, records, and rebroadcasts network messages. This attack can result in actions that are not authorized or the dissemination of false information throughout the network. This type of attack occurs because the CAN bus data transmission is broadcast. An example of a replay attack is depicted in Figure 4, and it includes the attacker transmitting the CAN IDs that belong to the target ECUs, A and C, and are received by ECU B.
Spoofing: The attacker is able to inject messages with specified CAN IDs belonging to authorized nodes, as no authentication is provided for communications on the CAN bus. Payload-focused spoofing is an attack where attackers intercept and analyze CAN communications to read and alter essential component structures. They quickly inject malicious information into transmission gaps by masquerading as a typical node with the same ID [46]. This attack has the possibility of reducing communication performance. Figure 5 demonstrates an example of a spoofing attack in which the attacker uses CAN ID 0x209, which belongs to ECU A, and sends it to the target ECU B. This attack has the potential to alter the frequency and the content of the targeted ID.

3. Related Work

In a review of IDS for vehicular networks, Nandy et al. [47] emphasized the importance of addressing cyber-physical threats and exploring IDS mechanisms for vehicular communication from multiple perspectives. They identified gaps in real-world validation and highlighted the significance of implementation and testing to verify IDS effectiveness. To detect in-vehicle attacks, the authors in [48] presented a deep convolutional neural network (DCNN) approach called Reduced Inception-ResNet. Compared to Naive Bayes (NB), Support Vector Machine (SVM), Decision Tree (DT), and Artificial Neural Network (ANN), this method outperformed the others in terms of detection accuracy. However, more improvement is needed to investigate the performance of various types of CAN bus attacks, and the imbalance of data between malicious and normal samples prevents these models from performing accurate intrusion detection techniques. In [49], a lightweight ML algorithm based on RNN is proposed for IDS on the CAN bus network. To obtain the highest effective results in detection performance, the authors combined the security control unit (SECCU) and the simplified attention (SIMATT) algorithms. The proposed model outperformed Long Short-Term Memory (LSTM), Gated Recurrent Unit (GRU), GAN-Based Intrusion Detection System (GIDS), and RNN in terms of performance metrics. The authors in [50] proposed a CAN-bus intrusion-based LSTM deep learning model. The model can detect three types of attacks: DoS, fuzzing, and spoofing. However, no feature selection or data balance is used. In [51], the authors proposed an IDS that utilizes RNN and LSTM. The selected model provided intrusion detection against CAN bus spoofing attacks; however, further research is required to detect additional types of cyberattacks. In [52], the authors presented CANintelliIDS, a method for detecting CAN bus intrusions based on CNN and attention-based gated recurrent unit (AGRU) models. The main focus of the model was detecting DoS, fuzzing, and impersonation attacks. In terms of performance metrics, the model outperformed RF, SVM, CNN, and Logistic Regression. In [53], CAN-bus intrusion based on the application of Recurrence Quantification Analysis (RQA) to detect spoofing attacks is proposed. The RQA-based approach obtained good detection accuracy. The author focused on spoofing attacks, but other attacks need to be considered. CNN and LSTM are types of deep learning models that have been integrated and proposed as methods for defending IVNs against a variety of cyberattacks [54]. These attacks include replay, DoS spoofing, and fuzzing attacks. They were able to detect all four attacks with an accuracy score of 97.30%. In [55], the authors proposed a graph-based IDS, and they utilized KNN and SVM to detect and identify attack messages broadcast on the CAN bus. This was conducted by turning the messages received from the CAN bus into a temporal graph; however, no hyperparameter tuning or data balancing were performed. IDS models have shown potential in previous research; however, they frequently lack an integrated framework that combines feature selection, data balancing, and systematic hyperparameter optimization across diverse attack types. Additionally, most studies focus on specific types of attacks or employ a single ensemble strategy. In contrast, our study integrates three ensemble methodologies, stacking, bagging, and voting, alongside rigorous preprocessing techniques to detect all four major CAN bus attacks (DoS, fuzzing, spoofing, and replay). This work aims to evaluate a comprehensive and multifaceted ensemble IDS on real-world CAN data. Authors in [56] have introduced an enhanced SVM-based IDS model for the CAN bus system. On the actual dataset, the model performed well and was robust to only DoS attacks on electric vehicles. Several studies [51,53,56] focus on a single type of attack, such as spoofing or DoS attacks. The CAN bus, however, is vulnerable to various attacks. While Refs. [51,52,53,54,55] accomplished feature selection, and Refs. [48,49,50,52,53,54] implemented model tuning, none of the related work used data balancing and ensemble methods. Table 2 presents a comparison between our method and some recently proposed methods. Ensemble learning, data balance, and hyperparameter tuning are in this table. The novelty lies in the combination of these components, with stacking using XGBoost (version 1.7.6) as a meta-learner being something rarely explored in prior CAN IDS research. This scheme achieves higher performance across all metrics as seen in the Results section, particularly in detecting classifying all four major CAN bus attacks.

4. Proposed Scheme

We propose a multi-classification scheme capable of detecting four types of attacks on CAN bus networks. We use machine learning to design and evaluate an effective IDS framework. This framework utilizes multi-classification algorithm-based ensemble methods to enhance the IDS’s ability to identify intrusions. We used three supervised ML models (RF, DT, and XGBoost) along with three ensemble classifiers (stacking, voting, and bagging). Well-known evaluation metrics were used to assess the effectiveness of the proposed approach. Accuracy, precision, recall, F1-score, and ROC were the metrics utilized in this study. Figure 6 is an overview of our proposed model’s workflow, which includes the CAN bus input dataset, data preprocessing, supervised models building, ensemble modeling, attacks classification, and scheme evaluation.

4.1. CAN Bus Dataset

The CAN intrusion dataset from IEEE DataPort is utilized for this study [57]. The dataset is selected since it was collected in 2020. Furthermore, the dataset has full labels, which is essential for our proposed supervised learning models. Millions of CAN bus messages were collected by the authors of the dataset from a vehicle’s real data, and then four attacks were launched: DoS, spoofing, replay, and fuzzing. The features used in the dataset are Timestamp, Arbitration-ID, DLC, Data, and Target. Timestamp is the time recorded. Arbitration-ID is an identification for CAN messages. DLC indicates the data length code. The CAN data field is Data. Target determines the types of attacks (normal, DoS, spoofing, replay, and fuzzing). The distribution of normal and attack messages is shown in Table 3.

4.2. Data Preprocessing

Preprocessing is used in data mining to transform raw datasets into a usable structure. Data is frequently insufficient and inconsistent in the real world. Preprocessing the data can be conducted in a variety of ways. Label encoding was implemented during the preprocessing phase of the data. It is the step before feeding data into a model, wherein numerical values are assigned to each dataset. Also, we cleaned and removed duplicate and null values. The mean–median method was used for filling null values. Feature selection was utilized to illustrate the significance of the dataset’s features [58]. The extra tree technique was utilized in order to identify the most important features and eliminate the features that had no significance in the dataset that was being analyzed. Due to their randomization, Extra Trees provide diversity, robustness to noise, and efficiency, reducing overfitting and identifying feature importance. The features used in the dataset are Timestamp, Arbitration- ID, and Data. We used a K-fold cross-validation process with K equals 10. We take the issue of data imbalance across classes into consideration. The main objective of utilizing balanced data during model training is to enhance the classification accuracy of the models. We use the near-miss as a method of undersampling that can help fix the imbalanced data issue. This method reduces the size of data for the majority class [59].

4.3. Supervised ML

In the supervised models building phase, we used three supervised models that provided the most accurate results in our previous work [29]. These models are RF [60], DT [61], and XGBoost [62]. ML model performance can be improved through model tuning. Random search is used to find the most suitable set of hyperparameters. For the models, we performed hyperparameter tuning. To prevent overfitting, we utilized a K-fold cross-validation process with K equals 10.

4.4. Ensemble Classifiers Learning

Ensemble learning uses techniques that allow different ML algorithms to work together on a single prediction to enhance accuracy. It has the potential to outperform any single algorithm. Ensemble learning for classification is several models that are trained to solve a classification problem. Models’ predictions are combined to make a final prediction. Using ensemble learning, the performance of a single classifier can be improved by reducing overfitting, making the classifier more robust, and improving its ability to generalize. In the ensemble modeling phase, we utilized three ensemble techniques: stacking, bagging, and voting. Ensemble learning with additional cross-validation provides reliable performance estimates and can improve generalization by using varied model predictions.
Stacking is an ensemble learning technique. The purpose of stacking is to achieve a more accurate final model by combining the strengths of multiple base models. It builds its models in two stages. These stages are called base learner and meta-learner. Stacking runs the single learners (base-learners) and combines them by training the meta-learner to make the final predictions using the predictions generated by the base-learners. The meta-classifier learns how to best combine the predictions of the base learners [63]. Any learning algorithm can be employed as a single learner or meta-learner. In our model, we used the RF, DT, and XGBoost models as base models and the XGBoost model as a meta model.
Bagging represents a parallel ensemble method. In this method, parallel learning produces single learners. Bagging generates many dataset subsets (bags) by bootstrapping. The final prediction results are determined by averaging all predictions for subsets. To improve performance, the bagging classifier reduces the variance of the base classifiers. Its main objective is to enhance the precision and stability of supervised models [64,65]. To reduce noise and avoid overfitting, we combined the bagging classifier with the XGBoost model.
A voting ensemble method is a technique for combining the predictions of multiple models to enhance the system’s overall performance. Different models can make different types of errors, and by combining their predictions, the ensemble can reduce errors overall [66]. The steps and evaluation of our proposed IDS scheme are depicted in Figure 7.

4.4.1. Attacks Classification

The target of our scheme during the classes phase is to identify the types of attacks (normal, DoS, spoofing, replay, and fuzzing). These attacks are described in Section 2.2.

4.4.2. Scheme Evaluation

In this phase, the evaluation of our scheme’s performance is carried out based on several metrics, including accuracy, recall, precision, receiver operating characteristic (ROC), and F1-score. These metrics are defined in relation to true positives (TPs), false positives (FPs), true negatives (TNs), and false negatives (FNs). For the ROC, specificity (True Positive Rate, or TPR) and sensitivity (True Negative Rate, or TNR) are also considered.
A c c u r a c y = T P + T N T P + T N + F P + F N
P r e c i s i o n = T P T P + F P
R e c a l l = T P T P + F N
F 1 = 2 P r e c i s i o n R e c a l l P r e c i s i o n + R e c a l l = 2 T P 2 T P + F P + F N
S p e c i f i c i t y = T N F P + T N
S e n s i t i v i t y = R e c a l l

4.5. Environment Tools

A Jupyter Notebook is used as the development environment for this work. This environment is one of the applications that Anaconda offers. Python is used for the implementation of the scheme. Python is selected because it is efficient, scalable, stable, and supports the metrics used in our work. All experiments were conducted in a Python 3.8 environment using scikit-learn and Pandas libraries.

5. Results and Discussion

This research’s main objective is to detect and classify intrusion detection attacks. DoS, fuzzing, spoofing, and replay attacks are four common CAN bus attacks that can pose a threat to the safety of a vehicle’s driver, passengers, and pedestrians. We built a scheme that detects these common CAN bus attacks and classifies their type. We utilized supervised machine learning in combination with stacking, voting, and bagging ensemble methods for this purpose. Initially, we developed and evaluated three promising supervised learning techniques. After performing feature selection and data balancing, we utilized RF, DT, and XGBoost and fine-tuned these models. These models were selected due to their effective multithreading capabilities, and these tree structure algorithms provide minimal computational time. Furthermore, their ability to execute in parallel significantly decreases the time frame of model training while improving accuracy [67].
In terms of precision, recall, and F1-score, feature selection enhanced the performance of all models (RF, DT, and XGBoost). We obtained F1-scores higher than 0.979, precision scores higher than 0.980, and recall scores higher than 0.979. The XGBoost model with feature selection has the highest precision, recall, and F1-score, followed by the RF model with feature selection. Also, using feature selection with ensemble methods (stacking, bagging, and voting) improved the performance in terms of precision, recall, and F1-score. The stacking method has the highest performance with an F1-score of 0.993, precision of 0.993, and recall of 0.993. Voting has the second-highest performance with an F1-score of 0.981, precision of 0.982, and recall of 0.981. The bagging method has the lowest performance with an F1-score of 0.980 and precision and recall of 0.980. Figure 8 shows that applying feature selection to the RF, DT, XGBoost, stacking, bagging, and voting models increases their precision, recall, and F1-score performance.
Cross-validation is a technique for determining the performance of machine learning models. Cross-validation can provide a more accurate estimate of model performance than a single train-test split by performing multiple iterations of training and testing on different subsets of the data [68]. In our proposed scheme, the dataset is divided using 10-fold cross-validation, where each fold is utilized once as test data and the remaining nine as training data. This process is repeated ten times to ensure robust evaluation by averaging the performance across all iterations. In this study, the accuracy of the models with feature selection is compared to that of the models without feature selection using 10-fold cross-validation. Without feature selection, stacking achieved the highest accuracy of 0.986. XGBoost and bagging achieved an accuracy of 0.982 and 0.976, respectively. The accuracy of the voting model is 0.975, while the accuracy of the RF and DT models is 0.973 and 0.971, respectively. The stacking method has the highest performance among all the models without feature selection. However, feature selection has improved the performance of most of the models. Stacking and DT have the same accuracy because both of them are already able to select significant features effectively. Both the XGBoost model and the bagging model have an accuracy of 0.985. Following these models are voting, with an accuracy of 0.979, and RF, with an accuracy of 0.978. Using 10-fold cross-validation, Table 4 and Table 5 compare the accuracy of the models without feature selection to that of the models with feature selection. The accuracy of some methods remains relatively unchanged both before and after feature selection because these approaches already incorporate built-in feature selection processes. Figure 9 demonstrates that feature selection consistently reduces testing and training times for all models.
The results for all the models (RF, DT, XGBoost, Stacking, Voting, and Bagging) show that all models perform well in detecting flooding and spoofing attacks with high precision, recall, and F1-score. Stacking, XGBoost, and voting achieve the highest performance for the fuzzing attack, reaching a value of 1.00 for precision, recall, and F1-score. These results were achieved through the use of feature selection for detecting these attacks. These are followed by bagging, RF, and DT models with feature selection. The stacking model with feature selection has the highest performance for normal traffic, with precision, recall, and F1-score values of 1.00, 0.97, and 0.98, respectively. With precision, recall, and F1-scores of 1, 0.94, and 0.97, respectively, the XGBoost and RF models with feature selection have the second-highest performance. The stacking model with feature selection has the highest performance for the replay attack, with precision, recall, and F1-score values of 0.97, 1.00, and 0.99, respectively. With precision, recall, and F1-scores of 0.94, 1.00, and 0.97, respectively, the XGBoost model with feature selection has the second-best performance. The stacking model with feature selection achieves the highest performance in detecting all types of attacks, making it the best model among those considered. The XGBoost model with feature selection is the second-best model, as it detects all types of attacks effectively. The performance of the RF and DT models is comparable across all attacks, with the exception of the fuzzing attack, where they perform slightly worse. The bagging and voting methods have the lowest performance among those evaluated. The evaluation results for each attack using the supervised models and ensemble methods without and with feature selection are shown in Table 6 and Table 7, respectively.
Figure 9 shows that incorporating feature selection into models and ensemble methods demonstrates that it reduces training and testing time for all models. The additional training time required for the stacking method with feature selection is a trade-off for improved performance. The stacking strategy requires the longest training time. Stacking is a technique that requires two distinct stages of training. In our experiment, there are three base classifiers and one meta-learner. Incorporating feature selection into models and ensemble methods reduces training and testing time. The use of tree-based models (RF, DT, and XGBoost) is well-suited for real-time deployment due to their efficient parallel processing capabilities and low inference latency. Although stacking involves a two-stage architecture that incurs a higher training cost, its real-time prediction performance remains practical. In addition, computational overhead is significantly reduced by selecting features, as evidenced by the shorter training and testing times seen in Figure 9. These factors collectively support the suitability of the proposed ensemble IDS for deployment in resource-constrained in-vehicle environments. Table 8 presents the hyperparameter configurations used for each supervised learning model in our study.
In Figure 10 for the stacking method, we visualize multiclassification using the AUC-ROC curve at each classification threshold. The False Positive Rate and the True Positive Rate are presented on the x-axis and the y-axis, respectively. It is preferable to have a high AUC-ROC score because this indicates the robustness of the model. Specifically, an AUC-ROC value near 1.0 indicates a robust model. In Figure 10, 0 represents DoS attacks, 1 represents fuzzing attacks, 2 represents normal messages, 3 represents replay attacks, and 4 represents spoofing attacks.
In Table 9, a comparison is presented of the proposed method and other promising recently proposed methods [53,54,55]. Evaluation metrics for the same dataset show promising results for our model. The experimental findings validate the effectiveness of the proposed IDS in detecting and classifying attacks against in-vehicle networks. Ensemble methods based on IDSs improve the efficiency with which these four attacks can be detected in the network’s traffic. Bagging, voting, and stacking are the three methods utilized in the development of ensemble classifiers. The results of the evaluation demonstrate that the proposed stacking method achieved the highest multiclassification performance while requiring more training and testing time. Stacking employs two stages to discover and learn how to effectively combine the individual models in the base learners with the meta learners, ultimately enhancing the performance of supervised classifiers.
Compared to deep learning-based IDS solutions (e.g., CNN-LSTM, GRU, etc.), our ensemble learning framework offers several advantages. First, it requires significantly less training data and computational resources, making it suitable for deployment in resource-constrained in-vehicle environments. Second, tree-based models are more interpretable, allowing developers to trace decisions back to input features. While deep learning methods often show strong generalization, they are prone to overfitting and require large labeled datasets, which are scarce in the automotive domain. A limitation of ensemble methods is that they may require longer training time when stacking is used, as seen in our timing analysis (Figure 9), but this tradeoff results in higher accuracy and robustness.

6. Conclusions

The CAN bus is vulnerable to various attacks as it lacks security features. We proposed a multi-classification intrusion detection system based on an ensemble learning solution to detect common CAN bus attacks (DoS, fuzzing, replay, and spoofing). We design an effective ensemble learning-based IDS scheme for classifying DoS, fuzzing, replay, and spoofing attacks. These are common CAN bus attacks that can threaten the safety of a vehicle’s driver, passengers, and pedestrians. Feature selection, data balancing, and hyperparameter tuning were all used to enhance the proposed scheme. The combination of these techniques and the ensemble learning methods resulted in a robust and accurate multi-classification IDS for common CAN bus attacks. With an F1-score of 0.993, precision of 0.993, recall of 0.993, and accuracy of 0.986, the stacking method outperformed other recently proposed methods, achieving the highest performance. However, stacking requires more training and testing time. While our results are promising, we acknowledge that the evaluation was conducted using a single dataset. Although the dataset is realistic and comprehensive in terms of attack types, this limitation may affect the generalizability of our findings. In future work, we aim to validate our IDS framework on multiple CAN bus datasets or in simulated real-time environments to ensure broader applicability and robustness.

Author Contributions

Conceptualization, E.A. and I.M.; methodology, E.A. and I.M.; software, E.A.; validation, E.A. and I.M.; formal analysis, E.A. and I.M.; investigation, E.A., I.M., B.A., and A.A.; writing—original draft preparation, review and editing, I.M.; visualization, E.A., B.A., and A.A.; supervision, I.M. and E.A.; writing—project administration, I.M. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data available upon request.

Acknowledgments

This work is part of the Smart Drive initiative at Tecore Networks Lab at Florida Atlantic University.

Conflicts of Interest

The authors declare that they have no conflicts of interest.

References

  1. Tang, F.; Mao, B.; Kato, N.; Gui, G. Comprehensive survey on machine learning in vehicular network: Technology, applications and challenges. IEEE Commun. Surv. Tutor. 2021, 23, 2027–2057. [Google Scholar] [CrossRef]
  2. He, J.; Ni, Y.; Cai, L.; Pan, J.; Chen, C. Optimal dropbox deployment algorithm for data dissemination in vehicular networks. IEEE Trans. Mob. Comput. 2017, 17, 632–645. [Google Scholar] [CrossRef]
  3. Han, R.; Guan, Q.; Yu, F.R.; Shi, J.; Ji, F. Congestion and position aware dynamic routing for the internet of vehicles. IEEE Trans. Veh. Technol. 2020, 69, 16082–16094. [Google Scholar] [CrossRef]
  4. Zhao, L.; Bi, Z.; Hawbani, A.; Yu, K.; Zhang, Y.; Guizani, M. ELITE: An intelligent digital twin-based hierarchical routing scheme for softwarized vehicular networks. IEEE Trans. Mob. Comput. 2022, 22, 5231–5247. [Google Scholar] [CrossRef]
  5. Slavik, M.; Mahgoub, I. Spatial distribution and channel quality adaptive protocol for multihop wireless broadcast routing in VANET. IEEE Trans. Mob. Comput. 2012, 12, 722–734. [Google Scholar] [CrossRef]
  6. Hasan, M.; Mohan, S.; Shimizu, T.; Lu, H. Securing vehicle-to-everything (V2X) communication platforms. IEEE Trans. Intell. Veh. 2020, 5, 693–713. [Google Scholar] [CrossRef]
  7. Ahmad, U.; Han, M.; Mahmood, S. Enhancing security in connected and autonomous vehicles: A pairing approach and machine learning integration. Appl. Sci. 2024, 14, 5648. [Google Scholar] [CrossRef]
  8. Lee, S.; Son, S.; Kwon, D.; Park, Y.; Park, Y. A Secure and Efficient Authentication Scheme for Fog-Based Vehicular Ad Hoc Networks. Appl. Sci. 2025, 15, 1229. [Google Scholar] [CrossRef]
  9. Kimm, H.; Ham, H.S. Integrated fault tolerant system for automotive bus networks. In Proceedings of the 2010 Second International Conference on Computer Engineering and Applications, Bali, Indonesia, 19–21 March 2010; IEEE: Piscataway, NJ, USA, 2010; Volume 1, pp. 486–490. [Google Scholar]
  10. Nilsson, D.K.; Phung, P.H.; Larson, U.E. Vehicle ECU classification based on safety-security characteristics. In Proceedings of the IET Road Transport Information and Control-RTIC 2008 and ITS United Kingdom Members’ Conference, Manchester, UK, 20–22 May 2008; IET: Stevenage, UK, 2008; pp. 1–7. [Google Scholar]
  11. Kelarestaghi, K.B.; Foruhandeh, M.; Heaslip, K.; Gerdes, R. Intelligent transportation system security: Impact-oriented risk assessment of in-vehicle networks. IEEE Intell. Transp. Syst. Mag. 2019, 13, 91–104. [Google Scholar] [CrossRef]
  12. Liu, J.; Zhang, S.; Sun, W.; Shi, Y. In-vehicle network attacks and countermeasures: Challenges and future directions. IEEE Netw. 2017, 31, 50–58. [Google Scholar] [CrossRef]
  13. Li, R.; Wu, J.; Wang, H.; Li, G. Design method of CAN BUS network communication structure for electric vehicle. In Proceedings of the International Forum on Strategic Technology 2010, Ulsan, Republic of Korea, 13–15 October 2010; IEEE: Piscataway, NJ, USA, 2010; pp. 326–329. [Google Scholar]
  14. Caviglia, R.; Gaggero, G.B.; Vincis, N.; Morando, O.; Aceti, A.; Marchese, M. SPAT: A Testbed for Automotive Cybersecurity Training. In Proceedings of the 2023 IEEE International Conference on Cyber Security and Resilience (CSR), Venice, Italy, 31 July–2 August 2023; pp. 381–386. [Google Scholar] [CrossRef]
  15. Pan, L.; Zheng, X.; Chen, H.; Luan, T.; Bootwala, H.; Batten, L. Cyber security attacks to modern vehicular systems. J. Inf. Secur. Appl. 2017, 36, 90–100. [Google Scholar] [CrossRef]
  16. Avatefipour, O.; Malik, H. State-of-the-art survey on in-vehicle network communication (CAN-Bus) security and vulnerabilities. arXiv 2018, arXiv:1802.01725. [Google Scholar]
  17. Alsolami, T.; Alsharif, B.; Ilyas, M. Enhancing Cybersecurity in Healthcare: Evaluating Ensemble Learning Models for Intrusion Detection in the Internet of Medical Things. Sensors 2024, 24, 5937. [Google Scholar] [CrossRef] [PubMed]
  18. Aliwa, E.; Rana, O.; Perera, C.; Burnap, P. Cyberattacks and countermeasures for in-vehicle networks. ACM Comput. Surv. 2021, 54, 21. [Google Scholar] [CrossRef]
  19. Rajapaksha, S.; Kalutarage, H.; Al-Kadri, M.O.; Petrovski, A.; Madzudzo, G.; Cheah, M. AI-based intrusion detection systems for in-vehicle networks: A survey. ACM Comput. Surv. 2023, 55, 237. [Google Scholar] [CrossRef]
  20. Miller, C.; Valasek, C. Remote Exploitation of an Unaltered Passenger Vehicle; Black Hat: San Francisco, CA, USA, 2015; Volume 2015, pp. 1–91. [Google Scholar]
  21. Wang, Q.; Qian, Y.; Lu, Z.; Shoukry, Y.; Qu, G. A delay based plug-in-monitor for intrusion detection in controller area network. In Proceedings of the 2018 Asian Hardware Oriented Security and Trust Symposium (AsianHOST), Hong Kong, China, 17–18 December 2018; IEEE: Piscataway, NJ, USA, 2018; pp. 86–91. [Google Scholar]
  22. Bozdal, M.; Samie, M.; Aslam, S.; Jennions, I. Evaluation of can bus security challenges. Sensors 2020, 20, 2364. [Google Scholar] [CrossRef]
  23. Fakhfakh, F.; Tounsi, M.; Mosbah, M. Cybersecurity attacks on CAN bus based vehicles: A review and open challenges. Libr. Hi Tech 2022, 40, 1179–1203. [Google Scholar] [CrossRef]
  24. Lokman, S.F.; Othman, A.T.; Abu-Bakar, M.H. Intrusion detection system for automotive Controller Area Network (CAN) bus system: A review. EURASIP J. Wirel. Commun. Netw. 2019, 2019, 184. [Google Scholar] [CrossRef]
  25. Wu, W.; Li, R.; Xie, G.; An, J.; Bai, Y.; Zhou, J.; Li, K. A survey of intrusion detection for in-vehicle networks. IEEE Trans. Intell. Transp. Syst. 2019, 21, 919–933. [Google Scholar] [CrossRef]
  26. Lampe, B.; Meng, W. Intrusion detection in the automotive domain: A comprehensive review. IEEE Commun. Surv. Tutor. 2023, 25, 2356–2426. [Google Scholar] [CrossRef]
  27. Gaggero, G.B.; Fausto, A.; Patrone, F.; Marchese, M. A Framework for Network Security Verification of Automated Vehicles in the Agricultural Domain. In Proceedings of the 2022 26th International Conference Electronics, Palanga, Lithuania, 13–15 June 2022; pp. 1–5. [Google Scholar] [CrossRef]
  28. Alalwany, E.; Alsharif, B.; Alotaibi, Y.; Alfahaid, A.; Mahgoub, I.; Ilyas, M. Stacking Ensemble Deep Learning for Real-Time Intrusion Detection in IoMT Environments. Sensors 2025, 25, 624. [Google Scholar] [CrossRef] [PubMed]
  29. Alalwany, E.; Mahgoub, I. Classification of Normal and Malicious Traffic Based on an Ensemble of Machine Learning for a Vehicle CAN-Network. Sensors 2022, 22, 9195. [Google Scholar] [CrossRef] [PubMed]
  30. Alhowaide, A.; Alsmadi, I.; Tang, J. Ensemble detection model for IoT IDS. Internet Things 2021, 16, 100435. [Google Scholar] [CrossRef]
  31. Pham, N.T.; Foo, E.; Suriadi, S.; Jeffrey, H.; Lahza, H.F.M. Improving performance of intrusion detection system using ensemble methods and feature selection. In Proceedings of the Australasian Computer Science Week Multiconference, Brisband, Australia, 29 January–2 February 2018; pp. 1–6. [Google Scholar]
  32. Bosch, C. Specification Version 2.0; Robert Bosch GmbH: Gerlingen, Germany, 1991; Volume 1. [Google Scholar]
  33. Mehedi, S.T.; Anwar, A.; Rahman, Z.; Ahmed, K. Deep transfer learning based intrusion detection system for electric vehicular networks. Sensors 2021, 21, 4736. [Google Scholar] [CrossRef]
  34. Mathur, R.; Saraswat, R.; Mathur, G. An Analytical Study of Communication Protocols Used in Automotive Industry. Int. J. Eng. Res. Technol. 2018, 2, 287–292. [Google Scholar]
  35. Bozdal, M.; Samie, M.; Jennions, I. A survey on can bus protocol: Attacks, challenges, and potential solutions. In Proceedings of the 2018 International Conference on Computing, Electronics & Communications Engineering (iCCECE), Southend, UK, 16–17 August 2018; IEEE: Piscataway, NJ, USA, 2018; pp. 201–205. [Google Scholar]
  36. Song, H.M.; Kim, H.R.; Kim, H.K. Intrusion detection system based on the analysis of time intervals of CAN messages for in-vehicle network. In Proceedings of the 2016 International Conference on Information Networking (ICOIN), Kota Kinabalu, Malaysia, 13–15 January 2016; IEEE: Piscataway, NJ, USA, 2016; pp. 63–68. [Google Scholar]
  37. Lee, H.; Jeong, S.H.; Kim, H.K. OTIDS: A novel intrusion detection system for in-vehicle network by using remote frame. In Proceedings of the 2017 15th Annual Conference on Privacy, Security and Trust (PST), Calgary, AB, Canada, 28–30 August 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 57–5709. [Google Scholar]
  38. Groza, B.; Murvay, P.S. Efficient intrusion detection with bloom filtering in controller area networks. IEEE Trans. Inf. Forensics Secur. 2018, 14, 1037–1051. [Google Scholar] [CrossRef]
  39. Alsulaiman, L.; Al-Ahmadi, S. Performance evaluation of machine learning techniques for DOS detection in wireless sensor network. arXiv 2021, arXiv:2104.01963. [Google Scholar] [CrossRef]
  40. Rahal, R.; Amara Korba, A.; Ghoualmi-Zine, N. Towards the development of realistic dos dataset for intelligent transportation systems. Wirel. Pers. Commun. 2020, 115, 1415–1444. [Google Scholar] [CrossRef]
  41. Seo, E.; Song, H.M.; Kim, H.K. GIDS: GAN based intrusion detection system for in-vehicle network. In Proceedings of the 2018 16th Annual Conference on Privacy, Security and Trust (PST), Belfast, Ireland, 28–30 August 2018; IEEE: Piscataway, NJ, USA, 2018; pp. 1–6. [Google Scholar]
  42. Martinelli, F.; Mercaldo, F.; Nardone, V.; Santone, A. Car hacking identification through fuzzy logic algorithms. In Proceedings of the 2017 IEEE International Conference on Fuzzy Systems (FUZZ-IEEE), Naples, Italy, 9–12 July 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 1–7. [Google Scholar]
  43. Alshammari, A.; Zohdy, M.A.; Debnath, D.; Corser, G. Classification approach for intrusion detection in vehicle systems. Wirel. Eng. Technol. 2018, 9, 79–94. [Google Scholar] [CrossRef]
  44. Zaidi, K.; Milojevic, M.B.; Rakocevic, V.; Nallanathan, A.; Rajarajan, M. Host-based intrusion detection for VANETs: A statistical approach to rogue node detection. IEEE Trans. Veh. Technol. 2015, 65, 6703–6714. [Google Scholar] [CrossRef]
  45. Alalwany, E.; Mahgoub, I. Security and Trust Management in the Internet of Vehicles (IoV): Challenges and Machine Learning Solutions. Sensors 2024, 24, 368. [Google Scholar] [CrossRef] [PubMed]
  46. Huang, T.; Zhou, J.; Bytes, A. ATG: An attack traffic generation tool for security testing of in-vehicle CAN bus. In Proceedings of the 13th International Conference on Availability, Reliability and Security, Hamburg, Germany, 27–30 August 2018; pp. 1–6. [Google Scholar]
  47. Nandy, T.; Noor, R.M.; Kolandaisamy, R.; Idris, M.Y.I.; Bhattacharyya, S. A review of security attacks and intrusion detection in the vehicular networks. J. King Saud Univ.-Comput. Inf. Sci. 2024, 36, 101945. [Google Scholar] [CrossRef]
  48. Song, H.M.; Woo, J.; Kim, H.K. In-vehicle network intrusion detection using deep convolutional neural network. Veh. Commun. 2020, 21, 100198. [Google Scholar] [CrossRef]
  49. Xiao, J.; Wu, H.; Li, X. Internet of things meets vehicles: Sheltering in-vehicle network through lightweight machine learning. Symmetry 2019, 11, 1388. [Google Scholar] [CrossRef]
  50. Hossain, M.D.; Inoue, H.; Ochiai, H.; Fall, D.; Kadobayashi, Y. LSTM-based intrusion detection system for in-vehicle can bus communications. IEEE Access 2020, 8, 185489–185502. [Google Scholar] [CrossRef]
  51. Yang, Y.; Duan, Z.; Tehranipoor, M. Identify a spoofing attack on an in-vehicle CAN bus based on the deep features of an ECU fingerprint signal. Smart Cities 2020, 3, 17–30. [Google Scholar] [CrossRef]
  52. Javed, A.R.; Ur Rehman, S.; Khan, M.U.; Alazab, M.; Reddy, T. CANintelliIDS: Detecting in-vehicle intrusion attacks on a controller area network using CNN and attention-based GRU. IEEE Trans. Netw. Sci. Eng. 2021, 8, 1456–1466. [Google Scholar] [CrossRef]
  53. Baldini, G. Detection of cybersecurity spoofing attacks in vehicular networks with recurrence quantification analysis. Comput. Commun. 2022, 191, 486–499. [Google Scholar] [CrossRef]
  54. Aldhyani, T.H.; Alkahtani, H. Attacks to automatous vehicles: A deep learning algorithm for cybersecurity. Sensors 2022, 22, 360. [Google Scholar] [CrossRef]
  55. Refat, R.U.D.; Elkhail, A.A.; Hafeez, A.; Malik, H. Detecting CAN bus intrusion by applying machine learning method to graph based features. In Intelligent Systems and Applications, Proceedings of the 2021 Intelligent Systems Conference (IntelliSys), Virtual, 2–3 September 2021; Springer: Cham, Switzerland, 2022; Volume 3, pp. 730–748. [Google Scholar]
  56. Al-Saud, M.; Eltamaly, A.M.; Mohamed, M.A.; Kavousi-Fard, A. An intelligent data-driven model to secure intravehicle communications based on machine learning. IEEE Trans. Ind. Electron. 2019, 67, 5112–5119. [Google Scholar] [CrossRef]
  57. Kang, H.; Kwak, B.; Lee, Y.H.; Lee, H.; Lee, H.; Kim, H. Car Hacking: Attack and Defense Challenge 2020 Dataset; IEEE DataPort; IEEE: Piscataway, NJ, USA, 2021. [Google Scholar]
  58. Dash, M.; Liu, H. Feature selection for classification. Intell. Data Anal. 1997, 1, 131–156. [Google Scholar] [CrossRef]
  59. Bao, L.; Juan, C.; Li, J.; Zhang, Y. Boosted near-miss under-sampling on SVM ensembles for concept detection in large-scale imbalanced datasets. Neurocomputing 2016, 172, 198–206. [Google Scholar] [CrossRef]
  60. Breiman, L. Random forests. Mach. Learn. 2001, 45, 5–32. [Google Scholar] [CrossRef]
  61. Song, Y.Y.; Ying, L. Decision tree methods: Applications for classification and prediction. Shanghai Arch. Psychiatry 2015, 27, 130. [Google Scholar]
  62. Chen, T.; He, T.; Benesty, M.; Khotilovich, V.; Tang, Y.; Cho, H.; Chen, K.; Mitchell, R.; Cano, I.; Zhou, T.; et al. XGBoost: Extreme Gradient Boosting, R Package Version 0.4–2; R Foundation for Statistical Computing: Vienna, Austria, 2015; Volume 1, pp. 1–4. [Google Scholar]
  63. Wolpert, D.H. Stacked generalization. Neural Netw. 1992, 5, 241–259. [Google Scholar] [CrossRef]
  64. Hothorn, T.; Lausen, B. Double-bagging: Combining classifiers by bootstrap aggregation. Pattern Recognit. 2003, 36, 1303–1309. [Google Scholar] [CrossRef]
  65. Quinlan, J.R. Bagging, boosting, and C4.5. In Proceedings of the AAAI/IAAI, Portland, OR, USA, 4–8 August 1996; Volume 1, pp. 725–730. [Google Scholar]
  66. Dietterich, T.G. Ensemble learning. In The Handbook of Brain Theory and Neural Networks; MIT Press: Cambridge, MA, USA, 2002; Volume 2, pp. 110–125. [Google Scholar]
  67. Purohit, S.; Govindarasu, M. ML-based anomaly detection for intra-vehicular CAN-bus networks. In Proceedings of the 2022 IEEE International Conference on Cyber Security and Resilience (CSR), Rhodes, Greece, 27–29 July 2022; IEEE: Piscataway, NJ, USA, 2022; pp. 233–238. [Google Scholar]
  68. Arlot, S.; Celisse, A. A survey of cross-validation procedures for model selection. Stat. Surv. 2010, 4, 40–79. [Google Scholar] [CrossRef]
  69. Bari, B.S.; Yelamarthi, K.; Ghafoor, S. Intrusion detection in vehicle controller area network (can) bus using machine learning: A comparative performance study. Sensors 2023, 23, 3610. [Google Scholar] [CrossRef]
Figure 1. The structure of a CAN packet frame.
Figure 1. The structure of a CAN packet frame.
Applsci 15 06869 g001
Figure 2. DoS attack sends two messages with the high-priority CAN ID 0x000.
Figure 2. DoS attack sends two messages with the high-priority CAN ID 0x000.
Applsci 15 06869 g002
Figure 3. Fuzzing attack generated random messages with CAN IDs that appear as legitimate IDs.
Figure 3. Fuzzing attack generated random messages with CAN IDs that appear as legitimate IDs.
Applsci 15 06869 g003
Figure 4. Replay attack transmitting the CAN IDs that belong to the legitimate node.
Figure 4. Replay attack transmitting the CAN IDs that belong to the legitimate node.
Applsci 15 06869 g004
Figure 5. Spoofing attack injects messages with specified CAN IDs belonging to the authorized node.
Figure 5. Spoofing attack injects messages with specified CAN IDs belonging to the authorized node.
Applsci 15 06869 g005
Figure 6. The overview of the workflow of the proposed scheme.
Figure 6. The overview of the workflow of the proposed scheme.
Applsci 15 06869 g006
Figure 7. The steps and evaluation of our proposed scheme.
Figure 7. The steps and evaluation of our proposed scheme.
Applsci 15 06869 g007
Figure 8. The comparison between ensemble methods and supervised models.
Figure 8. The comparison between ensemble methods and supervised models.
Applsci 15 06869 g008
Figure 9. Comparing training and testing times in (s) for all models with and without feature selection.
Figure 9. Comparing training and testing times in (s) for all models with and without feature selection.
Applsci 15 06869 g009
Figure 10. The ROC results for stacking method.
Figure 10. The ROC results for stacking method.
Applsci 15 06869 g010
Table 1. Affected security requirements.
Table 1. Affected security requirements.
AttackAvailabilityIntegrityAuthenticityNon-RepudiationConfidentiality
DoS [40]+
Fuzzing [41,42]++
Replay [43] ++++
Spoofing [44] ++
“+” as it affects the security requirements.
Table 2. Our proposed method compared to recently proposed promising approaches.
Table 2. Our proposed method compared to recently proposed promising approaches.
CitationModelFeature SelectionBalancedHyperparametersEnsemble MethodsType of Attacks
[48]DCNNNot reported+DoS, fuzzing, and spoofing
[49]RNNNot reportedNot reported+DoS, fuzzing, and impersonation
[50]LSTM+DoS, fuzzing, and spoofing
[51]RNNManual feature extractionspoofing
[52]CNN and GRUdeep feature selection via CNN+DoS, fuzzing, and impersonation
[53]MLRQA+spoofing
[54]CNN-LSTMImplicit via CNN layers+DoS and fuzzing
[55]SVM
KNN
Heuristic Feature SelectionDoS, fuzzing, and spoofing
OursStackingExtra Trees+++DoS, fuzzing, spoofing, and replay
“+” as a strength and “−” as a weakness.
Table 3. The distribution of normal and attack messages.
Table 3. The distribution of normal and attack messages.
Message TypeCountPercentage (%)
Normal3,372,74391.846523
DoS154,1804.198629
Fuzzing89,8792.447585
Replay47,5931.296052
Spoofing77560.211211
Total3,672,151100
Table 4. The evaluation results using 10-fold cross-validation of the supervised models and ensemble methods without feature selection.
Table 4. The evaluation results using 10-fold cross-validation of the supervised models and ensemble methods without feature selection.
ModelAccuracy
1 2 3 4 5 6 7 8 9 10 Mean
RF0.9930.9970.9930.9920.9940.9960.9830.9920.9750.8190.973
DT0.9870.9930.9900.9940.9930.9930.9810.9880.9740.8200.971
XGBoost1.001.001.000.9980.9980.9980.9981.000.9970.8330.982
Stacking1.001.001.001.000.9981.000.9980.9980.9960.8760.986
voting0.9880.9980.9980.9960.9940.9930.9900.9900.9790.8210.975
Bagging0.9931.000.9940.9930.9930.9960.9840.9980.9810.8230.976
Table 5. The evaluation results using 10-fold cross-validation of the supervised models and ensemble methods with feature selection.
Table 5. The evaluation results using 10-fold cross-validation of the supervised models and ensemble methods with feature selection.
ModelAccuracy
1 2 3 4 5 6 7 8 9 10 Mean
RF0.9930.9970.9970.9900.9870.9960.9900.9900.9870.8560.978
DT0.9670.9920.9900.9870.9920.9930.9840.9850.9660.8580.971
XGBoost1.001.001.000.9970.9971.001.000.9971.000.8580.985
Stacking1.001.001.001.001.001.000.9981.001.000.8680.986
voting0.9870.9940.9960.9920.9940.9960.9960.9960.9810.8550.979
Bagging1.001.001.000.9970.9981.000.9980.9970.9980.8650.985
Table 6. The evaluation results for each attack using the supervised models and ensemble methods without feature selection.
Table 6. The evaluation results for each attack using the supervised models and ensemble methods without feature selection.
ModelAttacksPrecisionRecallF1-Score
RFFlooding1.001.001.00
Fuzzing0.991.001.00
Normal1.000.920.96
Replay0.920.990.96
Spoofing1.001.001.00
DTFlooding1.001.001.00
Fuzzing1.000.990.99
Normal1.000.920.96
Replay0.920.990.95
Spoofing0.991.000.99
XGBoostFlooding1.001.001.00
Fuzzing1.001.001.00
Normal1.000.920.96
Replay0.931.000.96
Spoofing1.001.001.00
StackingFlooding1.001.001.00
Fuzzing1.001.001.00
Normal1.000.930.97
Replay0.941.000.97
Spoofing1.001.001.00
BaggingFlooding1.001.001.00
Fuzzing0.991.000.99
Normal0.990.920.96
Replay0.920.980.95
Spoofing1.001.001.00
VotingFlooding0.991.000.99
Fuzzing1.000.990.99
Normal1.000.890.94
Replay0.900.990.95
Spoofing1.001.001.00
Table 7. The evaluation results for each attack using the supervised models and ensemble methods with feature selection.
Table 7. The evaluation results for each attack using the supervised models and ensemble methods with feature selection.
ModelAttacksPrecisionRecallF1-Score
RFFlooding1.001.001.00
Fuzzing0.991.001.00
Normal1.000.930.96
Replay0.931.000.96
Spoofing1.001.001.00
DTFlooding1.001.001.00
Fuzzing1.000.990.99
Normal1.000.930.96
Replay0.991.000.99
Spoofing0.931.000.96
XGBoostFlooding1.001.001.00
Fuzzing1.001.001.00
Normal1.000.940.97
Replay0.941.000.97
Spoofing1.001.001.00
StackingFlooding1.001.001.00
Fuzzing1.001.001.00
Normal1.000.970.98
Replay0.971.000.99
Spoofing1.001.001.00
BaggingFlooding1.001.001.00
Fuzzing0.991.000.99
Normal0.990.920.95
Replay0.930.980.95
Spoofing1.001.001.00
VotingFlooding0.991.000.99
Fuzzing1.001.001.00
Normal1.000.920.96
Replay0.930.990.96
Spoofing1.001.001.00
Table 8. Hyperparameter configurations for supervised learning models.
Table 8. Hyperparameter configurations for supervised learning models.
ModelHyperparameterValue
Random Forestmax_features‘auto’
n_estimators100
max_depth20
min_samples_leaf2
min_samples_split5
XGBoostn_jobs−1
max_depth3
n_estimators300
objective‘multi:softprob’
Decision Treemax_depth20
max_features‘log2’
Table 9. Our method compared to promising current approaches.
Table 9. Our method compared to promising current approaches.
CitationAttacksModelPrecisionRecallF1-ScoreROC
[69]FloodKNN0.990.990.99-
Accuracy0.96
SVM0.990.990.99-
Accuracy0.97
FuzzingSVM1.000.960.97-
Accuracy0.97
KNN0.990.960.97-
Accuracy0.96
[53]SpoofingKNN-based RQA, K = 8 0.959
Accuracy0.914
DT-based RQA 0.85
Accuracy0.853
KNN-based RQA, K = 7 0.950
Accuracy0.927
[54]BenignCNN-LSTM0.991.00991.00
Flood0.6611180.77
Fuzzing971.000.990.91
Accuracy0.9730
[55]DoSSVM0.990.990.990.99
KNN0.990.990.990.99
FuzzingSVM0.990.990.990.99
KNN0.990.980.990.98
SpoofingSVM0.970.930.950.93
KNN0.970.930.950.93
Mix attackKNN0.980.960.970.96
Accuracy0.9792
SVM0.980.960.970.96
Accuracy0.9799
OurFloodStacking1.001.001.001.00
Fuzzing1.001.001.001.00
Normal1.000.970.981.00
Replay0.971.000.991.00
Spoofing1.001.001.001.00
Accuracy0.986
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Alalwany, E.; Mahgoub, I.; Alsharif, B.; Alfahaid, A. An Intelligent Ensemble-Based Detection of In-Vehicle Network Intrusion. Appl. Sci. 2025, 15, 6869. https://doi.org/10.3390/app15126869

AMA Style

Alalwany E, Mahgoub I, Alsharif B, Alfahaid A. An Intelligent Ensemble-Based Detection of In-Vehicle Network Intrusion. Applied Sciences. 2025; 15(12):6869. https://doi.org/10.3390/app15126869

Chicago/Turabian Style

Alalwany, Easa, Imad Mahgoub, Bader Alsharif, and Abdullah Alfahaid. 2025. "An Intelligent Ensemble-Based Detection of In-Vehicle Network Intrusion" Applied Sciences 15, no. 12: 6869. https://doi.org/10.3390/app15126869

APA Style

Alalwany, E., Mahgoub, I., Alsharif, B., & Alfahaid, A. (2025). An Intelligent Ensemble-Based Detection of In-Vehicle Network Intrusion. Applied Sciences, 15(12), 6869. https://doi.org/10.3390/app15126869

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop