DEV Community

SynapseSec
SynapseSec

Posted on

I Built a World's first Working Neural Signal Security System for BCI Devices (AES-256 + Anomaly Detection)

Why I built this

As brain-computer interfaces (like Neuralink and similar consumer devices) move closer to everyday use, the signal data they transmit — literally data from your brain — needs the same level of protection as any other sensitive channel. I got curious about what that protection could actually look like, so I built a working prototype: SynapseSec.

I'm a student in Pakistan with zero engineering background a few weeks ago. This was as much a learning exercise as it was a build.

What it does

SynapseSec simulates a full BCI signal pipeline and protects it end-to-end:

  • AES-256-GCM encryption — every signal is encrypted before it "leaves" the device
  • HMAC-based device authentication — a challenge-response system that blocks spoofed or unauthenticated devices
  • Real-time anomaly detection — checks amplitude, variance, and signal shape to catch injection attacks, replayed data, and flatline/dead-sensor spoofing
  • A live browser dashboard — visualizes the whole pipeline, from signal capture through encryption, decryption, and anomaly verdicts

It runs on simulated EEG data (I don't have real BCI hardware), but every cryptographic operation is genuinely executing — nothing is mocked.

Live demo

🔗 regal-naiad-3eff44.netlify.app

Try running a normal signal through the pipeline, then switch to the "injection attack" mode and watch the anomaly detector catch and block it.

How it's built

Backend (Python):

  • eeg_simulator.py — generates realistic EEG-like signals across 4 channels using layered sine waves + noise
  • encryption.py — AES-256-GCM encryption/decryption using the cryptography library
  • device_auth.py — HMAC-SHA256 challenge-response authentication
  • anomaly_detector.py — rule-based detection (amplitude thresholds, variance checks) — a first version that could evolve into a trained ML model
  • main.py — orchestrates the full pipeline

Frontend (JavaScript):

  • The dashboard reimplements the same logic client-side using the Web Crypto API for real AES-256-GCM encryption directly in the browser
  • Canvas-based live waveform rendering
  • A simulated device connection panel (Bluetooth/Wi-Fi) and incident log

What I'd add next

  • Integration with a real device via BrainFlow (an open-source library supporting OpenBCI, Muse, and other research-grade EEG hardware)
  • A trained anomaly detection model instead of rule-based thresholds
  • Proper key management (currently keys are generated per-session, not persisted or rotated)

Feedback welcome

If you work in security, BCI, or neurotech, I'd genuinely love your thoughts — especially on the anomaly detection approach, or what a production-grade version would need to get right.

Thanks for reading!

Top comments (0)