The Internet of Medical Things (IoMT) connects medical devices, wearable sensors, and cloud systems to deliver real-time healthcare. This ecosystem transmits highly sensitive patient data β ECG signals, EHR records, diagnostic images β continuously over networks.
Current security solutions fail because:
- Traditional encryption (AES, RSA) uses static keys that never adapt to changing threats
- Intrusion Detection Systems (IDS) detect threats but don't respond β encryption continues unchanged even after an attack is flagged
- IoMT devices are resource-constrained β heavy cryptographic methods are impractical
- Attacks like DDoS, MITM, replay, and data injection are increasingly sophisticated
The result: A detected intrusion does not stop ongoing data exposure. There is no closed-loop between detection and encryption response.
A unified, closed-loop security framework that:
- Detects threats using a hybrid CNN-BiLSTM model
- Classifies threat level (Low / Medium / High) from a continuous probability score
- Adapts encryption β key size, update frequency β based on threat severity
- Self-heals β automatically re-keys, blocks, and isolates under attack
IoMT Network Traffic
β
βΌ
ββββββββββββββββββββββββββββββββββββββββ
β PREPROCESSING β
β Normalize β One-hot encode β β
β Correlation-based feature selection β
ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββ
β CNN (Spatial Feature Extractor) β
β Conv β ReLU β MaxPool β
β Learns: traffic bursts, patterns β
ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββ
β BiLSTM (Temporal Sequence Model) β
β Forward LSTM + Backward LSTM β
β Concatenated: h_t = [βh_t ; βh_t] β
β Learns: multi-stage attack patterns β
ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
P_threat β [0,1] (sigmoid output)
β
βΌ
ββββββββββββββββββββ¬ββββββββββββββββββββ
β P < Ξ± β LOW β AES-128, slow rekeyβ
β Ξ± β€ P < Ξ² β MED β AES-256, rekey β
β P β₯ Ξ² β HIGH β AES-256, rekey + β
β β block + isolate β
ββββββββββββββββββββ΄ββββββββββββββββββββ
β
βΌ
ECDH Key Exchange β KDF(K, context) β AES Encryption
β
βΌ
Self-Healing: Isolate β Re-key β Restore channel
MedShield-AI/
βββ README.md
βββ requirements.txt
βββ src/
β βββ cnn_bilstm_ids.py # Hybrid CNN-BiLSTM intrusion detection model
β βββ threat_classifier.py # Threshold-based threat level classification
β βββ adaptive_encryption.py # AES + ECDH + dynamic re-keying
β βββ key_derivation.py # KDF with contextual binding
β βββ self_healing.py # Automated response & recovery module
β βββ preprocessing.py # Feature normalization & selection
β βββ train.py # Training pipeline
βββ notebooks/
β βββ MedShieldAI_Demo.ipynb
βββ results/
β βββ metrics.json
βββ images/
β βββ system_architecture.png
βββ LICENSE
CNN β Spatial Feature Extraction:
F_k = ReLU(W_k * X' + b_k) # Convolution
P_k = MaxPool(F_k) # Dimensionality reduction
Captures discriminative patterns: abnormal traffic bursts, irregular packet structures.
BiLSTM β Temporal Modeling:
βh_t = LSTM(P_t, βh_{t-1}) # Forward pass
βh_t = LSTM(P_t, βh_{t+1}) # Backward pass
h_t = [βh_t ; βh_t] # Concatenated representation
Models past + future context simultaneously β effective against multi-stage attacks.
Threat Probability Output:
P_threat = sigmoid(W_o Β· h_t + b_o) # β [0, 1]
Loss Function:
L = -(1/N) Ξ£ [y_iΒ·log(P_i) + (1-y_i)Β·log(1-P_i)] # Binary cross-entropy
Optimized with Adam optimizer.
| Threat Level | Condition | AES Key Size | Re-key Interval | Response |
|---|---|---|---|---|
| Low | P_threat < Ξ± | AES-128 | Slow | Monitor |
| Medium | Ξ± β€ P < Ξ² | AES-256 | Moderate | Re-key |
| High | P_threat β₯ Ξ² | AES-256 | Rapid | Re-key + Block + Isolate |
Key update interval adapts automatically:
t_update = 1 / (1 + P_threat)
Higher threat β shorter interval β more frequent key rotation.
Q_A = d_A Β· G # Device A public key
Q_B = d_B Β· G # Device B public key
K = d_A Β· Q_B # Shared secret (never transmitted)
= d_B Β· Q_A
Key Derivation with Contextual Binding:
K_enc = KDF(K, [timestamp, session_id, device_id, threat_level])
Every session uses a unique derived key β forward secrecy guaranteed.
K_new = KDF(K_old, P_threat, t)
Compromised keys are replaced automatically. Past sessions remain secure.
State Machine: Normal β Suspicious β Compromised
β
Filter malicious traffic:
X_safe = X \ X_malicious
β
Regenerate keys + re-establish channel:
C_new = AES(K_new, M)
Intrusion Detection Metrics: Accuracy, Precision, Recall, F1-Score
System Metrics: Latency, Computational Overhead
Datasets: Benchmark network intrusion detection datasets (normal + malicious traffic)
pip install -r requirements.txtpython src/train.py --epochs 50 --lr 1e-3python src/adaptive_encryption.py --threat_level highpython src/self_healing.py --mode demoSee requirements.txt for full dependencies.