Abstract
As 5G Standalone Core networks grow, Application Programming Interface (APIs) have become a key part of how network systems talk to each other. They allow different functions to share data and complete tasks quickly. However, this also makes them targets for attacks. 5G Standalone Core networks rely on Service-Based Architecture (SBA), where network functions communicate through exposed APIs. These APIs are attractive targets for cyberattacks because they are externally accessible, handle sensitive control-plane operations, and exchange structured data using Hypertext Transfer Protocol version 2 (HTTP/2) and JavaScript Object Notation (JSON) protocols. Most older security tools work using fixed rules, which cannot always detect new or changing threats. This study aimed to fix that gap by using Artificial Intelligence to make API security smarter. Two AI models were tested: Long Short-Term Memory (LSTM), which learns from past traffic and Reinforcement Learning (RL), which learns by adapting to network behavior. Both were used to assess API traffic and assign a real-time risk score. Synthetic traffic was created using Python, including both normal API calls and different types of attacks like Distributed Denial-of-Service (DDoS), brute force, and Structured Query Language (SQL) injection. The results show that both LSTM and RL models were better than traditional rule-based systems. They found more threats, gave fewer false alerts, and responded faster. RL was especially strong at handling unknown or changing attacks. Experimental results show that the proposed LSTM and RL models achieved approximately 95% detection accuracy, significantly outperforming the static rule-based baseline model, which achieved 58% accuracy. The results demonstrate the effectiveness of adaptive AI-based security mechanisms for detecting evolving API threats. This research shows that AI can help protect 5G APIs in a smarter and more flexible way. It can support telecom networks by making threat detection faster, more accurate, and ready for future challenges.
1. Introduction
The rapid rollout of 5G Standalone (SA) Core networks has transformed mobile communication by enabling ultra-fast data transfer, lower latency, and real-time connectivity. These APIs help different network functions talk to each other in real time. But as helpful as they are, APIs also create new risks. When APIs are open to external systems, they can be attacked by hackers [1,2,3]. Many existing security systems use fixed rules to detect threats. These tools check for known attack patterns [4]. If a threat looks different, the system may miss it [5,6]. This kind of static security does not work well with today’s smart and fast-changing cyberattacks [7,8,9]. Attackers now use advanced tricks to hide inside normal traffic. They also spread their attacks over time, making it harder to detect them early. In 5G networks, even a short delay in stopping an attack can cause serious problems [10,11,12,13]. This research looks at a better way to protect 5G APIs. It uses Artificial Intelligence (AI) to create a system that learns from traffic, scores each request, and acts quickly if something looks risky. The goal is to build a smarter, faster, and more flexible way to detect and stop threats in real time.
To do this, two AI models were used—Long Short-Term Memory (LSTM) and Reinforcement Learning (RL). LSTM helps the system learn from past traffic patterns. RL helps it learn how to take smart actions based on changing situations. Both models were trained using synthetic API traffic that looked like real 5G traffic. The data included normal requests and attack types like DoS, brute force, and SQL injection [14,15,16,17].
The project followed four clear objectives:
- Design a dynamic risk assessment framework using AI models (LSTM and RL) to score API requests and support fast, smart decisions.
- Develop a Python-based simulation to create synthetic 5G API traffic with both normal and harmful requests.
- Test how well the AI models perform in detecting different types of attacks and compare their results under various conditions.
- Compare the AI models with traditional static security methods using clear metrics like accuracy, false alerts, speed, and how well they stop threats.
The system was built using Python version 3.14 tools—TensorFlow, Keras, Scikit-learn, and Locust. Traffic was created using Scapy and OWASP ZAP to simulate real attacks. Each request was given a risk score, and the models learned to detect harmful traffic from this labeled data. The findings demonstrated that the AI models worked much better than the old rule-based system. They found more threats, made fewer mistakes, and responded faster. The RL model was especially good at learning and adapting to new attack types. This paper is structured as follows: It starts with a review of past research and the gaps that still exist. Then, it explains the system design, the dataset, and the AI models. After that, it presents the results and compares them with static models. The paper ends with a discussion, conclusion, and suggestions for future improvements. This research shows how AI can help keep 5G networks safer. It offers a tested and working system that can be used and improved further. It fills several research and technical gaps by introducing dynamic, learning-based threat detection. The approach offers promising results that could support telecom operators and cybersecurity teams in protecting future 5G and beyond networks.
This study makes three main contributions. First, it proposes an AI-driven framework for detecting malicious behavior in 5G SA Core APIs. Second, it integrates sequential anomaly detection using an LSTM model with adaptive decision making using a Reinforcement Learning RL agent. Third, the framework demonstrates how dynamic risk scoring can support automated mitigation decisions, such as allowing or blocking suspicious API requests in Service-Based Architecture environments.
2. Literature Review
The growing importance of securing APIs in 5G Standalone (SA) Core networks has brought new attention to smarter, adaptive cybersecurity methods [18,19]. Most earlier security approaches were built on static rules, which are not enough to handle dynamic threats in modern telecom systems. Many researchers have looked into how machine learning (ML) and Artificial Intelligence (AI) might be used to enhance threat detection, especially for network traffic analysis [20,21]. However, very few studies focus specifically on the 5G SA Core API layer, which is more sensitive and more exposed to external systems [22].
Ref. [20] focuses on identifying vulnerabilities inside the 5G Core (5GC) network. It uses a vulnerability assessment framework based on the IEC 62443 standard. The study looks at insider threats targeting network functions (NFs) like the NRF and AMF, using the OpenAirInterface (OAI) as a testbed. It does not use AI or machine learning models. Instead, it relies on manual vulnerability analysis and experimental attacks. The paper highlights dynamic insider threats like NF deregistration and spoofing, but does not propose adaptive learning-based solutions. The key gaps are the lack of AI-based detection and scoring systems for evolving insider threats. The paper suggests further work is needed for automated, dynamic security in 5G Core networks.
5G related another study [23] provides a detailed overview of 5G network security. It explains the security features of the 5G core and Service-Based Architecture (SBA). The focus is on improving authentication, encryption, and subscriber privacy. The guide does not use AI algorithms or machine learning for real-time threat detection. Instead, it discusses standard protocols and security models, like Zero Trust and OAuth 2.0, to protect 5G Core APIs and interfaces. This work does not study dynamic threat learning but highlights static security practices and framework-based controls. While it outlines API security challenges, it does not propose or test AI-driven solutions like LSTM or RL. The paper recommends strong encryption and secure design but lacks scoring mechanisms for real-time API risk detection. Therefore, it does not address dynamic API threat adaptation.
A particular study in [24] gives a wide view of cybersecurity threats and solutions in modern digital networks. Its key focus is on explaining different types of vulnerabilities in hardware, software, and network layers. The paper also talks about common attacks like DDoS, phishing, and ransomware. Machine learning and Deep Learning are discussed as modern solutions to detect such attacks. However, the paper does not focus on 5G Core or API protection directly. Instead, it gives a general review of security risks across all technologies. The algorithms mentioned are mostly ML and DL-based classifiers but are not applied to dynamic threats in 5G APIs. There is no clear scoring mechanism or model training shown in this work. Overall, AI is discussed as a helpful tool, but no LSTM or RL algorithms were used for real-time detection.
One of the early attempts to use LSTM for network security was in [2]. This study used time-based patterns in network flows to detect anomalies. While effective in identifying slow and long-term attacks, it was not tailored for the lightweight, high-frequency nature of API requests in 5G Core networks. Moreover, the dataset used was the classic NSL-KDD, which is not representative of 5G systems.
In terms of explainability, several papers like [25] highlighted questions regarding deep learning algorithms’ black-box nature. While LSTM and RL offer high accuracy, their internal decisions are hard to interpret.
Recent studies in federated intrusion detection have highlighted the robust aggregation as well as model architectures that need to withstand adversarial manipulation. Rezaei et al. Recommend a Federated Recurrent Neural Network (RNN) framework that consolidates defense strategies with simulations of adversarial attack to secure federated learning-based Intrusion Detection System for IoT environments, representing superior clustering-based aggregation functions performance compared with Federated Averaging under the scenarios of attack [26]. Moreover, Graph-based clustering as Aggregation for Federated Intrusion Detection System (GRAF IDS) presents graph-based clustering at the aggregation phase, which reinforces resilience alongside sophisticated attacks by identifying trustworthy model updates through structural similarity, outperforming both Federated Averaging and traditional Byzantine resilient methods. These studies prove that advanced aggregation strategies and temporal models, such as RNN with federated learning, meaningfully enhance the capability of intrusion detection systems for adapting securely and dynamically adjusting with emerging trends in AI-powered cybersecurity for distributed networks [27].
Discussions of AI in [28] mainly focuses on how Explainable AI (XAI) can help improve trust and security in beyond 5G (B5G) networks. The authors discuss various AI and ML techniques used in B5G, but their key focus is not on protecting the 5G Core APIs directly. Instead, they cover many technical areas like IoT, RAN, edge computing, and network slicing. The paper highlights how black-box AI models can create trust issues because their actions are hard to explain. They propose XAI as a way to make AI-based security systems more transparent and accountable. No specific AI algorithms like LSTM or RL were tested, and there was no focus on dynamic threat detection or risk scoring for APIs. So, the paper is useful for understanding future trends, but it does not solve 5G Core API protection challenges like this thesis did.
A related study [29] gives a full review of 5G Core security. It focuses on the Service-Based Architecture (SBA), network functions and key protocols like OAuth and TLS. The paper highlights security gaps in 5G Core, including API exposure risks through the Common API Framework (CAPIF). It also discusses threats from weak authentication and signaling vulnerabilities. The authors do not test AI algorithms but mention future directions like AI/ML-based security monitoring. The work is not directly about 5G Core API protection or dynamic threat learning. Instead, it focuses on summarizing security challenges and technical gaps. There is no scoring mechanism, detection accuracy, or AI-based risk handling discussed. This shows a gap where AI solutions like LSTM and RL could improve real-time threat detection for API protection. Ref. [22] mainly focuses on penetration testing as a way to find security gaps in 5G networks. The author explores how 5G brings new risks due to features like edge computing, network slicing, and massive MIMO. It discusses different penetration testing tools like Metasploit, Nessus and OpenVAS. However, the paper does not focus on protecting 5G Core APIs. Instead, it looks at the overall network vulnerabilities. No AI or ML algorithms were applied in this work. It also does not handle dynamic threats using learning models. Instead, it focuses on manual and tool-based testing. The paper suggests that new tools should be created for 5G, but does not provide adaptive or learning-based solutions.
The ML-related study in [30] focused on securing 5G network applications throughout their entire lifecycle. It proposed a new model combining application validation with an AI-based reactive security system. The model used machine learning (ML) algorithms to detect and then respond to real-time threats. It also validated network applications before deployment to reduce risks. The key areas were Network Function Virtualization (NFV), dynamic threat response, and security testing. The paper was not directly related to 5G Core API protection but focused on securing network apps running over 5G. AI was used for dynamic monitoring and response, but it did not use LSTM or RL algorithms. Instead, it applied reactive ML techniques. The study helped address the dynamic nature of threats but did not cover API-level security of the 5G Core.
One more study [31] mainly focuses on building an ontology (structured framework) to classify and understand hybrid threats in 5G networks. It studies various EU cybersecurity frameworks, especially ENISA’s 5G Threat Taxonomy, and integrates them into a common threat classification system. The research highlights risks in 5G network layers like SDN, NFV, and cloud, but it does not directly focus on 5G Core API protection. The paper does not use AI or machine learning algorithms; instead, it uses ontology design tools like RDF and OWL to model threats. It talks about evolving threats, but does not focus on learning from dynamic threats. Overall, it focuses on creating a clear understanding of 5G security risks but does not propose detection algorithms or AI-based solutions. Ref. [21] mainly focuses on protecting the 5G Core network from internal and external attacks. The authors propose a system called PROV5GC that uses provenance graphs to detect and track security attacks inside the 5G Core. Their work studies 3 types of attacks: slicing attacks, signaling storm attacks, and PFCP protocol attacks. The paper is directly related to 5G Core, but it does not focus on API protection specifically. Instead, it protects the network functions and their communication. The authors do not use AI or ML algorithms in their solution. Instead, they use graph-based detection and anomaly detection methods. Their approach does not learn dynamically from changing threats, but monitors call flow patterns in a structured way. The key contribution is a detection system that provides attack attribution inside the core.
The study [32] presents a wide review of the evolving security challenges in 5G networks. The focus is on classifying 5G threats, identifying gaps in current defenses and describing security needs across different use cases like smart cities and healthcare. It discusses the use of advanced technologies such as NFV, SDN, MEC, and Trusted Execution Environments (TEEs). Artificial Intelligence (AI) and machine learning (ML) are mentioned as future security enablers, but no specific AI algorithms or dynamic threat learning solutions were implemented in this work. Instead, the paper maps threats using a taxonomy and explains potential future security enablers. This study is related to the 5G Core in a broad sense, but does not focus on API protection for the 5G Core. It serves as a foundation for future security frameworks but does not build dynamic AI-based solutions itself.
A related study [33] mainly studies the security risks in 5G network slicing. The authors have broken down the slicing lifecycle into stages and listed over 70 security threats in these stages. The work focuses on virtual network slices inside 5G, including slicing in the core network. It covers technologies like SDN and NFV, but does not work on API protection specifically. It also does not propose an AI-based model for threat detection. Instead, it discusses security requirements and suggestions to improve security in slicing operations. The paper does mention machine learning in other related works, but does not implement it. It does not work on dynamic threat learning but highlights that 5G slicing has dynamic threat surfaces. Overall, the paper is more about summarizing known threats rather than building an active defense mechanism. Ref. [34] mainly focuses on studying the security of critical 5G network interfaces. It looks at how these interfaces connect different network functions in the 5G Core. The key focus is on identifying vulnerabilities in these interfaces using the STRIDE model, which lists threats like spoofing and denial of service. The paper does not use AI or machine learning algorithms. Instead, it is based on analyzing architecture and security policies. The study highlights how sensitive data flows through these interfaces and why protecting them is critical. However, it does not cover API security or AI-based dynamic learning. It is related to the 5G Core but focuses on architectural vulnerabilities, not API protection or dynamic threat learning.
One more study mainly focuses on security concerns in [35], a key part of the 5G Core. It reviews the vulnerabilities found in slice creation, communication, management, and end devices. The paper highlights critical threats like side-channel attacks, DoS/DDoS attacks, and inter-slice communication risks. It does not propose AI-based solutions but mentions that AI/ML could improve slice security in the future. The research does not include practical AI models or dynamic learning against evolving threats. Instead, it offers a detailed review of traditional and architectural security measures like isolation and SDN/NFV protection. The paper relates to the 5G Core but does not directly address API protection for external threats. Its work is mostly static, analyzing vulnerabilities rather than adapting to real-time attacks. Title of the paper:
This study [20] focuses on testing the security of two open-source 5G core projects: Open5GS and OpenAirInterface (OAI). The study mainly looks at two network functions: AMF and NRF/NEF, and their Service-Based Interface (SBI). The research checks for vulnerabilities like DoS, replay, and API injection attacks. It is clearly related to the 5G core but does not provide solutions for API protection. The paper does not use AI or machine learning models. It focuses on experimental testing rather than dynamic learning of threats. The vulnerabilities are tested using manual and tool-based simulations like Burp Suite and 5Greplay. The study highlights the gaps in secure software development but does not propose an AI-driven solution.
Another paper [36] studies how Artificial Intelligence (AI) and machine learning (ML) are helping wireless networks, including 5G, become smarter and more secure. It explains the risks of using AI in mobile networks, such as new attack types and vulnerabilities in AI models. The paper discusses AI use in different network parts like RAN, Core, and edge, but does not specifically cover 5G Core API protection. It talks about AI techniques like anomaly detection and network optimization but does not mention any particular algorithms like LSTM or Reinforcement Learning. The paper highlights that AI can adapt to changing threats, but it does not present any dynamic learning models in use. It mostly gives recommendations for how AI should be secured using frameworks, with no experimental results shown. Ref. [37] highlighted how AI can detect threats in telecom networks. It spoke about automation and anomaly detection, but only at a general level. There was no mention of APIs or scoring-based decisions. Another paper [18], suggested using AI to automate threat response across different layers of the network. It laid the foundation for future 6G security models. While promising, it focused on large-scale architecture planning. In “Machine Learning for Eavesdropper Detection in 5G IoT Networks,” ML models were used to detect hidden listeners in IoT networks. LSTM was one of the models applied. Although useful, the study focused on wireless sensors, not API layers in 5G core systems.
The literature also reflects a lack of diverse datasets. Many studies reused common datasets such as CICIDS2017 or UNSW-NB15, which focus on general network threats but do not simulate API-level interactions typical of 5G Core [11]. Moreover, prior research often limited evaluation to basic metrics like accuracy and precision. Most existing LSTM or RL-based systems act as black boxes, which limits their trustworthiness in telecom settings. While this study did not fully implement XAI, acknowledging it as a future enhancement to improve transparency and operator trust. In comparing literature, most prior research tested only a single AI model and lacked comparative analysis [38,39]. In contrast, this research implemented and evaluated both LSTM and RL models, alongside a static rule-based system. The RL model performed better in handling unknown or fast-evolving threats due to its reward-feedback learning mechanism. The LSTM model excelled in recognizing time-sequence patterns in recurring attacks, such as slow brute-force or low-rate DDoS attempts [40,41].
The literature shows a growing recognition of AI’s role in network security, but a clear gap exists in applying these techniques to the 5G Core API layer [42]. This research contributes by designing and testing an AI-driven, real-time risk assessment framework that outperforms traditional methods in accuracy, flexibility, and adaptability. It also adds value by using a custom synthetic dataset, running full-stack simulation, and evaluating comprehensive KPIs [43,44]. In summary, most of the existing works focus on general network intrusion detection using AI or on traditional traffic flows [45]. Very few address the unique nature of 5G Core APIs [29,46]. Fewer still combine both LSTM and RL models under a dynamic, real-time risk scoring system. This study fills this gap by implementing and testing such a system with realistic traffic, measuring multiple performance KPIs, and comparing results with static rule-based security [47,48,49]. This review shows that while AI-based security for telecom is well researched, the use of dynamic risk scoring at the 5G API layer using both LSTM and RL is novel and practical. The findings of this study offer a solid basis for further research on scalable, intelligent telecom security systems. The summary of Related Work and Research Gaps is added in below table (see Table 1).
Table 1.
Summary of Related Work and Research Gaps.
2.1. Theoretical Framework
2.1.1. Long Short-Term Memory (LSTM)
In this research, Long Short-Term Memory (LSTM) was used to detect unusual patterns in 5G Core API traffic. Neural networks of the LSTM type perform well when dealing with time-based data. It remembers important information from past inputs and ignores what is not useful. This makes it suitable for understanding how API traffic behaves over time.
The Keras Sequential API was used to build the proposed LSTM model. The input data had six features per API request, such as request size, method type, timestamp, source IP, endpoint and request rate. This data was reshaped into a 3D format that LSTM requires: (samples, time steps, features)—in this case, this became (n, 1, 6) where “n” represents the quantity of API samples. Time steps were kept at 1 since each request was treated independently for simplicity.
The model had one main LSTM layer with 64 units (or neurons). This layer helped capture hidden patterns in the traffic sequence. After this, a Dense layer with one output unit was added. Here, the API request is classified as either malicious (1) or regular (0) using a sigmoid activation function. This setup allowed the model to handle binary classification tasks based on learned behaviors.
Internally, the LSTM cell works using three gates. These gates help the model decide what to keep, what to update and what to output at each step:
- 1.
- Forget Gate:It chooses which portions of the prior memory to erase.Formula:It takes the previous hidden state and the current input , multiplies them with weights, adds a bias, and then applies a sigmoid function.
- 2.
- Input Gate:It chooses what fresh data should be stored in the memory.Formulas:These add new values to the cell’s existing state.
- 3.
- Output Gate:It calculates what the next hidden state should be.Formulas:This helps generate output that is passed to the next LSTM unit or final Dense layer.
In these formulas:
- is a sigmoid function that gives a value between 0 and 1.
- tanh scales values between −1 and 1.
- is the hidden state passed forward.
- is the cell’s memory, which keeps long-term information.
As a binary classification task, this model’s training employed binary cross-entropy as the loss function. During training, weight adjustments were made effectively using the Adam optimizer.
To train and test the model, you created synthetic 5G API traffic using Python scripts. This dataset included both normal API requests and different types of attack traffic like DDoS, SQL injection, and brute force. These were generated using tools like Locust, OWASP ZAP, and Scapy. LSTM model is being trained on this data to identify attack patterns based on how requests behaved over time.
The model output was a probability score between 0 and 1. This score represented the risk level of a given request. If the score was above a certain threshold (for example, 0.5), it was flagged as a potential attack. This dynamic scoring helped improve the model’s precision and reduce false alerts.
Evaluation was done using various metrics:
- Accuracy: The number of right forecasts
- Precision: The proportion of requests that were recognized as attacks
- Recall: How many real attacks were detected
- F1-Score: F1-Score strikes a compromise between precision and Recall.
- Confusion Matrix: breakdown of true vs. false predictions
Overall, the LSTM model worked well for detecting slow and stealthy attacks that were harder to catch with static rules. It improved detection accuracy and adaptability in a 5G Core API environment.
2.1.2. Reinforcement Learning (RL)
In this research, the Reinforcement Learning (RL) model was used to secure the 5G Core API layer by learning to take smart actions in real time. The model followed a Deep Q-Network (DQN) architecture. Unlike LSTM, which learns from past traffic patterns through interaction with its surroundings and incentives or penalties based on its activities, RL gets better. This helps the system adapt to new threats dynamically.
The RL agent’s job was to decide whether to allow or block each API request based on its current state. Each state represented the features of an incoming API call, like request size, type, timing, and frequency. The action space was simple—either allow (0) or block (1). This binary decision was enough to determine whether a request should be trusted or rejected.
You created a custom environment using OpenAI Gym. The environment took the API request data and processed it in a loop, allowing the agent to train itself based on experience. Each round, or episode, the agent interacted with traffic samples and received a reward or penalty depending on whether its action was correct.
The RL model used a neural network to estimate Q-values for every state-action pair. A Q-value indicates to the agent how effective a particular course of action is in a given circumstance. The basic formula used to estimate these values is:
To update the Q-values during learning, you applied the Bellman Equation, which is central to most RL algorithms. It is given as:
where:
- is the current Q-value for action in state
- determines the rate at which new information replaces previously learned information.
- is the reward received after taking action
- is the discount factor used to calculate future benefit values.
- is the best Q-value for the next state
In this implementation, the agent received:
- +2 reward for correctly classifying the API request (malicious or safe)
- −3 penalty for allowing a malicious request
- −1 penalty for wrongly blocking a safe request
- −1.5 penalty for other uncertain outcomes
To make training more effective, you used experience replay, which stores past state-action-reward experiences in memory using a deque structure. Instead of learning from just the most recent step, the agent learns from randomly selected past experiences. This breaks the link between consecutive data and improves stability.
There were two hidden layers in the simple neural network that were utilized to estimate Q-values. 64 neurons with ReLU activity were present in each layer. A linear activation function was employed by the final output layer, which comprised two nodes, one for each action. During model training, Binary Cross-Entropy (BCE) was used as the loss function, because the model performs binary classification (attack vs normal). The Adam optimizer was used to update the weights.
We employed the epsilon-greedy method to strike a balance between exploitation (using what it already knows) and exploration (trying new actions). At first, the agent picked random actions more often (high epsilon), but over time, it became more confident and picked the best-known action (epsilon reduced).
Key training hyperparameters were:
- Episodes: 100 total episodes (each with multiple API decisions)
- Batch size: 256 samples per training cycle
- Learning rate (): 0.001
- Gamma (): 0.99—strong focus on future reward
- Initial epsilon: 1.0 (100% random actions)
- Epsilon decay: 0.985—gradually becomes smarter
- Memory size: 50,000—how many past experiences to remember
The input data to the RL model was synthetic API traffic, generated using Python scripts. These scripts simulated both normal traffic and known attack types like SQL injection, brute force login attempts, and DDoS floods. Each sample included six features, such as time, length and request type.
The model learned over time to choose the correct action based on patterns in the data. Instead of fixed rules, it dynamically adapted its policy based on rewards. This helped the system respond faster to unknown threats, even when the patterns changed during simulation.
In testing, the RL model outperformed static rule-based tools. It made decisions faster, reduced false positives, and adapted better under high traffic load. It also showed strong real-time adaptability, which is critical for live 5G API protection.
3. Methodology
3.1. Design and Framework
This research was designed to build a dynamic AI-based risk assessment system to secure 5G Standalone (SA) Core APIs. The system aimed to detect and mitigate threats in real-time using two AI techniques—Reinforcement Learning (RL) and Long Short-Term Memory (LSTM).
The overall architecture included:
- Synthetic Traffic Generator: To simulate normal and attack API traffic patterns.
- Risk Scoring Module: To assign a risk level to each request.
- Detection Models: One using LSTM for sequence learning, the other using Deep Q-Learning for adaptive decision-making.
- Evaluation Engine: To benchmark detection models against a static rule-based baseline.
The system workflow included feeding synthetic API requests into the AI models. The models would classify the traffic as normal or attack and take actions like allow/block. Each request also received a dynamic risk score (see Figure 1).
Figure 1.
End-to-End Framework.
Due to the limited availability of public datasets representing 5G Core Service-Based Architecture (SBA) API traffic, a synthetic dataset was generated in a controlled laboratory environment. The goal was to simulate realistic API behavior and evaluate the proposed detection framework under different traffic conditions. API traffic was generated using multiple tools. The Locust load testing framework was used to simulate concurrent API requests and realistic traffic loads. Scapy was used to generate customized packet patterns and abnormal request sequences. OWASP ZAP was used to simulate common web API attack vectors. The generated traffic included both normal API interactions and malicious behavior. The attack scenarios included SQL injection attempts, brute-force authentication attacks and API request flooding, representing denial-of-service behavior. The generated API payloads were structured using JSON format, which is commonly used in 5G Service-Based Interface (SBI) communication. The dataset was designed to approximate REST-based API interactions typically used in modern service-oriented network architectures.
3.2. Dataset and Data Generation
Since real 5G Core API logs were unavailable, synthetic data was generated using Python (see Figure 2). Tools such as Locust, Scapy and OWASP ZAP were used to simulate API requests, including:
- Normal API calls: Auth, session creation, data request.
- Attack patterns: SQL injection, brute-force attempts, Denial of Service (DoS) and malformed payloads.
Figure 2.
Synthetic Data Generation.
Each record had six key features such as request method, payload length, source IP entropy, API endpoint risk level, frequency per time window, and authentication status. Labels were assigned manually: 1 for an attack and 0 for a safe request.
After cleaning and normalizing the data, it was divided into training (80%) and test (20%). To make it more realistic, noise and outlier simulation were added.
Existing public datasets related to 5G security mainly focus on general network traffic behavior or IoT communication patterns. These datasets often do not include detailed API-level interactions between network functions in Service-Based Architecture environments.
Real 5G Core datasets are rarely publicly available due to privacy, security, and regulatory constraints. Telecom operators typically restrict access to control-plane traffic data because it contains sensitive operational information.
Therefore, synthetic dataset generation was used to simulate REST-based API interactions and evaluate the proposed framework in a controlled laboratory environment.
The synthetic API dataset was generated using three widely used open-source tools. Locust was used to simulate realistic API workloads, concurrent users, and request frequency patterns. Locust supports HTTP-based testing and is widely used for performance evaluation of web services [50].
Scapy was used to generate customized packet structures and simulate abnormal traffic sequences. Scapy provides flexibility for packet manipulation and is frequently used in cybersecurity research experiments [51].
Moreover, OWASP ZAP (Zed Attack Proxy) was used to simulate application-layer attacks, including SQL injection attempts and authentication attacks. OWASP ZAP is an open-source security testing tool maintained by the Open Web Application Security Project (OWASP) [51]. These tools enabled controlled generation of normal and malicious API interactions while maintaining flexibility in traffic behavior modeling.
3.3. Risk Scoring System
In Python, a risk scoring system was put into practice. Using a weighted method, each API request was given a dynamic risk score ranging from 0 to 1:
where each w represented a predefined weight for the feature. If the final score crossed the threshold (0.6), the request was treated as a potential threat.
The dataset contains both normal and malicious API requests. Approximately 60% of the data represents normal traffic, while 40% represents attack scenarios. This distribution ensures that the models are trained using both legitimate and malicious behavior patterns while avoiding severe class imbalance.
The selected features focus on behavioral characteristics of API traffic rather than telecom-specific metadata. These features include request frequency, payload size, response time, and error rate. Such indicators are commonly used in anomaly detection research because they capture abnormal traffic behavior independent of specific network implementations. Incorporating detailed 3GPP Service-Based Architecture attributes such as Network Function type, HTTP/2 headers, or OAuth tokens would require access to operational telecom infrastructure. Therefore, the present study focuses on generalized behavioral indicators applicable across different API environments. Future work may extend the feature set to include telecom-specific metadata when such datasets become available.
3.4. Model Implementation
3.4.1. LSTM Model
To construct the LSTM model, the Keras Sequential API was utilized. The input shape was reshaped into (samples, time steps, features) = (n, 1, 6). The model architecture included one LSTM layer with 64 memory units, and one dense output layer for binary classification that uses sigmoid activation.
Weight updates were managed by the Adam optimizer and the loss function was binary cross-entropy. With early halting, the model was trained for 60 epochs. Accuracy, recall, precision, F1-score and AUC-ROC were the metrics that were employed.
The LSTM architecture was intentionally designed to remain lightweight to support real-time processing requirements in API security environments. In the current implementation, each API request is processed individually to maintain low latency during inference. As a result, the input sequence length was configured with a single time step. Although this limits the full sequential learning capability of the LSTM model, it allows fast processing of individual API requests. The overall framework architecture supports multi-step sequence inputs, and future work will explore longer request sequences to better capture temporal attack evolution.
3.4.2. RL Model Using DQN
The RL model used a Deep Q-Network to learn optimal actions for each API request. The environment was built using OpenAI Gym with:
- State: Vector of six API features.
- Action: 0 for allow, 1 for block.
The Bellman equation was used to update the Q-values:
where:
- = learning rate (0.001)
- = discount factor (0.99)
- = reward for current step
Reward logic:
- +2 for correct detection
- −3 if the agent allowed a malicious request
- −1 for wrongly blocking a safe request
- −1.5 for other uncertain or misclassified cases
The RL model used experience replay and epsilon-greedy strategy for training stability and exploration. Training was done for 100 episodes with a batch size of 256.
The Reinforcement Learning agent is designed to learn adaptive response strategies rather than perform simple traffic classification. The RL agent receives the calculated risk score as its state input and selects an action, such as allowing or blocking the request. During training, rewards are assigned based on the effectiveness of the chosen action. This enables the agent to learn a policy that balances threat mitigation with minimizing false positives. Unlike traditional supervised classification models, the RL agent optimizes long-term decision outcomes by learning how to respond dynamically to different risk levels.
3.5. Evaluation Metrics
The performance was measured using the following metrics:
- Accuracy:
- Precision:
- Recall (Sensitivity):
- F1-Score:
- False Positive Rate (FPR):
- AUC–ROC Score: Area under the Receiver Operating Characteristic curve
- Response Time per Request: Measured in seconds/request, calculated by dividing total processing time by the number of requests
- Mitigation Effectiveness:
The terms represent correct and incorrect classification of API traffic, specifically for detecting external threats in 5G Core security Where: = True Positives (correctly detected attacks), = True Negatives (correctly allowed safe requests), = False Positives (safe requests wrongly flagged as threats), = False Negatives (missed attack detections).
The evaluation was conducted on 4000 test samples for each model.
4. Results
The system was tested using three models: LSTM, Reinforcement Learning (RL) and a rule-based Static security model. Each model was initially trained and evaluated on the same set of 4000 synthetic API traffic samples. These samples included both normal and malicious requests like SQL injection, brute force and DDoS traffic.
4.1. LSTM Model Training Results
The bellow figure (Figure 3) shows how the LSTM model learned to classify API traffic during training. In the beginning, the accuracy was lower, but it improved quickly as the model trained on more data (see Figure 3). After a few rounds, both training and validation accuracy reached high values, staying close to each other. This means the model was learning the patterns without overfitting. The training accuracy stayed stable, and the validation accuracy also remained high, which shows that the model worked well on both training and unseen data. Overall, the LSTM model was able to learn the traffic patterns effectively and performed well in classifying normal and malicious requests.
Figure 3.
Training and Validation Accuracy of the LSTM Model.
The dataset was divided into training and testing sets using a 60–40% split. Early stopping was applied during model training to prevent overfitting. Training and validation loss values were monitored across epochs, and training was stopped when validation loss stopped improving. This approach helps ensure that the models generalize well to unseen API traffic.
4.2. Reinforcement Learning Agent Training Performance
The below diagram (see Figure 4) shows how the Reinforcement Learning model improved during training. At the start, the model struggled and earned low rewards because it was still learning how to handle API traffic. As training continued, the rewards increased, showing that the model learned to make better decisions. There were a few drops in performance when the model faced new attack patterns, but it quickly adapted and improved again. Overall, the graph proves that the RL model became smarter over time and learned how to respond better to changing threats. This shows the model’s ability to learn and improve its actions for securing 5G Core APIs.
Figure 4.
Reinforcement Learning Model Training Rewards Trend.
4.3. Accuracy and Classification Metrics
The LSTM and RL models both achieved a high accuracy of 95%, while the static model reached only 58% (see Table 2). This showed that the AI-based models were much better at detecting attacks.
The KPIs showed that both LSTM and RL models correctly identified most threats. The static model failed to detect most attacks, especially those that changed patterns.
Below are the key classification metrics:
Table 2.
Classification Metrics Comparison.
These results confirm that AI models are more reliable than static methods, especially for dynamic traffic patterns in 5G networks.
4.3.1. Accuracy Comparison Across Models
Accuracy shows the overall correctness of the model in classifying both safe and harmful API requests. The graph (see Figure 5) shows the accuracy of the three models tested in this research. The LSTM and RL models both achieved a high accuracy of 95%. This means they correctly identified most of the API requests, whether safe or harmful. In comparison, the static model performed much lower, reaching only 58% accuracy. This clearly shows that the AI models are much better at detecting threats in 5G Core API traffic. The static model failed to adjust to new attack patterns, which reduced its accuracy. These results prove that using AI for real-time security in Telecom systems is more effective than using fixed rule-based methods.
Figure 5.
Accuracy comparison across LSTM, RL, and Static models.
4.3.2. Precision Comparison Across Models
Precision shows how many of the requests flagged as threats were actually correct threats. The graph below (see Figure 6) compares the precision of the three models. Precision is important because it tells how many of the detected attacks were truly harmful. Both the LSTM and RL models achieved a precision of 95%, meaning they made very few wrong alerts. This shows they accurately identified malicious API requests without blocking safe ones. The static model had much lower precision, only 51%. This means it wrongly flagged many safe API requests as harmful. In a real 5G Core network, this could cause unnecessary blocks and service disruptions. These results highlight the advantage of using smart AI models for better decision-making in API security.
Figure 6.
Precision comparison across LSTM, RL, and Static models.
4.3.3. Recall Comparison Across Models
Recall tells how many real threats the model correctly found and blocked. Following graph shows the recall values for the three models. Both the LSTM and RL models achieved a recall of 94%, meaning they successfully detected most of the malicious API requests. This shows that these AI models are strong at finding and stopping actual threats. On the other hand, the static model only had a recall of 58%. This means it missed a lot of harmful requests, allowing many attacks to pass through without detection. In telecom security, missing a threat can lead to bigger problems. This comparison shows that AI-based models are much better at protecting the 5G Core APIs by detecting more real-time threats (see Figure 7).
Figure 7.
Recallcomparison between LSTM, RL, and Static models.
4.3.4. F1-Score Comparison Across Models
F1-Score balances precision and recall, showing how well the model detects threats without too many mistakes. Below graph below (see Figure 8) shows how the F1-Score compares for all three models. The LSTM and RL models both achieved 95%. This means they not only detected threats accurately but also avoided too many wrong predictions. A high F1-Score shows that the model performs well in real-world situations where both correct detection and avoiding mistakes are important. In comparison, the static model only had an F1-Score of 51%. This tells us that the static model struggled to balance between catching threats and avoiding false alarms. Overall, AI models like LSTM and RL provided much better protection for the 5G Core APIs.
Figure 8.
F1 Score comparison of LSTM, RL, and Static models.
4.3.5. ROC Curve
The ROC curve shows how well the models separate safe and harmful API requests, and a higher AUC means better detection performance. The ROC curve in the Figure 9 compares how well each model can tell safe API requests from harmful ones. The LSTM and RL models both have an AUC score of about 0.94. This shows that they are very good at finding threats while keeping false alarms low. Their curves stay close to the top-left corner, meaning they have strong detection power. On the other hand, the static model has an AUC score of only 0.49. This is very low and close to random guessing. Its curve follows the diagonal line, meaning it does not detect threats well. These results clearly show that AI models like LSTM and RL are much better at protecting 5G Core APIs compared with static rule-based systems.
Figure 9.
ROC Curve comparison of LSTM, RL, and Static models.
4.4. Response Time
The system also measured how fast each model responded to threats. The RL model had the best total response time of 0.3638 s for 4000 requests. LSTM followed with 0.5639 s, while the static model was the fastest at 0.1794 s. However, the static model’s speed came at the cost of low accuracy.
Here is the per-sample response time:
- RL: 0.000091 s/request
- LSTM: 0.000141 s/request
- Static: 0.000045 s/request
Even though the static model was fastest, it failed to identify many threats, which made it unreliable.
4.5. Mitigation Effectiveness and Scalability
Mitigation effectiveness shows how well a model stops harmful API requests from causing damage (see Figure 10 and Figure 11). The graph below (see Figure 8) compares how well each model reduced harmful API attacks. The LSTM and RL models both stopped around 92% of the threats. This means they were highly effective in blocking bad API requests before they could cause problems. Their performance was consistent and strong across different attack types. On the other hand, the static model only stopped about 13% of the harmful traffic. This shows that static security rules were unable to protect the system from evolving threats. Overall, AI models like LSTM and RL provided much better protection by learning and reacting to changing attack patterns in real-time.
Figure 10.
Mitigation Effectiveness Comparison.
Figure 11.
Throughput Comparison across Models.
The AI models showed strong scalability when handling large amounts of API traffic. As the number of API requests increased, both LSTM and RL models continued to detect threats accurately. They did not slow down or miss requests, even when traffic went above 500 requests per second. This means the AI models can easily support busy network environments where traffic changes quickly. In comparison, the static model struggled when the traffic load increased. It started missing harmful requests because it could not adjust fast enough. This shows that AI-based systems are more reliable and flexible for growing 5G Core networks, where traffic demand is always changing.
This graph shows that both the LSTM and the RL models handled around 500 requests per second, while the static model could only process 250 requests per second before its performance dropped.
4.6. Alert Accuracy and Adaptability
The LSTM and RL models showed strong performance in alert accuracy. They correctly identified harmful and safe API requests. This means the number of false alarms (false positives) was low. High alert accuracy is very important in real-time API security because it helps avoid wasting time on harmless traffic.
The RL model was able to learn from feedback. Every time it made the right or wrong decision, it adjusted its actions. This reward-based learning helped it adapt to new types of attacks quickly. For example, when a new threat pattern appeared, RL learned to block it after a few attempts.
The LSTM model learned from the patterns of past API traffic. It was good at finding repeated attack behaviors, such as brute-force or injection attempts happening over time. This pattern learning helped it detect hidden threats that static systems might miss (see Figure 12).
Figure 12.
False Positive Rate Comparison between LSTM, RL and Static Models.
Both models generated a risk score between 0 and 1 for each request. This score helped in deciding whether to allow, block, or monitor the request. The score was based on the model’s output probability.
5. Discussion
This research aimed to create an AI-driven system to secure 5G Standalone Core APIs. The results clearly show that both LSTM and RL models performed better than traditional static methods. They were more accurate, more adaptive, and faster at responding to threats. These outcomes support the main goal of the study, which was to build a smarter and real-time risk assessment system.
The LSTM model learned from past traffic. It used sequences to detect slow or hidden attacks. The RL model, on the other hand, learned from actions and rewards. It adapted quickly to new threat patterns. Both models helped assign a risk score to each API request. This made it easier to take actions like blocking or further monitoring.
Compared with previous studies, in this research, the models achieved an accuracy of 95% using both Reinforcement Learning (RL) as well as LSTM, which is competitive with current state-of-the-art approaches. The 5G environments of recent RL-based intrusion detection frameworks have represented accuracy levels of about 95.8%, notably outperforming traditional signature-based systems around 78.2% and standard ML models (88.5%) [52]. Although some federated and advanced hybrid models can reach higher accuracy around 97%, they frequently need higher computational resources and complex architectures [26]. Hence, the results of this paper represent a strong balance between model simplicity and performance. Moreover, the noteworthy gap between the proposed static baseline model (58%) and intelligent models (95%) further proves the necessity of adaptive and learning-based approaches to secure API traffic within dynamic 5G standalone core environments.
In addition, this research went one step ahead. Many past works used machine learning only on stored logs or simple datasets. They focused more on detection than real-time decisions. Some used AI with SDNs or at the user edge but not deep into the 5G Core API layer. Very few combined both LSTM and RL for dynamic risk scoring. This study filled that gap by introducing a combined approach tested in a live testbed [37,53,54,55].
A key research paper [20] focuses on the vulnerability assessment of the 5G Core but does not apply AI or dynamic learning algorithms. The paper does not propose any scoring mechanism or AI-driven detection. Their focus is on insider threats, like NF deregistration and spoofing, using the OAI testbed. This thesis fills the gap by applying AI to protect the 5G Core APIs dynamically, learning from traffic patterns and assigning real-time risk scores. The results show high detection accuracy (95%) and adaptive responses, while this study only performed manual assessments without automation. Therefore, this work improves 5G Core API protection by using AI to handle dynamic insider attacks that the aforementioned paper did not address.
The paper in [36] mostly talks about standard 5G security practices like Zero Trust, encryption, and authentication for protecting the core network and APIs. It clearly explains the risks in exposed APIs but does not suggest AI-based solutions to manage these risks in real-time. There are no AI algorithms like LSTM or Reinforcement Learning (RL) used in their study. They also do not handle dynamic threats using scoring or real-time adjustments. In contrast, this paper used AI models like LSTM and RL to learn traffic behavior and assign risk scores to each API request. These models adjusted to changing threats and improved detection accuracy. This work protected the 5G Core API layer using AI-driven scoring, which was missing in the GSMA’s approach. This shows that this research filled a gap in dynamic API protection for 5G Core.
The study in [24] gave a broad review of security issues across IT systems. It focused on general cyber threats but did not cover the specific API protection needs of the 5G Core. AI models like ML and DL were discussed as helpful solutions, but the study did not apply them practically for dynamic threat detection in 5G APIs. This paper went further by applying LSTM and RL algorithms, which handled the dynamic nature of API threats. We also implemented a real-time scoring system to measure API risk and detect evolving attacks. The results show clear detection accuracy using LSTM and RL, but the review paper did not mention any real model accuracy. So, this work fills the gap by bringing AI-driven API protection to 5G Core security, which this review paper did not cover.
Another study [28] explored how explainable AI can improve security in B5G networks, but it did not cover real-time API threat detection for 5G Core. Unlike this study, which built and tested AI models like LSTM and RL to handle dynamic threats and assign risk scores to API traffic, the paper mostly discussed the theory and future direction of XAI. There was no practical testing or model performance results, such as detection accuracy. Also, it did not look at scoring mechanisms or dynamic API protection. This research filled this gap by using LSTM and RL to adaptively score API risks, showing how AI can detect and respond to fast-changing threats in the 5G Core environment. The paper helped frame the need for explainable security, but it did not achieve practical results like we did.
Compared with [29], this research paper introduced actual AI-based solutions. That paper mainly reviewed 5G Core security features and listed possible gaps in SBA, CAPIF, and signaling layers, but did not build or test AI models. In contrast, this research applied LSTM and Reinforcement Learning (RL) to dynamically detect API threats in the 5G Core. The AI models achieved high detection accuracy and managed the changing nature of threats in real time. This thesis also built a risk scoring system for each API request, filling the gap that the earlier paper left unexplored. In summary, while the paper gave a strong theoretical base, this thesis delivered tested AI solutions for practical 5G Core API protection.
Compared with the study in [22], this study uses AI algorithms (LSTM and Reinforcement Learning) to detect and manage threats in real-time 5G Core API traffic. The reviewed paper mainly talks about manual and tool-based penetration testing, without using AI. Also, it does not cover the 5G Core API security layer or risk scoring. This research fills this gap by using AI to learn traffic patterns and score the risk of each API call. LSTM and RL models in this study achieved strong detection accuracy and could handle dynamic and changing threats, which this penetration testing study did not cover. The proposed solution also introduced a scoring mechanism to assess API risk in real-time, making it more proactive than traditional testing approaches.
Compared with the study in [30], this thesis focused on API-level protection for the 5G Core, which is not the focus of the cited study. While the paper used ML-driven reactive systems for application validation and dynamic threat response, it did not use LSTM or RL models, nor did it apply a scoring mechanism for requests. This thesis built AI models using LSTM and RL to detect threats at the 5G Core API level and achieved strong detection accuracy with dynamic risk scoring. Also, the paper mainly worked on the infrastructure and application behavior, while this research protected sensitive API communication in the core. This research handled the dynamic nature of threats, provided accurate risk scoring, and demonstrated higher detection accuracy for 5G Core API protection. Ref. [31] mostly worked on building a security taxonomy and threat classification for 5G networks. It mapped different threats but did not focus on real-time detection, risk scoring, or using AI models like LSTM or RL. In contrast, this research used AI to score API risks dynamically and detect fast-changing threats in 5G Core APIs. This study handled real-time API traffic and used LSTM and RL to learn from dynamic attacks like DDoS and SQL injections. The paper did not mention detection accuracy or scoring methods, but this research achieved high detection rates and built a scoring system for API protection. Therefore, this research filled the gap of providing AI-driven dynamic detection for protecting 5G Core APIs, which was missing in this ontology-based work.
Compared with the study in [20], this research addresses some important gaps. While the paper built a graph-based detection system for the 5G Core, it did not use AI models like LSTM or Reinforcement Learning (RL). Their method focused on predefined graph rules rather than learning from changing threat patterns. Also, they did not target API-level threats inside the 5G Core. This work introduces AI models (LSTM and RL) that learn dynamically from API traffic and score the risks in real-time. We achieved high detection accuracy and handled evolving threats using AI-based dynamic scoring. Proposed models protect the API layer and block attacks like SQL injection, brute force, and DDoS, which the paper did not cover. This research fills the gap by applying AI for dynamic 5G Core API protection.
Compared with this study of AI-Driven Dynamic Risk Assessment for Securing 5G SA Core APIs Against External Threats, another study [32] provided a theoretical review of 5G security but did not implement or test AI models. It focused on defining security gaps in areas like network slicing, NFV and SDN, but missed addressing dynamic threat learning for 5G Core APIs. Unlike this research, this study did not apply LSTM or Reinforcement Learning (RL) models for adaptive risk scoring. It did not assess detection accuracy or build a scoring mechanism for API requests. This research filled this gap by using AI models (LSTM and RL) to detect dynamic threats in real-time, providing risk scores for each API request and protecting 5G Core APIs directly. This makes proposed model more practical and results-driven in protecting exposed APIs against evolving threats.
Another study [33] provided a good summary of 5G slicing threats but did not implement or test any AI security solutions. It lacked dynamic risk detection or scoring methods like the ones this research has used. This work fills this gap by applying LSTM and Reinforcement Learning (RL) models to dynamically learn and adapt to threats in real-time. While the paper outlined static security threats in the slicing lifecycle, targeted research actively scored API requests and learned patterns from API traffic. This work also evaluated detection accuracy and response times for 5G Core API protection, something the paper did not do. By combining AI and risk scoring, this study achieved more effective dynamic threat protection for 5G Core API surfaces.
Compared with the study in [34], this research takes a step further by using AI models to protect 5G Core APIs. The paper studied 5G interfaces like N1, N2, and N4 but did not use AI or machine learning to detect attacks. Also, it did not address API protection for the 5G Core or dynamic risk assessment. This research used LSTM and RL algorithms to learn traffic patterns and detect changing threats. We introduced a scoring mechanism to rate API request risks in real-time, which the study did not do. In this work, the focus was on the detection accuracy of AI models, achieving better efficiency in threat response and mitigation at the API level. This way, this research filled the gap by adding AI-based, dynamic API security for the 5G Core.
Compared with this study, the study in [35] mainly focuses on the general security of network slices, not on API protection or real-time threat adaptation. It does not implement AI models like LSTM or Reinforcement Learning, nor does it propose dynamic learning for evolving attacks. This research fills this gap by designing an AI-driven system that detects dynamic API threats in the 5G Core, achieving high detection accuracy for LSTM and RL models. The paper also does not cover scoring mechanisms for API risks, while this work implements real-time risk scoring and adaptive responses. Unlike the paper’s static security focus, this research improves the protection of 5G Core APIs, using AI to learn from dynamic traffic patterns and threats. In summary, while the paper provides useful background on slicing security, this research addresses the real-time detection and scoring of API threats, which is missing in the comparative work.
The main focus of another study [20] was on testing real vulnerabilities in open-source 5G Core functions, but it did not explore AI models or dynamic learning for threat detection. While it showed real gaps in AMF and NRF, it did not use AI algorithms like LSTM or Reinforcement Learning to detect or respond to threats. The paper did not provide a scoring mechanism or real-time risk assessment for API calls. In comparison, this research added AI-based detection using LSTM and RL, improving the detection of dynamic threats over time. Propsoed models achieved strong detection accuracy and adaptive learning against changing attack patterns. We also introduced a scoring mechanism to assess API risks and applied it to protect 5G Core APIs, which were missing in this study. This work filled this gap by adding dynamic, smart detection instead of static vulnerability testing.
Another AI-related study [30] mainly focused on how AI can help wireless networks stay secure, but did not go deep into protecting 5G Core APIs or scoring threats in real-time. It covered general risks of AI in networks but did not apply algorithms like LSTM or RL for threat detection. Unlike the aforementioned paper, this research designed AI-based models that adapt to changing 5G Core API attacks. We trained LSTM and RL models on synthetic API data to score risks and respond quickly. This work showed a detection accuracy of 95%, while the aforementioned paper did not present accuracy results. Proposed risk scoring helped protect 5G Core APIs, which the other paper did not cover. So, this work filled the gap by providing practical AI models for dynamic API threat detection in 5G Core environments.
One key strength was the custom test environment. Tools like Locust, Scapy, and OWASP ZAP helped generate both normal and attack traffic. This included DDoS, SQL injection, brute force, and noisy traffic. The traffic was labeled and passed through the models. This setup helped simulate real scenarios without using any real user data. It kept the testing ethical and safe.
The RL model was built using a Deep Q-Network (DQN) with experience replay. Feedback in the form of incentives and sanctions helped the agent learn. In this setup
- +2 reward was given when the model correctly identified an API request, whether malicious or safe.
- −3 penalty was applied if the agent allowed a malicious request.
- −1 penalty was given for wrongly blocking a safe request.
- −1.5 penalty was used for other uncertain or misclassified cases.
This custom reward system helped the agent learn the best actions in real time to protect the 5G Core API environment. This reward system helped it learn quickly. Over time, the model started making better decisions even when attack patterns changed. It showed strong adaptability.
The LSTM model was trained using a binary classification approach. It employed a sigmoid activation to provide a risk score and had a single 64-unit LSTM layer. The input was reshaped to (samples, time steps, features), which in this case was (n, 1, 6). It performed well with high accuracy and low false positives. However, LSTM was slightly slower than RL in terms of response time.
The use of synthetic data was one of the limitations. It might not capture every edge case of actual network traffic, despite being realistic. Future work can improve this by testing the models on live traffic in a controlled telco lab. Also, the RL model was limited to binary actions: allow or block. Future versions could support multi-step responses like throttling, alerting, or logging.
Another challenge was explainability. Both AI models acted like black boxes. While their results are accurate, it was hard to understand why a certain request was marked as risky. Adding Explainable AI (XAI) in the future can help gain trust and improve clarity.
This study also opens the door for more AI-driven work in telecom security. Techniques like federated learning or Graph Neural Networks (GNNs) can help in building even stronger, distributed protection. The use of risk scoring also has potential for wider use—such as access control, prioritization and automated mitigation.
In summary, this project showed that combining LSTM and RL can make 5G Core API protection smarter, faster, and more flexible. The results prove that AI can play a key role in future telecom security. However, real-world testing, model explainability and broader automation are still areas to explore.
Limitation & Future Work
This study has several limitations. The evaluation was performed using synthetically generated API traffic in a controlled laboratory environment. Although the dataset was designed to simulate realistic REST-based API interactions, it does not fully replicate the complexity of real 5G Core control-plane procedures. In addition, the feature set focuses on general behavioral characteristics rather than detailed 3GPP Service-Based Architecture metadata.
Future work will focus on validating the framework using publicly available telecom datasets and more realistic network testbeds. Further research will also explore multi-step LSTM sequence inputs and more complex Reinforcement Learning policies to improve adaptive threat mitigation.
6. Conclusions
This research explored the use of AI models to improve security for 5G Standalone Core APIs. The main goal was to build a real-time, flexible system that could assess API risk and take smart actions against external threats. The growing exposure of core network APIs in 5G has created new risks. Traditional static security systems were no longer enough to detect or respond to evolving attacks.
Two AI models were tested: LSTM and Reinforcement Learning (RL). The LSTM model focused on learning traffic patterns over time. It could detect hidden or delayed attacks by analyzing sequences. The RL model worked differently. It learned through rewards and penalties and made decisions based on the latest state of API traffic. Both models were trained on synthetic datasets with various attack types like DDoS, brute force, and SQL injection.
The results are strong. Both AI models outperformed static rule-based detection in accuracy, adaptability and response time. The RL model showed better speed and flexibility, while LSTM showed strong consistency in recognizing long-term patterns. These findings confirmed that AI can make 5G API protection more dynamic, smarter and faster.
The research has practical implications. Telecom operators can use similar AI-based systems to improve their network security. Instead of using fixed rules, they can switch to models that learn and adjust in real time. This could reduce downtime, improve threat visibility, and cut the cost of managing false alerts.
There were also some limitations. The data used for model training was synthetic. Although it included realistic patterns, it may not cover all possible traffic behaviors. Real-world testing would be needed in the future to check for scalability and reliability. Another challenge was the explainability of AI decisions. The current models could not fully explain why a request was marked risky. This can be addressed later by integrating Explainable AI (XAI) techniques.
In the future, the system can be improved in multiple ways. Live traffic from operator labs can be used for training. Multi-level risk responses (e.g., rate limiting or flagging) can be added instead of simple allow/block actions. New models like Graph Neural Networks (GNNs) or federated learning can be tested. Explainability and user trust should also be part of future development.
In summary, this research made a valuable contribution by designing and testing a working AI-based framework for 5G Core API protection. It showed that a mix of LSTM and RL can detect and respond to API threats better than older static systems. The work supports the shift toward smarter and more adaptive telecom security. Further improvements will make the solution even more useful in real-world 5G environments.
Author Contributions
Conceptualization, S.E.H. and S.P.; methodology, A.Y.; software, M.N.; validation, A.Y.; formal analysis, S.E.H. and S.P. and A.Y.; writing—original draft preparation, A.Y. and S.E.H.; visualization, M.N.; supervision, S.E.H. and S.P.; project administration, A.Y. and S.E.H.; Rosurces, M.N. and S.P. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Data Availability Statement
The original contributions presented in this study are included in the article. Further inquiries can be directed to the corresponding author.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Kouchaki, M.; Zhang, M.; Abdalla, A.S.; Lan, G.; Brinton, C.G.; Marojevic, V. Enhanced Real-Time Threat Detection in 5G Networks: A Self-Attention RNN Autoencoder Approach for Spectral Intrusion Analysis. arXiv 2024. [Google Scholar] [CrossRef] [Scilit]
- Sengan, S.; Mehbodniya, A.; Webber, J.; Bostani, A.; Almusharraf, A.; Alharbi, M.; Alqahtani, A.; Bhatia, S. Improved LSTM-Based Anomaly Detection Model with Cybertwin Deep Learning to Detect Cutting-Edge Cybersecurity Attacks. Hum. Centric Comput. Inf. Sci. 2023, 13, 55. [Google Scholar] [CrossRef]
- Giambartolomei, F.; Barceló, M.; Brighente, A.; Urbieta, A.; Conti, M. Penetration Testing of 5G Core Network Web Technologies. arXiv 2024. [Google Scholar] [CrossRef] [Scilit]
- Vomvas, M.; Ludant, N.; Noubir, G. Establishing Trust in the Beyond-5G Core Network using Trusted Execution Environments. arXiv 2024. [Google Scholar] [CrossRef] [Scilit]
- Aloupogianni, E.; Karyotis, C.; Maniak, T.; Iqbal, R.; Passas, N.; Vujicic, Z.; Doctor, F. Network Slicing for Beyond 5G Networks using Machine Learning. In Proceedings of the 2024 IEEE 24th International Symposium on Cluster, Cloud and Internet Computing Workshops (CCGridW), Philadelphia, PA, USA, 6–9 May 2024; pp. 197–200. [Google Scholar] [CrossRef] [Scilit]
- Dhanasekar, R.; Vijayaraja, L.; Rithika, C.; Avanthika, S.; Thalapathiraj, S.; Premkumar, R. Navigating Emerging Technologies: A Comprehensive Review of 5G and the Evolving Landscape of 6G Communication. In Proceedings of the 2024 International Conference on Communication, Computing and Internet of Things (IC3IoT), Chennai, India, 17–18 April 2024; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
- Anand, D.; Togou, M.A.; Muntean, G.M. A Machine Learning-based xAPP for 5G O-RAN to Mitigate Co-tier Interference and Improve QoE for Various Services in a HetNet Environment. In Proceedings of the 2023 IEEE International Symposium on Broadband Multimedia Systems and Broadcasting (BMSB), Beijing, China, 14–16 June 2023; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
- Deshpande, R.; Khan, F.A.; Ahmed, Q.Z. Support Vector Machine Based Spectrum Sensing in Beyond 5G Wireless Networks. In Proceedings of the 2024 11th International Conference on Wireless Networks and Mobile Communications (WINCOM), Leeds, UK, 23–25 July 2024; pp. 1–5. [Google Scholar] [CrossRef] [Scilit]
- Raman, D.R.; Kumar, V.; Pillai, B.G.; Rabadiya, D.; Patre, S.; Meenakshi, R. Enhancing Trust-Based Attacker Detection in 5G Social Networks Through Advanced Artificial Intelligence Control. In Proceedings of the 2024 International Conference on Knowledge Engineering and Communication Systems (ICKECS), Chikkaballapur, India, 18–19 April 2024; IEEE: New York, NY, USA; Volume 1, pp. 1–5. [CrossRef] [Scilit]
- Michaelides, S.; Lenz, S.; Vogt, T.; Henze, M. Secure integration of 5G in industrial networks: State of the art, challenges and opportunities. Future Gener. Comput. Syst. 2025, 166, 107645. [Google Scholar] [CrossRef] [Scilit]
- Wala, F.B.; Kiran, M. 5G Network Security Practices: An Overview and Survey. arXiv 2024. [Google Scholar] [CrossRef] [Scilit]
- Ashfaq, F.; Wasim, M.; Shah, M.A.; Ahad, A.; Pires, I.M. Enhancing Security in 5G Edge Networks: Predicting Real-Time Zero Trust Attacks Using Machine Learning in SDN Environments. Sensors 2025, 25, 1905. [Google Scholar] [CrossRef] [Scilit]
- Li, T.; Pan, Y.; Zhu, Q. Decision-Dominant Strategic Defense Against Lateral Movement for 5G Zero-Trust Multi-Domain Networks. In Network Security Empowered by Artificial Intelligence; Chen, Y., Wu, J., Yu, P., Wang, X., Eds.; Springer Nature: Cham, Switzerland, 2024; pp. 25–76. [Google Scholar] [CrossRef] [Scilit]
- Deloitte. Security and Compliance in 5G and AI-Powered Edge Networks; White paper; Deloitte: Mumbai, India, 2024. [Google Scholar]
- Hamroun, C.; Fladenmuller, A.; Pariente, M.; Pujolle, G. Intrusion Detection in 5G and Wi-Fi networks: A Survey of Current Methods, Challenges & Perspectives. IEEE Access 2025, 13, 40950–40976. [Google Scholar] [CrossRef] [Scilit]
- Huang, C.; Tan, C.L. Deep Learning for Cybersecurity: A Comprehensive Survey. IEEE Access 2020, 8, 130122–130140. [Google Scholar] [CrossRef]
- Liu, Z.; Xu, M. AI for Network Defense: A Comprehensive Survey. Int. J. Comput. Sci. Inf. Secur. 2021, 18, 128–135. [Google Scholar]
- Yang, L.; Naser, S.; Shami, A.; Muhaidat, S.; Ong, L.; Debbah, M. Towards Zero Touch Networks: Cross-Layer Automated Security Solutions for 6G Wireless Networks. IEEE Trans. Commun. 2025, 13, 7650–7679. [Google Scholar] [CrossRef] [Scilit]
- Domb, M.; Balaji, C.G.; Menaka, S.; Gayathri, A.; Joshi, S. Securing 5G Networks by Mitigating Cybersecurity Risks for Transformative Applications. Int. J. Interact. Mob. Technol. 2025, 19, 11. [Google Scholar] [CrossRef] [Scilit]
- Dolente, F.; Garroppo, R.G.; Pagano, M. A Vulnerability Assessment of Open-Source Implementations of Fifth-Generation Core Network Functions. Future Internet 2024, 16, 1. [Google Scholar] [CrossRef] [Scilit]
- Pacherkar, H.S.; Yan, G. PROV5GC: Hardening 5G Core Network Security with Attack Detection and Attribution Based on Provenance Graphs. In Proceedings of the 17th ACM Conference on Security and Privacy in Wireless and Mobile Networks, WiSec ’24, New York, NY, USA, 27–29 May 2024; pp. 254–264. [Google Scholar] [CrossRef] [Scilit]
- Smith-Haynes, S.-A. Advanced Penetration Testing for Enhancing 5G Security. arXiv 2024. [Google Scholar] [CrossRef] [Scilit]
- Bizzarri, S.; Fodrini, M.; Garcia-Aviles, G.; Spinelli, F.; Fiore, M.; Gramaglia, M. Rethinking Network Architecture: Enabling Service-Based Design Beyond 5G. In 2025 IEEE Conference on Standards for Communications and Networking (CSCN); IEEE: New York, NY, USA, 2025; pp. 1–6. [Google Scholar]
- Aslan, Ö.; Aktuğ, S.S.; Ozkan-Okay, M.; Yilmaz, A.A.; Akin, E. A Comprehensive Review of Cyber Security Vulnerabilities, Threats, Attacks, and Solutions. Electronics 2023, 12, 1333. [Google Scholar] [CrossRef] [Scilit]
- Nkoro, E.C.; Njoku, J.N.; Nwakanma, C.I.; Lee, J.M.; Kim, D.S. Zero-Trust Marine Cyberdefense for IoT-Based Communications: An Explainable Approach. Electronics 2024, 13, 276. [Google Scholar] [CrossRef] [Scilit]
- Rezaei, H.; Taheri, R.; Jordanov, I.; Shojafar, M. Federated RNN for intrusion detection system in IoT environment under adversarial attack. J. Netw. Syst. Manag. 2025, 33, 82. [Google Scholar] [CrossRef] [Scilit]
- Rezaei, H.; Taheri, R.; Shojafar, M.; Foh, C.H. GRAF-IDS: Graph-based clustering as aggregation for federated intrusion detection system in IoT network. Neural Comput. Appl. 2025, 37, 18401–18423. [Google Scholar] [CrossRef] [Scilit]
- Senevirathna, T.; La, V.H.; Marcha, S.; Siniarski, B.; Liyanage, M.; Wang, S. A Survey on XAI for 5G and Beyond Security: Technical Aspects, Challenges and Research Directions. IEEE Commun. Surv. Tutorials 2025, 27, 941–973. [Google Scholar] [CrossRef] [Scilit]
- Tang, Q.; Ermis, O.; Nguyen, C.D.; Oliveira, A.D.; Hirtzig, A. A Systematic Analysis of 5G Networks with a Focus on 5G Core Security. IEEE Access 2022, 10, 18298–18319. [Google Scholar] [CrossRef] [Scilit]
- Hermosilla, A.; Gallego-Madrid, J.; Martinez-Julia, P.; Ortiz, J.; Kafle, V.P.; Skarmeta, A. Advancing 5G Network Applications Lifecycle Security: An ML-Driven Approach. Comput. Model. Eng. Sci. 2024, 141, 1447–1471. [Google Scholar] [CrossRef] [Scilit]
- Paskauskas, R.A. Decoding 5G Security: Toward a Hybrid Threat Ontology. Open Res. Eur. 2024, 4, 34. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Mavropoulos, O.; Millar, G.; Kafchitsas, A.; Kourtis, A.; Xilouris, G.; Christopoulou, M.; Kolometsos, S.; de Oca, E.M.; Nguyen, H.N.; Pastor, A.; et al. 5G Security: Current Status and Future Trends; Technical Report D2.1; INSPIRE-5Gplus Consortium: Heidelberg, Germany, 2020. [Google Scholar]
- Gao, S.; Lin, R.; Fu, Y.; Li, H.; Cao, J. Security Threats, Requirements and Recommendations on Creating 5G Network Slicing System: A Survey. Electronics 2024, 13, 1860. [Google Scholar] [CrossRef] [Scilit]
- Mahyoub, M.; AbdulGhaffar, A.; Alalade, E.; Ndubisi, E.; Matrawy, A. Security Analysis of Critical 5G Interfaces. IEEE Commun. Surv. Tutorials 2024, 26, 2382–2410. [Google Scholar] [CrossRef] [Scilit]
- Singh, V.P.; Singh, M.P.; Hegde, S.; Gupta, M. Security in 5G Network Slices: Concerns and Opportunities. IEEE Access 2024, 12, 51873–51896. [Google Scholar] [CrossRef] [Scilit]
- 5G Americas. Advances in Trust and Security in Wireless Cellular Networks in the Age of AI; White Paper; 5G Americas: Seattle, WA, USA, 2025. [Google Scholar]
- Ohene-Akoto, J.; Al-Attabi, K.; Al-Taee, F.; Das, P.; Alsalhy, M.J.; Sabr, A.R.H.; Taaban, N.K. The Development of Framework Design Using AI for VC in 5G N/W. In Proceedings of the 2024 4th International Conference on Advance Computing and Innovative Technologies in Engineering (ICACITE), Greater Noida, India, 14–15 May 2024; pp. 1218–1221. [Google Scholar] [CrossRef] [Scilit]
- Solmaz, M.; Arslan, E. AI and Deep Learning for Cyber Defense; Springer: Cham, Switzerland, 2020. [Google Scholar]
- WiseML ’24: Proceedings of the 2024 ACM Workshop on Wireless Security and Machine Learning; Association for Computing Machinery: New York, NY, USA, 2024.
- Bekri, W.; Jmal, R.; Fourati, L.C. Secure and Trustworthiness IoT Systems: Investigations and Literature Review. Telecommun. Syst. 2024, 85, 503–538. [Google Scholar] [CrossRef] [Scilit]
- Rekkas, V.P.; Sotiroudis, S.P.; Tsoulos, G.V.; Athanasiadou, G.; Boursianis, A.D.; Zaharis, Z.D.; Sarigiannids, P.; Christodoulou, C.G.; Goudos, S.K. Modeling Received Power from 4G and 5G Networks in Greece U sing Machine Learning. In Proceedings of the 2024 18th European Conference on Antennas and Propagation (EuCAP), Glasgow, HK, 17–22 March 2024; pp. 1–5. [Google Scholar] [CrossRef] [Scilit]
- Suresh, P.; Subramanian, V. Scalability of AI Models in Cybersecurity. Comput. Networks 2020, 178, 107292. [Google Scholar] [CrossRef] [Scilit]
- Wei, W.; Chen, S.; Chen, C.; Wang, H.; Liu, J.; Cheng, Z.; Zou, X. HEN: A Novel Hybrid Explainable Neural Network Based Framework for Robust Network Intrusion Detection. Sci. China Inf. Sci. 2024, 67, 170304. [Google Scholar] [CrossRef] [Scilit]
- Hoang, V.T.; Ergu, Y.A.; Nguyen, V.L.; Chang, R.G. Security risks and countermeasures of adversarial attacks on AI-driven applications in 6G networks: A survey. J. Netw. Comput. Appl. 2024, 232, 104031. [Google Scholar] [CrossRef] [Scilit]
- AlMarshoud, M.; Sabir Kiraz, M.; H. Al-Bayatti, A. Security, Privacy, and Decentralized Trust Management in VANETs: A Review of Current Research and Future Directions. ACM Comput. Surv. 2024, 56, 260. [Google Scholar] [CrossRef] [Scilit]
- Wang, Z.; Fok, K.W.; Thing, V.L.L. Exploring Emerging Trends in 5G Malicious Traffic Analysis and Incremental Learning Intrusion Detection Strategies. arXiv 2024. [Google Scholar] [CrossRef] [Scilit]
- Almazroi, A.A.; Ayub, N. Deep Learning Hybridization for Improved Malware Detection in Smart Internet of Things. Sci. Rep. 2024, 14, 7838. [Google Scholar] [CrossRef] [Scilit]
- Desai, A. Machine Learning Approaches in 5G Networks. Int. J. Res. Appl. Sci. Eng. Technol. 2024, 12, 1691–1697. [Google Scholar] [CrossRef] [Scilit]
- Alkhoori, A.; Alkhoori, A.; Alkhoori, A.; Ahmed, O. Security and Reliability Concerns of AI on Critical Embedded Systems. In Proceedings of the Forthcoming Networks and Sustainability in the AIoT Era; Rasheed, J., Abu-Mahfouz, A.M., Fahim, M., Eds.; Springer: Cham, Switzerland, 2024; pp. 32–45. [Google Scholar] [CrossRef] [Scilit]
- Ingman, A. Network API Security Testing in Modern Embedded Systems. Master’s Thesis, Tampere University, Tampere, Finland, 2025. [Google Scholar]
- Rangisetti, A.K. Explore Scapy for Experimenting with Networking Environments Security. In Future Networking Essentials: A Practical Guide for Exploring Cloud, Edge, and 5G core Networking Environments; Springer: Berlin/Heidelberg, Germany, 2024; pp. 453–516. [Google Scholar]
- Alnfiai, M.M. AI-powered cyber resilience: A reinforcement learning approach for automated threat hunting in 5G networks. EURASIP J. Wirel. Commun. Netw. 2025, 2025, 68. [Google Scholar] [CrossRef] [Scilit]
- Sood, S. A Technical Analysis of Hybrid Combination of AI, 5G, and ML for Various Application. In Proceedings of the 2024 IEEE International Conference on Computing, Power and Communication Technologies (IC2PCT), Greater Noida, India, 9–10 February 2024; Volume 5, pp. 1065–1070. [Google Scholar] [CrossRef] [Scilit]
- Patel, K.; Vadher, A.; Patel, M.; Thaker, J.; Bhise, A. AI-Based Security System for 5G Enabled IoT. In Proceedings of the 2024 Second International Conference on Emerging Trends in Information Technology and Engineering (ICETITE), Vellore, India, 22–23 February 2024; pp. 1–7. [Google Scholar] [CrossRef] [Scilit]
- Alnaim, A.K. Securing 5G Virtual Networks: A Critical Analysis of SDN, NFV, and Network Slicing Security. Int. J. Inf. Secur. 2024, 23, 3569–3589. [Google Scholar] [CrossRef] [Scilit]
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. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.











