Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Zero-Trust Adversarial Intrusion Detection System

Research Project Β· Department of Computer Science & Engineering Β· SRM Institute of Science and Technology

πŸ“„ Paper under review β€” Journal of Information Security and Applications, Elsevier Β· Scopus Q1 Β· IF 3.7

Python PyTorch Streamlit Dataset Dataset License


Research Question

Can Zero-Trust context-aware policies mitigate adversarial evasion attacks against ML-based network intrusion detection systems β€” without requiring adversarial retraining of the underlying model?

Answer: Yes. While FGSM/PGD adversarial attacks achieve a 65% bypass rate against the ML classifier alone, the Zero-Trust contextual policy layer reduces the effective system bypass rate to 2.2% β€” a 96.6% reduction β€” without any model retraining.


Key Results

Metric UNSW-NB15 CICIDS-2017
ML Classifier Accuracy 90.7% 99.9%
Seeds (statistical validity) 5 5
Condition Attack Bypass Rate
ML classifier alone (adversarial) 65%
ML classifier + Zero-Trust context layer 2.2%
Reduction 96.6%

All accuracy metrics are averaged across 5 independent random seeds for statistical robustness.


What This Project Does

ML-based intrusion detection systems are vulnerable to adversarial evasion attacks β€” carefully crafted perturbations to network traffic features that cause the model to misclassify malicious flows as benign. This project investigates whether the contextual policy layer of a Zero-Trust Network Architecture (ZTNA) can compensate when the ML component is actively fooled, without needing to retrain the model against adversarial examples.

The key insight is dimensional orthogonality: gradient-based adversarial attacks operate in the network feature space of the ML model, while Zero-Trust contextual signals (device trust, geographic risk, identity tier, time-of-day) exist in a completely separate information space sourced from external systems that cannot be manipulated by crafting network packet features. An attacker who suppresses their ML risk score through adversarial perturbation still cannot escape a DENY decision if their device enrollment status or geographic IP reputation flags them as suspicious.


System Architecture

Network Traffic (UNSW-NB15 / CICIDS-2017 features)
          β”‚
          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   ML Risk Classifier    β”‚  ←  Neural Net: Input β†’ 128 β†’ 64 β†’ 32 β†’ 1 (PyTorch)
β”‚   Risk Score: 0.0 – 1.0 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚          β–²
           β”‚          β”‚  FGSM / PGD adversarial perturbation
           β”‚          β”‚  (domain-constrained, Ξ΅-bounded)
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Context Enrichment    β”‚  ←  Device Trust Β· Geo-Risk Β· Identity Tier Β· Time-of-Day
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Zero-Trust Policy     β”‚  ←  Priority-ordered rule engine
β”‚   Engine                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β–Ό
   ALLOW / DENY / STEP_UP_AUTH / RATE_LIMIT / ISOLATE
           β”‚
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   SOC Telemetry Log     β”‚  ←  Structured JSON audit trail
β”‚   Streamlit Dashboard   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Datasets

Dataset Description Features
UNSW-NB15 Modern network intrusion dataset from the Australian Centre for Cyber Security 49 features, 9 attack categories
CICIDS-2017 Canadian Institute for Cybersecurity network traffic dataset Benign + 14 attack types

Both datasets were preprocessed through the same pipeline: feature selection, normalisation, and encoding of categorical fields before training.


Adversarial Attack Implementation

FGSM (Fast Gradient Sign Method) β€” single-step attack, perturbs input features in the direction that maximally increases model loss:

x_adv = x + Ξ΅ Β· sign(βˆ‡_x J(ΞΈ, x, y))

PGD (Projected Gradient Descent) β€” iterative, stronger attack; takes multiple small steps and projects back into the valid feature range after each step:

x_t+1 = Ξ _{x+S}(x_t + Ξ± Β· sign(βˆ‡_x J(ΞΈ, x_t, y)))

Both attacks are domain-constrained: perturbations are bounded to realistic network traffic feature ranges. Features with physical constraints (e.g., non-negative packet sizes, valid port ranges) are clamped after each perturbation step to ensure the adversarial examples remain plausible network traffic.


Zero-Trust Context Signals

Signal Low Risk Medium Risk High Risk
Device Trust Enrolled, compliant Unknown device Untrusted / blacklisted
Geographic Risk Home region Unusual region High-risk region
Identity Tier Privileged user Standard user Guest / service account
Time-of-Day Business hours Off-hours Unusual hours

The policy engine combines the ML risk score with these four context signals through a priority-ordered rule set. An adversarial packet that suppresses the ML risk score still fails the policy check if any context signal exceeds its threshold for the requested resource.


Ablation Study

The ablation study isolates the contribution of each context signal to the overall adversarial robustness:

Configuration Adversarial Bypass Rate
ML Classifier Only 65.0%
ML + Device Trust Context ~38%
ML + Geographic Risk Context ~45%
Full System (All Context Signals) 2.2%

The full context combination is what drives the result β€” no single signal alone achieves comparable robustness.


Quick Start

Prerequisites: Python 3.10+

# 1. Clone the repository
git clone https://github.com/Aarnav-Singh/adversarial-ml-security-framework.git
cd adversarial-ml-security-framework

# 2. Install dependencies
pip install -r requirements.txt

# 3. Download datasets
# UNSW-NB15: https://research.unsw.edu.au/projects/unsw-nb15-dataset
# CICIDS-2017: https://www.unb.ca/cic/datasets/ids-2017.html
# Place files in the data/ folder

# 4. Train the ML classifier
python scripts/train_baseline.py

# 5. Launch the interactive SOC dashboard
streamlit run src/dashboard/app.py
# Open http://localhost:8501

The dashboard has three tabs:

  • SOC Console β€” live traffic simulation and real-time decision log
  • Red Team β€” adversarial attack testing with configurable Ξ΅
  • Blue Team β€” defense analytics and context signal breakdown

Reproducing the Paper Results

All experiments use fixed random seeds and are fully reproducible. Run in this order:

python scripts/train_multiseed.py      # Train across 5 seeds β†’ CI metrics
python scripts/run_ablation.py         # 4-configuration ablation study
python scripts/run_epsilon_sweep.py    # FGSM + PGD across Ξ΅ = 0.01 to 0.20

Results are saved to results/ as JSON. The key output is results/ablation_results.json, which directly corresponds to the ablation table in the paper.


Repository Structure

adversarial-ml-security-framework/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config.py                    # Central configuration & hyperparameters
β”‚   β”œβ”€β”€ data/network_loader.py       # UNSW-NB15 / CICIDS-2017 loading & preprocessing
β”‚   β”œβ”€β”€ risk_engine/                 # Neural network model definition & inference
β”‚   β”œβ”€β”€ attacks/                     # FGSM, PGD, epsilon sweep, constraint validator
β”‚   β”œβ”€β”€ policy/                      # Context enrichment & Zero-Trust rule engine
β”‚   β”œβ”€β”€ system/                      # Full pipeline integration layer
β”‚   β”œβ”€β”€ evaluation/                  # Multi-seed runner, statistics, reporting
β”‚   β”œβ”€β”€ training/                    # Model training & adversarial retraining
β”‚   β”œβ”€β”€ logging/                     # SOC telemetry & blue team analytics
β”‚   └── dashboard/app.py             # Streamlit interactive dashboard
β”œβ”€β”€ scripts/                         # Runnable experiment scripts
β”‚   β”œβ”€β”€ train_baseline.py            # ← Start here
β”‚   β”œβ”€β”€ train_multiseed.py
β”‚   β”œβ”€β”€ run_ablation.py
β”‚   β”œβ”€β”€ run_epsilon_sweep.py
β”‚   └── test_zero_trust_system.py
β”œβ”€β”€ docs/                            # Full documentation
β”œβ”€β”€ data/                            # Place dataset files here (not committed)
β”œβ”€β”€ models/                          # Trained model checkpoints (generated locally)
β”œβ”€β”€ results/                         # Experiment outputs (generated by scripts)
β”œβ”€β”€ figures/                         # Architecture diagrams & paper figures
β”œβ”€β”€ requirements.txt
└── LICENSE

Documentation

For researchers:

  • Research Methodology β€” Dataset preprocessing, model architecture, attack generation, evaluation metrics
  • Architecture β€” Component design, data flow, policy rule table
  • Threat Model β€” Attacker capabilities, domain constraints, security assumptions
  • Adversarial Attacks β€” FGSM and PGD implementation details

For developers:


Requirements

torch==2.0.1
numpy==1.24.3
pandas==2.0.3
scikit-learn==1.3.0
streamlit==1.28.0
plotly==5.17.0
joblib==1.3.2

Academic Context

This is the research paper basis:

"Zero-Trust Context-Aware Defense Against Adversarial Evasion Attacks on ML-Based Network Intrusion Detection Systems" Currently under review β€” Journal of Information Security and Applications, Elsevier, Scopus Q1, Impact Factor 3.7

Available on request.


License

Released under the MIT License for educational and research purposes. Adversarial attack implementations are included solely to evaluate and demonstrate defensive mechanisms β€” not for offensive use.


Author

Aarnav Singh Β· Portfolio Β· LinkedIn Β· aarnavujji@gmail.com

About

A learning-focused simulation of adversarial attacks against ML-based network intrusion detection systems within a Zero-Trust architecture, including constrained adversarial modeling, policy enforcement, and security-focused evaluation metrics.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages