Continuous Behavioral-Authentication Banking(Can be deployed to any general purpose website/broswer) Prototype
Next-Generation Zero-Trust Security Powered by Real-Time Telemetry and Isolation Forest Anomaly Detection
- > Project Overview
- > Key Features
- > System Architecture & Data Flow
- > Adaptive Security Policy Matrix
- > Offline Model Evaluation
- > Getting Started (Live Demo)
- > Machine Learning Pipeline Commands
- > Security & Cryptographic Details
- > Project Layout
Strix is a fully functional continuous behavioral-authentication prototype. Unlike standard authentication methods (which check identity only once at login), Strix continually verifies that the logged-in user is indeed the owner throughout the session by analyzing behavioral biometrics:
- Typing Dynamics: Keydown/keyup times, dwell intervals, and flight times.
- Mouse Movements: Speed, acceleration, jerk, std dev, and straightness.
- Scroll Mechanics: Patterns in page navigation.
These interaction patterns are captured in the browser, summarized into a 37-dimension feature vector every few seconds, and transmitted to a Python Flask API. An offline-trained Isolation Forest model evaluates the vector to detect anomalies. The resulting anomaly score is calibrated into a 0β100% Trust Score and smoothed using an Exponential Moving Average (EMA) to filter transient noise before updating the app's access policy in real-time.
- π Real-Time Telemetry Collector: Captures keystrokes, mouse moves, and scroll dynamics without interfering with the user experience.
- π§ Isolation Forest Anomaly Detection: Model trained solely on genuine owner behavior. Impostor/negative profiles are never required during fittingβonly for calibration.
- γ°οΈ EMA Trust Smoothing: Employs Exponential Moving Average (
Ξ± = 0.4) to absorb temporary noise, preventing false-positive lockouts while maintaining high sensitivity to user changes. - π‘οΈ Fail-Closed Security: Decays trust scores gracefully to
0%if telemetry is lost or the ML API is unreachable, securing the dashboard. - π Secure Local Hashing: Utilizes Argon2id (via
argon2-cffi) to protect owner passwords and emergency lockout recovery keys stored in SQLite.
Below is the runtime flow representing how behavioral interactions are captured, evaluated, and enforced:
graph TD
A[Browser Events: Mouse, Keyboard, Scroll] -->|telemetry| B(assets/js/collector.js)
B -->|raw signals| C(assets/js/featureExtractor.js)
C -->|37-key feature vector| D(assets/js/mlAdapter.js)
D -->|POST /predict| E{Flask server/app.py}
E -->|decision_function| F[model_out/model.pkl & scaler.pkl]
F -->|Raw Anomaly Score| G[server/app.py: trust_from_score]
G -->|EMA Trust Smoothing| H[TrustController]
H -->|real-time trust update| I(PolicyEngine)
I -->|Enforce Access Band| J[Banking UI Views & Research Console]
style A fill:#1e1e2f,stroke:#00d2ff,stroke-width:2px,color:#fff
style E fill:#0d1117,stroke:#39c5bb,stroke-width:2px,color:#fff
style F fill:#0d1117,stroke:#ff79c6,stroke-width:2px,color:#fff
style I fill:#1e1e2f,stroke:#50fa7b,stroke-width:2px,color:#fff
style J fill:#1e1e2f,stroke:#bd93f9,stroke-width:2px,color:#fff
Based on the smoothed trust score, the PolicyEngine dynamically limits banking views and operations:
| π‘οΈ Policy Band | π Trust Range | π·οΈ Label | π Action & Friction Level |
|---|---|---|---|
FULL |
80% - 100% |
Full Access | No friction. User can transfer funds and add beneficiaries freely. |
STEPUP |
60% - 79% |
Step-Up Verification | High-value transactions (exceeding βΉ50,000) require SMS/MFA verification. |
RESTRICT |
40% - 59% |
Restricted Access | Suspicious behavior detected. Fund transfers are disabled; beneficiary management is locked. |
LOCK |
< 40% |
Session Locked | Critical risk. Session is instantly locked. Safe lockout recovery screen displayed. |
The Isolation Forest classifier is validated offline against genuine and hard-negative (impostor) sessions. Review the generated curves in the repository (reports/figures/):
Evaluates the true-positive rate vs. the false-positive rate across decision thresholds.
Displays the percentage of genuine and hard-negative test sessions that fall into each of our four policy tiers.
Shows the separation of scores between genuine (blue) and impostor (red) sessions.
Follow these steps to run the interactive banking prototype locally:
Ensure you have Python 3.9+ installed.
Create a virtual environment and install the required libraries:
# Create virtual environment
python -m venv .venv
# Activate virtual environment
# On Windows:
.\.venv\Scripts\Activate.ps1
# On Linux/macOS:
source .venv/bin/activate
# Install required Python packages
pip install -r requirements.txtServes predictions and manages Argon2id credentials.
python -m server.app(The model will load from model_out/ and bind to http://127.0.0.1:5000/)
In a second terminal (with .venv active), launch a static server:
python -m http.server 8000Navigate to:
http://127.0.0.1:8000/
- Username:
owner - Password:
password123 - Recovery Key:
emergency-recovery-key-2026(You can modify these credentials securely inside the Profile & Security dashboard tab)
If you wish to rebuild the feature tables, retrain the model, or re-run the visualizations, use the following commands from the root directory:
# 1. Compile genuine raw JSON/Parquet sessions into a feature table
python -m ml_pipeline.build_dataset --genuine-dir data\true_sessions --out data\processed\genuine.parquet
# 2. Compile hard-negative raw sessions
python -m ml_pipeline.build_dataset --negative-dir data\hardnegtive_sessions --out data\processed\hardnegative.parquet
# 3. Train the Isolation Forest model and calibrate score anchors
python -m ml_pipeline.train_model --genuine data\processed\genuine.parquet --negative data\processed\hardnegative.parquet --out-dir model_out
# 4. Re-generate all evaluation plots
python -m ml_pipeline.plot_results --genuine data\processed\genuine.parquet --negative data\processed\hardnegative.parquet --model-dir model_out --out-dir reports\figuresπ Password & Recovery Key Protection
BankGuard incorporates modern cryptographic hashing standard Argon2id (configured with parameters: time_cost=3, memory_cost=65536, parallelism=2) to guard sensitive inputs. Plaintext values are verified in-memory and are never stored to SQLite or exposed in terminal output logs.
π Trust Smoothing (EMA Formula)
To manage False Rejection Rate (FRR) anomalies caused by transient disruptions (e.g. user pauses typing or adjusts their posture), the server applies Exponential Moving Average smoothing on the trust score:
With
β οΈ Connection Lost & Fail-Closed Strategy
If the browser telemetry client loses connection to the Python API or fails to transmit telemetry within the window configured in assets/js/config.js, the mlAdapter.js drops the Trust Score to 0%. This immediately triggers the LOCK policy, protecting account dashboards from exposure.
WEB_Lab/
βββ index.html # Main dashboard application shell
βββ requirements.txt # Python dependencies
βββ README.md # Visual project documentation
βββ bankguard.db # SQLite user and credential database
βββ assets/
β βββ banner.jpg # High-tech system header banner
β βββ css/
β β βββ main.css # Custom layout and typography styles
β βββ js/
β βββ app.js # Application core initialization
β βββ collector.js # Mouse, keyboard, and scroll listener
β βββ featureExtractor.js # Extracts 37 features from raw streams
β βββ mlAdapter.js # Relays features to the Flask API
β βββ policyEngine.js # Evaluates trust tiers and updates UI state
β βββ trustController.js # Manages stream subscriptions and EMA
β βββ views.js # HTML templates for the dashboard modules
β βββ bankDB.js # Seeds mock user profile, cards, and data
βββ server/
β βββ app.py # Model API & credential controller
β βββ credentials_store.py # Argon2id DB logic for login credentials
β βββ recovery_key_store.py # Argon2id DB logic for emergency keys
βββ ml_pipeline/
β βββ feature_extractor.py # Standard feature calculation engine
β βββ build_dataset.py # Compiles raw session parquets
β βββ train_model.py # Fits Isolation Forest & handles scaling
β βββ plot_results.py # Matplotlib evaluator curves script
β βββ parity_check.py # Compares browser and python feature output
βββ model_out/
β βββ model.pkl # Isolation Forest model artifact
β βββ scaler.pkl # RobustScaler artifact
β βββ calibration.json # Calibrated decision score anchors
β βββ stats.json # Diagnostic accuracy and AUC metrics
βββ reports/
βββ figures/
βββ fig_C_roc_curve.png # Generated ROC curve
βββ fig_D_band_distribution_both.png # Band evaluation chart
βββ fig_E_trust_histogram.png # Score histogram


