How moreyash007/nerofence works
NeuroFence is an air-gapped desktop scanner for detecting LLM weight poisoning and backdoors. An analyst selects a local model; the worker audits and safely loads it, records baseline activations, exercises adversarial prompts, and scores anomalies before returning a report to the desktop console. A separate static viewer reads exported reports locally and presents scores, flagged neurons, integrity findings, layer profiles, and activation heatmaps. The README documents these workflows; sampled source confirms key orchestration and viewer paths, while some subsystem wiring is documented rather than directly sampled.
Main entry points: worker.py Scan worker · page.tsx Viewer page · app.py Desktop console · sandbox_tracker.py Audit and loader
Components 21
Scanning
- Audit and loader
sandbox_tracker.py - MLP hook capture
sandbox_tracker.py - Activation statistics
sandbox_tracker.py - Prompt generation
fuzzer.py - Anomaly scoring
detector.py
Desktop console
- Desktop console
app.py - Scan worker
worker.py - Exported report
Report viewer
- Viewer page
neurofence-web/app/page.tsx - Report loader
neurofence-web/components/DropZone.tsx - Heatmap decoder
neurofence-web/lib/decode.ts - Score summaries
neurofence-web/components/ScoreHero.tsx - Neuron findings
neurofence-web/components/AnomalyTable.tsx - Integrity findings
neurofence-web/components/IntegrityList.tsx - Layer profile
neurofence-web/components/LayerProfile.tsx - Activation heatmap
neurofence-web/components/Heatmap.tsx - Heatmap scaling
neurofence-web/lib/colormap.ts
Poison simulation
- Backdoor simulator
mock_poison.py
Other components
- Analyst
- Local model files
- Report reader
Connections 26
- Analyst → Desktop console: selects model
- Desktop console → Scan worker: starts scan
- Scan worker → Audit and loader: audits and loads
- Audit and loader → Local model files: reads locally
- Audit and loader → MLP hook capture: instruments model
- Scan worker → Prompt generation: requests prompts
- Scan worker → MLP hook capture: runs prompts
- MLP hook capture → Activation statistics: records activations
- Scan worker → Activation statistics: reads statistics
- Scan worker → Anomaly scoring: scores phases
- Anomaly scoring → Scan worker: returns findings
- Scan worker → Desktop console: sends results
- Desktop console → Exported report: exports JSON
- Analyst → Backdoor simulator: runs simulation
- Backdoor simulator → Local model files: creates poisoned model
- Report reader → Viewer page: opens viewer
- Report reader → Report loader: selects report
- Report loader → Viewer page: returns report
- Exported report → Report loader: loads locally
- Viewer page → Heatmap decoder: decodes heatmap
- Viewer page → Score summaries: renders score
- Viewer page → Neuron findings: renders anomalies
- Viewer page → Integrity findings: renders integrity
- Viewer page → Layer profile: renders layers
- Viewer page → Activation heatmap: renders matrix
- Activation heatmap → Heatmap scaling: scales colors