Skip to content
Projects

OkbaBenatia/AIoT-Autonomous-Security-Lab

View on GitHub

About

Interactive, deterministic educational simulation of an agentic AI workflow securing a smart-building IoT digital twin (React + TypeScript, fully offline).

Learning & Education

How these counts are measured

What you can do

  • Interactive Digital Twin of a four-zone building (research laboratory, smart classroom, server room, building infrastructure) drawn as an architectural floor plan.
  • Nine simulated IoT devices, each with its own vector illustration (thermometer, humidity probe, air-quality monitor, PIR motion sensor, smart bulb, wall-mounted probe, smart meter, gateway, HVAC unit) and four visual states: normal, warning, critical, isolated.
  • Animated telemetry tied to the simulation state: regular pulses, message bursts, irregular transmissions with gaps, and unplugged links after isolation. Animations pause with the simulation and respect the reduced motion accessibility preference.
  • Three scenarios: Normal Operation, Simulate Cyberattack, Simulate Sensor Fault.

Measured star growth

in 24h
Collecting history
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

AIoT Autonomous Security Lab

Agentic AI • Digital Twins • Autonomous IoT Security

Live demo Deploy to GitHub Pages License: MIT

An open, interactive teaching simulation that shows how an agentic AI workflow could monitor a smart building's IoT devices, detect and investigate anomalies, weigh the evidence and propose a safe, proportionate response — with a human approving every consequential action.

▶ Live demo: https://okbabenatia.github.io/AIoT-Autonomous-Security-Lab/

[!IMPORTANT] This is a deterministic educational simulation, not a real AI or cybersecurity system. All telemetry is synthetic and seeded. The "Simulated AI Agent" is a hand-written, rule-based workflow that mimics the structure of a tool-using AI agent (observe, call tools, collect evidence, decide, ask a human). No large language model, AI API, real IoT device, MQTT broker, network monitor, database or backend is involved, and the application makes no network requests at runtime.

Digital Twin during an agent decision on a simulated cyberattack


Contents

Scientific motivation

Agentic AI is increasingly proposed for autonomous monitoring of cyber-physical systems. Before such systems can be trusted, students and researchers need an intuition for how an agent reasons, where it can go wrong and why human oversight matters. This lab makes four ideas tangible:

  1. Digital Twin – a live floor plan of a fictional smart university building with nine illustrated IoT devices and animated telemetry links to a gateway.
  2. Agentic workflow – Observe → Detect → Investigate → Decide → Respond: the simulated agent calls "tools", performs the detection itself and records the evidence each tool returns.
  3. False positives – an anomaly is a question, not an answer. The same alarming reading can come from an attack or from a broken sensor, and the correct responses differ.
  4. Human oversight – the agent only proposes; a person approves, rejects or acknowledges.

Because every run is deterministic, a demonstration can be rehearsed, repeated and discussed precisely.

Screenshots

Normal operation and device inspector Agent investigation in progress
Normal operation with the humidity sensor inspector open The agent investigating a simulated cyberattack
Human decision on a suspected compromise Sensor fault in Presentation Mode
Decision card proposing isolation Sensor-fault investigation recommending inspection

Main features

  • Interactive Digital Twin of a four-zone building (research laboratory, smart classroom, server room, building infrastructure) drawn as an architectural floor plan.
  • Nine simulated IoT devices, each with its own vector illustration (thermometer, humidity probe, air-quality monitor, PIR motion sensor, smart bulb, wall-mounted probe, smart meter, gateway, HVAC unit) and four visual states: normal, warning, critical, isolated.
  • Animated telemetry tied to the simulation state: regular pulses, message bursts, irregular transmissions with gaps, and unplugged links after isolation. Animations pause with the simulation and respect the reduced motion accessibility preference.
  • Three scenarios: Normal Operation, Simulate Cyberattack, Simulate Sensor Fault.
  • Simulated AI Agent with a five-stage workflow. Injecting a scenario only changes raw telemetry; the anomaly is detected by the agent when the presenter clicks Run Agent Investigation.
  • Evidence-based investigation: history, sudden deviation, message rate, missing samples, repeated values and neighbouring sensors, all computed from the synthetic data.
  • Human-in-the-loop response: Approve Isolation / Reject Action for a suspected compromise, Acknowledge Inspection Recommendation for a probable sensor fault.
  • Device inspector with current reading, normal range, history chart, security state and link rate.
  • Technical Details panel listing the functions actually executed, every anomaly score, the thresholds and the result of each decision rule.
  • Presentation Mode for screen sharing at 1920 × 1080 (also usable at 1366 × 768), mouse-only.
  • Fully offline after npm install; deterministic and reproducible.

Architecture

flowchart LR
    subgraph Building["Digital Twin (synthetic)"]
        D1["9 simulated IoT devices<br/>seeded telemetry"] --> GW["IoT Gateway<br/>message rate"]
    end
    GW --> OBS
    subgraph Agent["Simulated AI Agent (deterministic rules)"]
        OBS["1 · Observe<br/>getDeviceTelemetry()"] --> DET["2 · Detect<br/>calculateAnomalyScore()"]
        DET --> INV["3 · Investigate<br/>getDeviceHistory()<br/>compareSensorReadings()"]
        INV --> DEC["4 · Decide<br/>classifySimulatedIncident()<br/>recommendSimulatedAction()"]
    end
    DEC --> HUM{"5 · Respond<br/>human decision"}
    HUM -- approve --> ACT["applySimulatedAction()<br/>isolate / flag for inspection"]
    HUM -- reject --> MON["keep monitoring"]
    ACT --> D1

The simulation core is plain TypeScript with no UI dependencies; the interface is React.

src/
  sim/                     Pure TypeScript simulation core (no React)
    types.ts               Data model
    devices.ts             9 fictional devices, 4 zones, floor-plan coordinates
    telemetry.ts           Seeded synthetic telemetry, scenario overlays, agent read tools
    agent.ts               Anomaly score, detection scan, history analysis, peer comparison,
                           classification, recommendation
    engine.ts              Pure reducer / state machine: ticks, agent steps, human decisions
    engine.test.ts         Tests of detection, decision rules and state transitions
  components/              React UI (Tailwind CSS, Lucide icons, hand-built SVG)
    Header.tsx             Title, status, clock, controls, scenario bar
    DigitalTwin.tsx        Device cards, cable routes, telemetry pulses, agent tool-call lines
    FloorPlan.tsx          Walls, doors, windows and room furniture
    DeviceArt.tsx          One vector illustration per device type
    DeviceInspector.tsx    Floating device inspector
    AgentPanel.tsx         Five-stage stepper and human decision card
    TechnicalDetails.tsx   Executed tools, scores, thresholds, rule results
    EventHistory.tsx       Collapsible event list
  App.tsx                  Layout, timer, Presentation Mode

All state lives in a single pure reducer (simReducer). A one-second timer dispatches TICK; one tick is one telemetry cycle of 5 simulated seconds, and the simulated clock starts at 08:00:00.

Technology: React 19, TypeScript, Vite, Tailwind CSS 4, Lucide icons, Vitest. Fonts are bundled locally, so no external font or CDN request is made.

Installation

Requirements: Node.js 20 or newer and npm.

git clone https://github.com/OkbaBenatia/AIoT-Autonomous-Security-Lab.git
cd AIoT-Autonomous-Security-Lab
npm ci            # or: npm install
npm run dev       # http://localhost:5173

Other commands:

npm test          # run the automated tests (Vitest)
npm run build     # type-check and build the static site into dist/
npm run preview   # serve the production build at http://localhost:4173/AIoT-Autonomous-Security-Lab/

No API keys, accounts, backend, database or internet connection are needed after installation.

Deployment. Every push to main runs the tests, builds the site and publishes dist/ to GitHub Pages through .github/workflows/deploy.yml. The production base path is set in vite.config.ts (/AIoT-Autonomous-Security-Lab/); forks published under a different repository name should change it there.

The three simulation scenarios

Scenario What happens (ground truth, hidden from the agent) Expected agent outcome
Normal Operation All devices report within range; the gateway forwards about 108 msg/min. Isolated or flagged devices are restored. No anomaly found.
Simulate Cyberattack The laboratory temperature sensor LAB-TMP-01 jumps from about 23 °C to about 95 °C and sends 6× its usual message rate (a fictional data-injection attack). Neighbouring sensors stay normal. Suspicious telemetry — verification required → propose temporary isolation.
Simulate Sensor Fault The server-room probe SRV-TMP-01 intermittently reports exactly 85.0 °C (a power-on reset value documented for some digital temperature sensors), drops samples and otherwise reads normally. Likely sensor malfunction — inspection recommended (not isolation: a false positive avoided).

Simulated devices

Zone Device Measurement Normal range
Research Laboratory LAB-TMP-01 Temperature Sensor Air temperature 19–27 °C
LAB-HUM-01 Humidity Sensor Relative humidity 30–60 %RH
LAB-AQ-01 Air-Quality Sensor CO₂ 400–1000 ppm
Smart Classroom CLS-MOT-01 Motion Detector Motion events 0–40 /min
CLS-LGT-01 Smart Lighting Illuminance 300–700 lux
Server Room SRV-TMP-01 Server Temperature Probe Cold-aisle temperature 18–27 °C
SRV-PWR-01 Energy Monitor Rack power 3–9 kW
Building Infrastructure INF-GW-01 IoT Gateway Forwarded messages 60–220 msg/min
INF-HVAC-01 HVAC Controller Supply-air temperature 13–20 °C

Each value is baseline + slow drift + noise, where the noise comes from a stateless integer hash of (seed, device, tick), so every run replays identically.

How the simulated agent decides

The agent never sees the scenario name; it only applies the rules below to telemetry. A test checks that the same data produces the same conclusion whatever scenario label is attached to it.

1 · Observe – getDeviceTelemetry() reads the latest sample of every trusted device.

2 · Detect – calculateAnomalyScore() is applied to every reading not yet reviewed since the environment was last restored, for every trusted, scored device:

score = 0.45 · min(z / 8, 1)                       deviation from a synthetic 24 h profile (z-score)
      + 0.35 · [outside range] · min(1, 0.5 + excess / rangeWidth)
      + 0.20 · min(|Δ| / (0.5 · rangeWidth), 1)    sudden change from the previous valid sample
anomaly  ⇔  score ≥ 0.50

The device with the highest anomalous score becomes the incident. If no score reaches 0.50 the workflow stops with No anomaly found. In normal operation the highest score over 3,000 ticks is about 0.15.

3 · Investigate – getDeviceHistory() characterises the samples since onset (sustained or intermittent pattern, missing samples, maximum rate of change against a physically plausible limit, message rate against 12 msg/min, exact repeated values). compareSensorReadings() cross-checks physically related sensors.

4 · Decide – classifySimulatedIncident() scores three hypotheses with explicit rules:

Rule Evidence Supports
R2 Related sensors remain normal compromise +1, fault +1 (physical event −2)
R3 Related sensors also abnormal physical event +2
R4 Physically implausible rate of change physical event −1
R5 Sustained abnormal values compromise +1
R6 Intermittent abnormal values fault +2
R7 Telemetry burst (≥ 3× message rate) compromise +2
R8 ≥ 15 % of samples missing fault +1
R9 Complete, regular data stream compromise +1
R10 Repeated identical abnormal value fault +1
R11 Normal or reduced message rate fault +1

A hypothesis is selected only with ≥ 3 points and a lead of ≥ 2 points; otherwise the result is inconclusive. A single abnormal reading is never enough. recommendSimulatedAction() maps the result to a proportionate action: suspected compromise → temporary isolation; probable sensor fault → inspection (device stays online, readings flagged untrusted); possible physical event → escalation; inconclusive → keep monitoring. The suspected compromise is always described as requiring verification, never as a proven attack.

5 · Respond – nothing changes until a human decides. applySimulatedAction() is the only function that modifies device state, and isolation affects only the selected simulated device.

Suggested classroom demonstration

The full sequence takes about 10–15 minutes and needs only a mouse.

Minutes Step
0–2 Click Normal Operation. Show the rooms, the nine devices and the telemetry flowing to the gateway and the agent. Open the inspector on one or two devices.
2–4 Click Simulate Cyberattack. The lab temperature jumps to ~95 °C with a burst of messages — raw data only, not yet assessed by the agent.
4–8 Click Run Agent Investigation and follow Observe → Detect → Investigate → Decide. The devices being queried are highlighted on the twin.
8–10 Read the decision card, then Approve Isolation or Reject Action and watch the twin update.
10–13 Click Reset, Simulate Sensor Fault, then Run Agent Investigation. The agent recommends inspection, not isolation.
13–15 Optionally open Technical Details; discuss verification, false positives and human oversight.

Educational and research applications

  • University courses in IoT, cyber-physical systems, cybersecurity and AI: a concrete, visual case study of anomaly detection, evidence gathering and proportionate response.
  • Master's and PhD projects: a transparent baseline to extend with new devices, scenarios, detection rules or explanation techniques, or to compare against learned models on synthetic data.
  • Teaching agentic AI without hype: students see what an agent's "tools" and "evidence" are, and where human judgement must stay in the loop.
  • Discussion of false positives and automation bias: the attack and the sensor fault produce similarly alarming readings but require different responses.
  • Scientific demonstrations and outreach: deterministic, offline and rehearsable, suitable for lectures, seminars and public events.

Scientific limitations

  • All data are synthetic. The building, devices, attack and fault are fictional and simplified.
  • The agent is a hand-written rule set, not machine learning and not a language model. It illustrates the structure of an agentic investigation; it does not demonstrate real-world intelligence.
  • Thresholds, weights and the synthetic "24 h profile" were chosen for clarity, not calibrated on real deployments. No detection performance is claimed or measured.
  • Real attacks can mimic faults and vice versa; classes are therefore labelled suspected or probable, and verification is always required.
  • Real agentic security systems need validation, guardrails, audit logging, access control and safety review. None of these are in scope here.

Testing

npm test

src/sim/engine.test.ts covers deterministic telemetry, anomaly-score bounds, normal operation without false alarms, raw telemetry shown without an incident before the agent runs, detection inside the agent's Detect stage, cyberattack classification and isolation of only the target, rejection, pausing and stepping the investigation, re-running after isolation, sensor-fault classification and inspection, the single-sample rule, independence from the scenario label, repeated scenario switches and reset. src/components/deviceArt.test.ts checks that all nine devices have distinct illustrations.

Contributing

Contributions from students, researchers and educators are very welcome — new scenarios, devices, detection rules, translations, accessibility improvements, documentation or teaching material. Please read CONTRIBUTING.md before opening an issue or a pull request.

Citing this project

If you use this lab in teaching, a thesis or a publication, please cite it. GitHub's "Cite this repository" button uses CITATION.cff; a BibTeX entry is:

@software{benatia_aiot_autonomous_security_lab,
  author  = {Ben Atia, Okba},
  title   = {{AIoT Autonomous Security Lab: an interactive simulation of agentic AI, digital twins and autonomous IoT security}},
  year    = {2026},
  version = {1.0.0},
  url     = {https://github.com/OkbaBenatia/AIoT-Autonomous-Security-Lab},
  license = {MIT}
}

⭐ Support the project

If this lab is useful for your course, research or demonstration, please star the repository, share it with colleagues and students, cite it in your work and contribute improvements. Feedback from classroom use is especially valuable — open an issue to tell us how you used it.

Developer

Developed by Dr. Okba BEN ATIA Université Marie et Louis Pasteur, France

License and third-party notices

The source code is released under the MIT License.

The application bundles the following third-party components, each under its own license:

The device illustrations, floor plan and simulation logic were created for this project and are covered by the MIT License.

Explore related projects

Loading…