## 5 Proposed Framework
### Model Integrity Verification  
Maintaining the integrity of the ML models in real time is crucial for preventing adversarial manipulation and ensuring that models are functioning as expected. The system uses a drift detection mechanism, where the Kullback-Leibler (KL) divergence is calculated between consecutive model inferences. If the KL divergence exceeds a threshold of 0.2, the system flags the model for potential integrity issues. Additionally, a CNN-based detector is employed to identify adversarial inputs, with an impressive 98.7% success rate for detecting gradient-based attacks. To further safeguard model integrity, cryptographic hashes are used to verify the model's integrity prior to execution, ensuring that any tampering or unauthorized modification of the model can be quickly detected.  
The monitoring system is organized into a three-stage processing pipeline that includes metric collection, anomaly analysis, and response execution. During the metric collection stage, the system gathers real-time data from various sources, storing them in a time-series database with 1 ms resolution. Kernel-level instrumentation ensures that the collection process incurs minimal overhead, with less than 3% CPU impact. In the anomaly analysis stage, lightweight ML models such as autoencoders and isolation forests analyze the collected data for patterns indicative of anomalies. The autoencoder offers a 10:1 compression ratio, and an ensemble of five isolation forests is used for evaluating different metrics, resulting in an average detection latency of 50 ms, which meets the Near-Real-Time (Near-RT) requirements. Finally, in the response execution stage, once an anomaly is detected, the system triggers automated quarantine of the compromised xApp within 200 ms. This is coupled with dynamic policy updates through the SMO interface, and forensic logs are maintained with a retention period of one year for future analysis.  
To benchmark the system's performance, it was tested against OpenRAN Gym workloads, achieving a true positive rate of 99.2% for DDoS detection, with a very low false positive rate of 0.8% during normal operation. The system incurs only a 3.5% CPU overhead when processing up to 10,000 metrics per second, demonstrating its efficiency.  
Security alerts are prioritized using a weighted scoring system that combines the anomaly scores across the three monitored dimensions: API behavior, resource utilization, and model integrity. The formula for the alert score is given by  
\[\text{Alert Score}=0.4S_{\text{API}}+0.3S_{\text{Resource}}+0.3S_{\text{ Model}}, \tag{9}\]where \(S_{\text{API}},S_{\text{Resource}}\), and \(S_{\text{Model}}\) represent the normalized anomaly scores for each respective dimension. If the computed alert score exceeds a threshold of 0.7, the system automatically triggers containment procedures to isolate and mitigate the threat.  
For a clearer understanding of the alert scoring process, Algorithm1 illustrate how the system computes and processes these scores in real time.  
```
1:Input: Anomaly scores \(S_{\text{API}},S_{\text{Resource}},S_{\text{Model}}\)
2:Output: Alert score and containment decision
3:Alert Score \(\leftarrow\) 0.4 \(\times\)\(S_{\text{API}}+0.3\times S_{\text{Resource}}+0.3\times S_{\text{Model}}\)
4:if Alert Score > 0.7 then
5:Trigger containment procedures
6:else
7:Monitor and continue normal operation
8:endif
```  
**Algorithm 1** Alert Scoring Algorithm  
This algorithm ensures that the system reacts swiftly to security threats while maintaining minimal disruption to ongoing operations. The integration of ML models and rule-based checks offers a highly adaptable and resilient runtime monitoring system that continuously enhances security and performance in dynamic environments.