Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
- security
|
| 5 |
- ai-agents
|
|
@@ -7,70 +9,234 @@ tags:
|
|
| 7 |
- nanomind
|
| 8 |
- opena2a
|
| 9 |
- threat-detection
|
|
|
|
|
|
|
| 10 |
datasets:
|
| 11 |
- opena2a/nanomind-training
|
| 12 |
metrics:
|
| 13 |
- accuracy
|
| 14 |
- f1
|
|
|
|
|
|
|
| 15 |
model-index:
|
| 16 |
- name: nanomind-security-classifier
|
| 17 |
results:
|
| 18 |
- task:
|
| 19 |
type: text-classification
|
| 20 |
name: AI Agent Threat Classification
|
|
|
|
|
|
|
|
|
|
| 21 |
metrics:
|
| 22 |
- name: Eval Accuracy
|
| 23 |
type: accuracy
|
| 24 |
-
value: 0.
|
|
|
|
|
|
|
|
|
|
| 25 |
---
|
| 26 |
|
| 27 |
-
#
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
Part of the [OpenA2A](https://
|
| 32 |
-
Used by [HackMyAgent](https://github.com/opena2a-org/hackmyagent) for AI agent security scanning.
|
| 33 |
|
| 34 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
| Metric | Value |
|
| 37 |
|--------|-------|
|
| 38 |
-
| Eval accuracy |
|
| 39 |
-
|
|
| 40 |
-
|
|
| 41 |
-
|
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
## Architecture
|
| 45 |
|
| 46 |
-
|
| 47 |
-
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
-
##
|
| 55 |
|
| 56 |
```bash
|
| 57 |
-
# Install HackMyAgent (includes NanoMind inference)
|
| 58 |
npm install -g hackmyagent
|
| 59 |
|
| 60 |
-
# Scan an
|
| 61 |
hackmyagent scan ./my-agent --deep
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
npx opena2a scan ./my-agent
|
| 65 |
```
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
## Training
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
## License
|
| 76 |
|
|
@@ -83,7 +249,15 @@ Apache-2.0. Free for commercial and non-commercial use.
|
|
| 83 |
title = {NanoMind Security Classifier},
|
| 84 |
author = {OpenA2A},
|
| 85 |
url = {https://github.com/opena2a-org/nanomind},
|
| 86 |
-
version = {0.
|
| 87 |
year = {2026}
|
| 88 |
}
|
| 89 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
tags:
|
| 6 |
- security
|
| 7 |
- ai-agents
|
|
|
|
| 9 |
- nanomind
|
| 10 |
- opena2a
|
| 11 |
- threat-detection
|
| 12 |
+
- onnx
|
| 13 |
+
- text-classification
|
| 14 |
datasets:
|
| 15 |
- opena2a/nanomind-training
|
| 16 |
metrics:
|
| 17 |
- accuracy
|
| 18 |
- f1
|
| 19 |
+
pipeline_tag: text-classification
|
| 20 |
+
library_name: onnxruntime
|
| 21 |
model-index:
|
| 22 |
- name: nanomind-security-classifier
|
| 23 |
results:
|
| 24 |
- task:
|
| 25 |
type: text-classification
|
| 26 |
name: AI Agent Threat Classification
|
| 27 |
+
dataset:
|
| 28 |
+
type: opena2a/nanomind-training
|
| 29 |
+
name: NanoMind Security Corpus sft-v10
|
| 30 |
metrics:
|
| 31 |
- name: Eval Accuracy
|
| 32 |
type: accuracy
|
| 33 |
+
value: 0.9845
|
| 34 |
+
- name: Macro F1
|
| 35 |
+
type: f1
|
| 36 |
+
value: 0.9778
|
| 37 |
---
|
| 38 |
|
| 39 |
+
# NanoMind Security Classifier v0.5.0
|
| 40 |
|
| 41 |
+
A fast, lightweight threat classifier purpose-built for AI agent security scanning. Classifies SKILL.md files, MCP server configurations, SOUL.md governance docs, and agent tool descriptions into 10 security categories in under 1ms.
|
| 42 |
|
| 43 |
+
Part of the [OpenA2A](https://github.com/opena2a-org) security ecosystem.
|
|
|
|
| 44 |
|
| 45 |
+
## What This Model Does
|
| 46 |
+
|
| 47 |
+
NanoMind analyzes the text content of AI agent configurations and detects security threats:
|
| 48 |
+
|
| 49 |
+
```
|
| 50 |
+
Input: MCP server config with hidden data forwarding endpoint
|
| 51 |
+
Output: exfiltration (confidence: 0.97)
|
| 52 |
+
|
| 53 |
+
Input: Normal SOUL.md governance policy
|
| 54 |
+
Output: benign (confidence: 0.99)
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
It runs at the scanning layer of [HackMyAgent](https://github.com/opena2a-org/hackmyagent) and [OpenA2A CLI](https://github.com/opena2a-org/opena2a), classifying every piece of agent content before it reaches production.
|
| 58 |
+
|
| 59 |
+
## Key Metrics
|
| 60 |
|
| 61 |
| Metric | Value |
|
| 62 |
|--------|-------|
|
| 63 |
+
| **Eval accuracy** | **98.45%** |
|
| 64 |
+
| **Macro F1** | **0.9778** |
|
| 65 |
+
| **False positives** | **0** on 33 benign Unicode inputs |
|
| 66 |
+
| **Inference latency** | **< 1ms** (p99 on CPU) |
|
| 67 |
+
| **Model size** | **8.3 MB** (ONNX + weights + tokenizer) |
|
| 68 |
+
| Training samples | 3168 |
|
| 69 |
+
| Eval samples | 194 |
|
| 70 |
+
| Training corpus | sft-v10 |
|
| 71 |
+
|
| 72 |
+
## Threat Taxonomy (10 classes)
|
| 73 |
+
|
| 74 |
+
| Class | Description |
|
| 75 |
+
|-------|-------------|
|
| 76 |
+
| `exfiltration` | Data forwarding to unauthorized external endpoints |
|
| 77 |
+
| `injection` | Instruction override, jailbreak, prompt injection |
|
| 78 |
+
| `privilege_escalation` | Unauthorized access elevation |
|
| 79 |
+
| `persistence` | Permanent unauthorized state manipulation |
|
| 80 |
+
| `credential_abuse` | Credential harvesting, phishing, token theft |
|
| 81 |
+
| `lateral_movement` | Remote config/instruction fetching, C2 patterns |
|
| 82 |
+
| `social_engineering` | Urgency, authority, or pressure manipulation |
|
| 83 |
+
| `policy_violation` | Governance bypass, boundary violations |
|
| 84 |
+
| `steganography` | Unicode-based attacks (zero-width chars, homoglyphs, bidi overrides) |
|
| 85 |
+
| `benign` | Normal, safe agent behavior |
|
| 86 |
|
| 87 |
## Architecture
|
| 88 |
|
| 89 |
+
| Parameter | Value |
|
| 90 |
+
|-----------|-------|
|
| 91 |
+
| Type | Mamba SSM (Selective State Space Model) |
|
| 92 |
+
| Architecture | TME (Ternary Mamba Encoder) |
|
| 93 |
+
| Blocks | 8 MambaBlocks with gated projection |
|
| 94 |
+
| Dimensions | d_model=128, d_inner=256, d_state=64 |
|
| 95 |
+
| Vocabulary | 6,000 tokens (word-level) |
|
| 96 |
+
| Parameters | 2,089,482 |
|
| 97 |
+
| Inference | ONNX Runtime (cross-platform) or MLX (Apple Silicon) |
|
| 98 |
|
| 99 |
+
The model processes text through: Embedding -> 8x MambaBlock (in_proj -> SiLU gate -> dt_proj -> out_proj + LayerNorm residual) -> Mean pooling -> LayerNorm -> Linear classifier -> Softmax.
|
| 100 |
|
| 101 |
+
## Quick Start
|
| 102 |
|
| 103 |
+
### Via HackMyAgent (recommended)
|
| 104 |
|
| 105 |
```bash
|
|
|
|
| 106 |
npm install -g hackmyagent
|
| 107 |
|
| 108 |
+
# Scan an AI agent project for threats
|
| 109 |
hackmyagent scan ./my-agent --deep
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
### Via OpenA2A CLI
|
| 113 |
|
| 114 |
+
```bash
|
| 115 |
npx opena2a scan ./my-agent
|
| 116 |
```
|
| 117 |
|
| 118 |
+
### Direct ONNX Inference (Python)
|
| 119 |
+
|
| 120 |
+
```python
|
| 121 |
+
import json
|
| 122 |
+
import numpy as np
|
| 123 |
+
import onnxruntime as ort
|
| 124 |
+
|
| 125 |
+
# Load model
|
| 126 |
+
session = ort.InferenceSession("nanomind-tme.onnx")
|
| 127 |
+
vocab = json.load(open("tokenizer.json"))
|
| 128 |
+
|
| 129 |
+
# Tokenize
|
| 130 |
+
text = "your agent config text here"
|
| 131 |
+
tokens = text.lower().split()
|
| 132 |
+
ids = [vocab.get(t, 1) for t in tokens[:128]]
|
| 133 |
+
ids += [0] * (128 - len(ids)) # pad
|
| 134 |
+
input_ids = np.array([ids], dtype=np.int64)
|
| 135 |
+
|
| 136 |
+
# Predict
|
| 137 |
+
logits = session.run(None, {"input_ids": input_ids})[0][0]
|
| 138 |
+
classes = ["exfiltration", "injection", "privilege_escalation", "persistence",
|
| 139 |
+
"credential_abuse", "lateral_movement", "social_engineering",
|
| 140 |
+
"policy_violation", "benign", "steganography"]
|
| 141 |
+
pred = classes[np.argmax(logits)]
|
| 142 |
+
conf = np.exp(logits) / np.exp(logits).sum()
|
| 143 |
+
print(f"{pred} (confidence: {conf[np.argmax(logits)]:.3f})")
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
### Direct ONNX Inference (Node.js)
|
| 147 |
+
|
| 148 |
+
```javascript
|
| 149 |
+
const ort = require("onnxruntime-node");
|
| 150 |
+
const vocab = require("./tokenizer.json");
|
| 151 |
+
|
| 152 |
+
async function classify(text) {
|
| 153 |
+
const session = await ort.InferenceSession.create("nanomind-tme.onnx");
|
| 154 |
+
const tokens = text.toLowerCase().split(" ");
|
| 155 |
+
const ids = tokens.slice(0, 128).map(t => vocab[t] || 1);
|
| 156 |
+
while (ids.length < 128) ids.push(0);
|
| 157 |
+
|
| 158 |
+
const input = new ort.Tensor("int64", BigInt64Array.from(ids.map(BigInt)), [1, 128]);
|
| 159 |
+
const result = await session.run({ input_ids: input });
|
| 160 |
+
const logits = Array.from(result.logits.data);
|
| 161 |
+
|
| 162 |
+
const classes = ["exfiltration", "injection", "privilege_escalation", "persistence",
|
| 163 |
+
"credential_abuse", "lateral_movement", "social_engineering",
|
| 164 |
+
"policy_violation", "benign", "steganography"];
|
| 165 |
+
const maxIdx = logits.indexOf(Math.max(...logits));
|
| 166 |
+
return { class: classes[maxIdx], logits };
|
| 167 |
+
}
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
## Training
|
| 171 |
|
| 172 |
+
### Data Sources
|
| 173 |
+
|
| 174 |
+
| Source | Samples | Description |
|
| 175 |
+
|--------|---------|-------------|
|
| 176 |
+
| [OASB](https://oasb.org) | ~400 | Open Agent Security Benchmark attack/benign corpus |
|
| 177 |
+
| [DVAA](https://github.com/opena2a-org/damn-vulnerable-ai-agent) | ~200 | Deliberately vulnerable agent scenarios |
|
| 178 |
+
| [AgentPwn](https://agentpwn.com) | ~100 | Real honeypot-captured attack payloads |
|
| 179 |
+
| Synthetic | ~1,500 | Generated SKILL.md, MCP config, SOUL.md samples |
|
| 180 |
+
| Stego corpus | ~550 | Zero-width, homoglyph, bidi, tag character attacks |
|
| 181 |
+
| FP-reduction | 106 | Targeted benign samples for false positive elimination |
|
| 182 |
+
|
| 183 |
+
### Training Process
|
| 184 |
+
|
| 185 |
+
- **Hardware:** Apple M4 Max, 32 GB, MLX GPU acceleration
|
| 186 |
+
- **Framework:** [MLX](https://github.com/ml-explore/mlx) (Apple Silicon native)
|
| 187 |
+
- **Strategy:** Fine-tuned from v0.4.0 weights with lower learning rate (0.0005)
|
| 188 |
+
- **Schedule:** Cosine decay with linear warmup (5 epochs)
|
| 189 |
+
- **Regularization:** Dropout 0.1, early stopping (patience=60)
|
| 190 |
+
|
| 191 |
+
### Corpus Evolution
|
| 192 |
+
|
| 193 |
+
| Version | Samples | Classes | Key Change |
|
| 194 |
+
|---------|---------|---------|------------|
|
| 195 |
+
| sft-v4 | 1,028 | 9 | Initial release |
|
| 196 |
+
| sft-v5 | ~1,100 | 9 | Added OASB data |
|
| 197 |
+
| sft-v8 | 4,500 | 9 | Multi-source, balanced |
|
| 198 |
+
| sft-v9 | 3,566 | 10 | Added steganography class |
|
| 199 |
+
| **sft-v10** | **3,566** | **10** | **FP-reduction: +106 targeted benign** |
|
| 200 |
+
|
| 201 |
+
## Changelog
|
| 202 |
+
|
| 203 |
+
### v0.5.0 (2026-04-09)
|
| 204 |
+
FP reduction: 7 false positives eliminated via targeted benign training data (base64, emoji, Cyrillic, Arabic, governance, error messages, security tools). Fine-tuned from v0.4.0.
|
| 205 |
+
|
| 206 |
+
### v0.4.0 (2026-04-07)
|
| 207 |
+
Added steganography as 10th attack class. Trained on sft-v9 corpus with 370+ steganographic attack samples and 370+ benign Unicode samples.
|
| 208 |
+
|
| 209 |
+
### v0.3.0 (2026-04-01)
|
| 210 |
+
Added ONNX export with external data format for efficient deployment.
|
| 211 |
+
|
| 212 |
+
### v0.2.0 (2026-03-20)
|
| 213 |
+
Upgraded from MLP to Mamba TME architecture. 97.01% accuracy.
|
| 214 |
+
|
| 215 |
+
## File Manifest
|
| 216 |
+
|
| 217 |
+
| File | Size | Description |
|
| 218 |
+
|------|------|-------------|
|
| 219 |
+
| `nanomind-tme.onnx` | 140 KB | ONNX model graph |
|
| 220 |
+
| `nanomind-tme.onnx.data` | 8.0 MB | External weight data |
|
| 221 |
+
| `tokenizer.json` | 165 KB | Word-level vocabulary (6,000 tokens) |
|
| 222 |
+
| `nanomind-tme-classifier.npz` | 8.0 MB | Best checkpoint (MLX/NumPy weights) |
|
| 223 |
+
|
| 224 |
+
## Limitations
|
| 225 |
+
|
| 226 |
+
- **Small eval set:** 194 samples. Per-class metrics may be noisy for classes with < 15 support.
|
| 227 |
+
- **Word-level tokenizer:** Cannot detect character-level steganographic attacks (e.g., single Cyrillic homoglyphs embedded in Latin words). Relies on contextual patterns instead.
|
| 228 |
+
- **Base64 sensitivity:** Long base64 strings can look like encoded/hidden content. v0.5.0 added targeted training but novel base64 patterns may still trigger false positives.
|
| 229 |
+
- **English-centric vocabulary:** Vocabulary is trained primarily on English text. Non-English package descriptions rely on Unicode pattern recognition rather than semantic understanding.
|
| 230 |
+
- **No adversarial robustness testing:** Not tested against adversarial examples designed to evade detection.
|
| 231 |
+
|
| 232 |
+
## Responsible Use
|
| 233 |
+
|
| 234 |
+
This model is designed to **assist** security review, not replace it. All findings should be verified by a human before taking action. The model may produce false positives on legitimate content that uses security-related terminology in defensive contexts.
|
| 235 |
+
|
| 236 |
+
Do not use this model to:
|
| 237 |
+
- Block packages or agents without human review
|
| 238 |
+
- Make automated access control decisions
|
| 239 |
+
- Replace security audits or penetration testing
|
| 240 |
|
| 241 |
## License
|
| 242 |
|
|
|
|
| 249 |
title = {NanoMind Security Classifier},
|
| 250 |
author = {OpenA2A},
|
| 251 |
url = {https://github.com/opena2a-org/nanomind},
|
| 252 |
+
version = {0.5.0},
|
| 253 |
year = {2026}
|
| 254 |
}
|
| 255 |
```
|
| 256 |
+
|
| 257 |
+
## Links
|
| 258 |
+
|
| 259 |
+
- [NanoMind GitHub](https://github.com/opena2a-org/nanomind) -- Model code, specifications, documentation
|
| 260 |
+
- [HackMyAgent](https://github.com/opena2a-org/hackmyagent) -- Primary consumer (AI agent security scanner)
|
| 261 |
+
- [OpenA2A](https://github.com/opena2a-org/opena2a) -- CLI toolkit for AI agent security
|
| 262 |
+
- [OASB](https://oasb.org) -- Open Agent Security Benchmark
|
| 263 |
+
- [DVAA](https://github.com/opena2a-org/damn-vulnerable-ai-agent) -- Training data source (vulnerable agent scenarios)
|