Expand model card
Browse files
README.md
CHANGED
|
@@ -1,56 +1,199 @@
|
|
| 1 |
---
|
| 2 |
base_model: microsoft/codebert-base
|
| 3 |
library_name: pytorch
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
- security
|
| 6 |
- command-analysis
|
| 7 |
- malware-detection
|
|
|
|
| 8 |
- tf-idf
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
# Genos
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
## Files
|
| 16 |
|
| 17 |
-
| File | Format | Purpose |
|
| 18 |
-
|---|---|---|
|
| 19 |
-
| `gatekeeper.pt` | PyTorch
|
| 20 |
-
| `
|
| 21 |
-
| `family_specialist_tfidf.
|
| 22 |
-
| `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## Usage
|
| 28 |
|
| 29 |
-
Download into the
|
| 30 |
-
application expects these files:
|
| 31 |
|
| 32 |
```bash
|
| 33 |
hf download genos-security/genos --local-dir models
|
| 34 |
hf download microsoft/codebert-base --local-dir models/codebert-base
|
| 35 |
```
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
The `.pt`
|
| 40 |
-
|
| 41 |
-
verify checksums before deploying.
|
| 42 |
|
| 43 |
## Intended use
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
##
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
-
|
| 54 |
-
|
| 55 |
-
- The TF-IDF artifact stores vocabulary built from training commands, so it may
|
| 56 |
-
contain fragments of that data.
|
|
|
|
| 1 |
---
|
| 2 |
base_model: microsoft/codebert-base
|
| 3 |
library_name: pytorch
|
| 4 |
+
pipeline_tag: text-classification
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
tags:
|
| 8 |
- security
|
| 9 |
- command-analysis
|
| 10 |
- malware-detection
|
| 11 |
+
- mitre-attack
|
| 12 |
- tf-idf
|
| 13 |
+
- codebert
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# Genos: command-line threat triage models
|
| 17 |
|
| 18 |
+
Genos classifies a single shell or script command line (Linux, macOS, Windows,
|
| 19 |
+
PowerShell) in two tiers. This repository holds the runtime artifacts used by
|
| 20 |
+
the `genos_api` service.
|
| 21 |
+
|
| 22 |
+
```
|
| 23 |
+
command ─► (Base64/obfuscation decode) ─► Tier 1 gatekeeper ─► Benign / Context_Dependent / Malicious
|
| 24 |
+
│
|
| 25 |
+
└─► Tier 2: family specialist (11 tactic families)
|
| 26 |
+
+ behavior encoder (attack stage + action tags)
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
Benign commands skip Tier 2 by default. Every output is a model estimate, not a
|
| 30 |
+
verdict to act on automatically.
|
| 31 |
|
| 32 |
## Files
|
| 33 |
|
| 34 |
+
| File | Format | Size | Purpose |
|
| 35 |
+
|---|---|---|---|
|
| 36 |
+
| `gatekeeper.pt` | PyTorch checkpoint | 502 MB | Tier 1 three-class gatekeeper |
|
| 37 |
+
| `family_specialist_tfidf.joblib` | joblib (scikit-learn) | 33 MB | Tier 2 default specialist: calibrated multi-label 11-family classifier |
|
| 38 |
+
| `family_specialist_tfidf.json` | JSON | 45 KB | Specialist training config, split audit, metrics, and checkpoint hash |
|
| 39 |
+
| `behavior_encoder.pt` | PyTorch checkpoint | 499 MB | Attack-stage and action-tag encoder |
|
| 40 |
+
| `behavior_encoder.json` | JSON | 1 KB | Behavior label maps and test metrics |
|
| 41 |
+
|
| 42 |
+
The CodeBERT backbone (`microsoft/codebert-base`) is **not** included; download
|
| 43 |
+
it separately (see Usage).
|
| 44 |
+
|
| 45 |
+
## Models
|
| 46 |
+
|
| 47 |
+
### Tier 1: gatekeeper (`gatekeeper.pt`)
|
| 48 |
+
|
| 49 |
+
- **Architecture:** shared CodeBERT encoder with decision-decomposition heads
|
| 50 |
+
(`verdict_logits`, `non_benign_logit`, `malicious_given_non_benign_logit`,
|
| 51 |
+
`ordinal_risk_logit`).
|
| 52 |
+
- **Classes:** `Benign` (0), `Malicious` (1), `Context_Dependent` (2).
|
| 53 |
+
`Context_Dependent` marks commands that cannot be judged benign or malicious
|
| 54 |
+
without environmental context.
|
| 55 |
+
- **Training:** 5 epochs (best epoch 5), max length 256, learning rate 1e-5,
|
| 56 |
+
weight decay 0.01, label smoothing 0.05, effective batch size 256, balanced
|
| 57 |
+
sampling, seed 42, plus a 250-row benign operational patch.
|
| 58 |
+
- **Reported metrics** (from `config/gatekeeper_meta.json` in the source repo):
|
| 59 |
+
|
| 60 |
+
| Split | Accuracy | Macro F1 |
|
| 61 |
+
|---|---:|---:|
|
| 62 |
+
| Validation | 0.963 | 0.955 |
|
| 63 |
+
| Test | 0.948 | 0.932 |
|
| 64 |
+
|
| 65 |
+
Test per class: Benign P 0.968 / R 0.957 / F1 0.962; Malicious P 0.944 / R 0.970 /
|
| 66 |
+
F1 0.957; Context_Dependent P 0.880 / R 0.871 / F1 0.876.
|
| 67 |
+
|
| 68 |
+
> These numbers come from the original split used when this checkpoint was
|
| 69 |
+
> trained. The project's later dataset audit found conflicting and
|
| 70 |
+
> development-exposed rows in earlier splits, so these metrics should be treated
|
| 71 |
+
> as optimistic and not as evidence of production accuracy.
|
| 72 |
+
|
| 73 |
+
### Tier 2: family specialist (`family_specialist_tfidf.joblib`)
|
| 74 |
+
|
| 75 |
+
- **Architecture:** TF-IDF features (character `char_wb` 2-5-grams, 250k features;
|
| 76 |
+
word 1-2-grams with a shell-aware token pattern, 100k features) feeding one
|
| 77 |
+
linear SVM per family, with per-family sigmoid calibration fit on train only
|
| 78 |
+
using template-group-isolated folds.
|
| 79 |
+
- **Output:** multi-label scores over 11 families: Execution, Persistence,
|
| 80 |
+
Privilege Escalation, Defense Evasion, Credential Access, Discovery, Lateral
|
| 81 |
+
Movement, Command-and-Control / Payload Retrieval, Exfiltration, Impact,
|
| 82 |
+
Benign Admin. Decision threshold 0.5. No MITRE technique IDs are predicted.
|
| 83 |
+
- **Data:** 37,846 train / 4,740 validation / 4,740 test commands, split 80/10/10
|
| 84 |
+
by parser residual-template group (seed 42) so normalized commands and
|
| 85 |
+
templates never cross splits. The split audit found zero command overlap
|
| 86 |
+
between splits.
|
| 87 |
+
- **Speed:** about 2.9 ms median (3.1 ms p95) per command on CPU, excluding HTTP
|
| 88 |
+
and the other models.
|
| 89 |
+
|
| 90 |
+
Test-set results (threshold 0.5):
|
| 91 |
+
|
| 92 |
+
| Family | Precision | Recall | F1 | Support |
|
| 93 |
+
|---|---:|---:|---:|---:|
|
| 94 |
+
| Execution | 0.62 | 0.48 | 0.54 | 92 |
|
| 95 |
+
| Persistence | 0.77 | 0.62 | 0.68 | 144 |
|
| 96 |
+
| Privilege Escalation | 0.73 | 0.50 | 0.59 | 147 |
|
| 97 |
+
| Defense Evasion | 0.77 | 0.56 | 0.65 | 280 |
|
| 98 |
+
| Credential Access | 0.82 | 0.53 | 0.64 | 59 |
|
| 99 |
+
| Discovery | 0.74 | 0.58 | 0.65 | 115 |
|
| 100 |
+
| Lateral Movement | 1.00 | 0.14 | 0.25 | 7 |
|
| 101 |
+
| Command-and-Control / Payload Retrieval | 0.81 | 0.54 | 0.65 | 39 |
|
| 102 |
+
| Exfiltration | 1.00 | 0.11 | 0.20 | 9 |
|
| 103 |
+
| Impact | 0.50 | 0.38 | 0.43 | 21 |
|
| 104 |
+
| Benign Admin | 0.98 | 0.99 | 0.99 | 4,027 |
|
| 105 |
|
| 106 |
+
Macro F1 is 0.570 on test (0.604 on validation). The top-1 prediction matches at
|
| 107 |
+
least one true family 93.7% of the time (top-2: 96.0%). The weakest families
|
| 108 |
+
(Lateral Movement, Exfiltration, Impact) have very few test examples, so their
|
| 109 |
+
scores are noisy. Precision is generally higher than recall: the model tends to
|
| 110 |
+
miss attack families rather than invent them, and its most common error is
|
| 111 |
+
predicting `Benign Admin` for a Defense Evasion or Discovery command.
|
| 112 |
+
|
| 113 |
+
### Tier 2: behavior encoder (`behavior_encoder.pt`)
|
| 114 |
+
|
| 115 |
+
- **Architecture:** CodeBERT encoder with a stage classifier and a multi-label
|
| 116 |
+
action head, max length 256.
|
| 117 |
+
- **Stages (13):** C2 / Remote Access, Collection / Staging, Context Required,
|
| 118 |
+
Credential Access, Defense Evasion, Discovery / Recon, Execution, Exfiltration,
|
| 119 |
+
Impact, Lateral Movement, Payload Retrieval, Persistence, Privilege Escalation.
|
| 120 |
+
- **Action tags (9):** archive_data, download_remote_resource,
|
| 121 |
+
execute_inline_code, execute_interpreter, extract_archive, remote_execution,
|
| 122 |
+
use_encoded_payload, use_obfuscation, use_signed_proxy_binary.
|
| 123 |
+
- **Reported test metrics:** stage accuracy 0.565, stage macro F1 0.500, action
|
| 124 |
+
micro F1 0.936.
|
| 125 |
+
|
| 126 |
+
> Action labels are derived from the same parser and rule features used for
|
| 127 |
+
> input, so the high action F1 shows the model reproduces those rules. It is not
|
| 128 |
+
> independent evidence of behavioral understanding. Stage accuracy of 0.565 over
|
| 129 |
+
> 13 classes is modest.
|
| 130 |
|
| 131 |
## Usage
|
| 132 |
|
| 133 |
+
Download the files into the application's `models/` directory:
|
|
|
|
| 134 |
|
| 135 |
```bash
|
| 136 |
hf download genos-security/genos --local-dir models
|
| 137 |
hf download microsoft/codebert-base --local-dir models/codebert-base
|
| 138 |
```
|
| 139 |
|
| 140 |
+
Then point the service at them:
|
| 141 |
+
|
| 142 |
+
```bash
|
| 143 |
+
GENOS_CODEBERT_PATH=models/codebert-base
|
| 144 |
+
GENOS_HF_LOCAL_ONLY=1
|
| 145 |
+
GENOS_SPECIALIST_MODE=family
|
| 146 |
+
GENOS_FAMILY_SPECIALIST_PATH=models/family_specialist_tfidf.joblib
|
| 147 |
+
```
|
| 148 |
|
| 149 |
+
The `.pt` files expect the `genos_api` code, label maps in `config/`, and the
|
| 150 |
+
CodeBERT tokenizer. They are not drop-in `transformers` checkpoints.
|
|
|
|
| 151 |
|
| 152 |
## Intended use
|
| 153 |
|
| 154 |
+
- Triage and prioritization of suspicious command lines in defensive tooling,
|
| 155 |
+
research, and education.
|
| 156 |
+
- Use as one signal alongside other telemetry, with a human in the loop.
|
| 157 |
+
|
| 158 |
+
## Out-of-scope use
|
| 159 |
+
|
| 160 |
+
- Automatically blocking, killing, or attributing activity from a score alone.
|
| 161 |
+
- Judging full scripts, binaries, or multi-command sessions. Inputs are single
|
| 162 |
+
command lines truncated to 256 tokens.
|
| 163 |
+
- Offensive use, such as tuning commands to evade the models.
|
| 164 |
+
- Claims of production accuracy.
|
| 165 |
+
|
| 166 |
+
## Limitations and known issues
|
| 167 |
+
|
| 168 |
+
- **Weak labels.** Training labels come from source-derived tactic families and
|
| 169 |
+
parser rules, not human review. Independent annotation is not complete.
|
| 170 |
+
- **Local evaluation only.** Results are from template-grouped splits of the
|
| 171 |
+
same data distribution. Generalization to new environments, attacker
|
| 172 |
+
tooling, or novel obfuscation has not been measured.
|
| 173 |
+
- **Cross-component overlap.** Some test commands for one component appear in
|
| 174 |
+
another component's training data, so the tiers are not evaluated end to end
|
| 175 |
+
on untouched data.
|
| 176 |
+
- **Uncalibrated gatekeeper.** Scores are estimates, not probabilities, unless a
|
| 177 |
+
validation-fitted calibration artifact is supplied.
|
| 178 |
+
- **Known false positive.** The gatekeeper has scored the benign command `pwd` as
|
| 179 |
+
Malicious (about 52%, uncalibrated), and the behavior model labeled it
|
| 180 |
+
Persistence. Expect other false positives on very short commands.
|
| 181 |
+
- **Low-support families.** Lateral Movement, Exfiltration, and Impact are
|
| 182 |
+
recalled poorly (recall 0.11-0.38).
|
| 183 |
+
- **English, command-line text only.**
|
| 184 |
+
- **Training data traces.** The TF-IDF vocabulary is built from training
|
| 185 |
+
commands and may contain fragments of them.
|
| 186 |
+
|
| 187 |
+
## Security note
|
| 188 |
+
|
| 189 |
+
`.pt` and `.joblib` files are Python pickles. Loading one runs code embedded in
|
| 190 |
+
the file. Only load these artifacts from this repository's verified revisions,
|
| 191 |
+
and check file hashes before deployment. The specialist records its own SHA-256
|
| 192 |
+
in `family_specialist_tfidf.json` (`checkpoint_sha256`).
|
| 193 |
|
| 194 |
+
## Citation and license
|
| 195 |
|
| 196 |
+
No license has been declared for these weights yet. Contact the maintainers
|
| 197 |
+
before redistribution or commercial use. The base model,
|
| 198 |
+
[`microsoft/codebert-base`](https://huggingface.co/microsoft/codebert-base), is
|
| 199 |
+
released under the MIT license.
|
|
|
|
|
|