Skip to main content

Security Anomaly ML

Security Anomaly ML

Security Anomaly ML is an open-source batch network-flow anomaly detection system that converts unlabeled CICFlowMeter-compatible flows into promoted, analyst-facing security incidents.

CI Python 3.13 Apache-2.0 Release v0.1.0

v0.1.0 is a usable research/evaluation release. It is not production-ready. The frozen detector performed well on one future capture day from the same network family, but the remaining alert volume is too high for a normal Tier-1 production queue.

Quick start

Docker is the recommended path. The published image includes the exact verified frozen model, so no separate model download is needed.

docker pull ghcr.io/ibondarenko1/security-anomaly-ml:0.1.0

docker run --rm --network none \
  -v "$PWD:/data" \
  ghcr.io/ibondarenko1/security-anomaly-ml:0.1.0 \
  validate /data/flows.csv

docker run --rm --network none \
  -v "$PWD:/data" \
  ghcr.io/ibondarenko1/security-anomaly-ml:0.1.0 \
  analyze /data/flows.csv \
  --output /data/incidents.jsonl

Windows PowerShell:

docker pull ghcr.io/ibondarenko1/security-anomaly-ml:0.1.0

docker run --rm --network none `
  --mount "type=bind,source=$($PWD.Path),target=/data" `
  ghcr.io/ibondarenko1/security-anomaly-ml:0.1.0 `
  validate /data/flows.csv

docker run --rm --network none `
  --mount "type=bind,source=$($PWD.Path),target=/data" `
  ghcr.io/ibondarenko1/security-anomaly-ml:0.1.0 `
  analyze /data/flows.csv `
  --output /data/incidents.jsonl

The mounted directory must be writable by the container's non-root UID/GID 10001. Normal inference works with networking disabled.

How it works

One input row represents one network flow. The product validates the label-free CSV, builds tie-safe causal context, scores each flow, groups flow alerts into deterministic five-minute incidents, and emits only promoted incidents.

flowchart LR
    A["CICFlowMeter flows"] --> B["Input validation"]
    B --> C["128 causal features"]
    C --> D["context-rf-v2 attack score"]
    D --> E["Flow alert: score >= 0.10"]
    E --> F["Policy B: src IP + dst IP + dst port / 5 min"]
    F --> G["Promotion: max score >= 0.25"]
    G --> H["incident-v1 JSONL"]

The frozen feature contract is:

76 CICFlowMeter flow features
+ 9 static port/protocol behavioral features
+ 43 causal temporal-context features
= 128 model features

Raw IP addresses and timestamps provide temporal and incident context but are not model identity features. Same-timestamp flows are processed as one peer group: all peers are featurized before that timestamp updates state.

Output

The output is newline-delimited incident-v1 JSON. Each object contains a deterministic incident ID, first/last timestamps, endpoints, destination port, protocols, flow count, aggregate attack scores, and frozen version metadata.

{
  "schema_version": "incident-v1",
  "incident_id": "inc_<64-hex-digest>",
  "first_seen": "2026-08-20T13:00:00",
  "last_seen": "2026-08-20T13:00:05",
  "src_ip": "192.0.2.10",
  "dst_ip": "198.51.100.20",
  "dst_port": 445,
  "protocols": [6, 17],
  "flow_count": 3,
  "max_attack_score": 0.432590909091,
  "mean_attack_score": 0.418368686869,
  "promoted": true,
  "product_version": "0.1.0",
  "model_version": "context-rf-v2",
  "feature_contract": "cicflow-v2-128"
}

The synthetic regression fixture at tests/fixtures/product-v01/flows.csv deterministically produces:

  • 12 processed flows;
  • 9 flow alerts;
  • 5 aggregated incidents;
  • 2 promoted incidents.

These numbers test runtime stability; they are not an accuracy benchmark and contain no copied research-dataset rows.

Frozen validation results

The v0.1 pipeline was frozen before evaluation on the February 18 temporal holdout. No thresholds, features, model parameters, aggregation rules, promotion rules, suppression, or whitelisting were changed after opening it.

Metric Locked holdout
Flow recall 98.3686%
Flow precision 67.5499%
Flow FPR 2.1190%
PR-AUC 0.898915
Aggregated incident recall 99.9917%
Promoted incident recall 99.9339%
Promoted incident precision 93.46%
Flow-alert to incident reduction 83.80%
FP-object reduction 96.74%

Verdict: acceptable but operationally noisy. This is one future capture day with overlapping hosts/environment from the same dataset and network family. It is not evidence of generalization across arbitrary networks, and the remaining workload is too high for normal Tier-1 production use.

Input format

Input must be a UTF-8 CICFlowMeter-compatible CSV containing:

  • Src IP, Src Port, Dst IP, Dst Port, Protocol, and Timestamp;
  • all 76 baseline numeric fields defined by cicflow-v2-128;
  • optional Flow ID.

Label, label, and attack_cat are not required and are removed if present. Validation rejects missing or duplicate columns, reserved derived fields, malformed timestamps, invalid ports/protocols, and non-numeric or non-finite model inputs. Source timestamps are timezone-naive; v0.1 does not invent a timezone.

Use validate before analysis when integrating a new exporter:

security-anomaly validate flows.csv

Docker

The immutable release tag is:

ghcr.io/ibondarenko1/security-anomaly-ml:0.1.0

It includes Python 3.13, the installed package, contracts, pinned runtime dependencies, and the verified model. It runs as non-root and requires no network during inference. Build and operational details are in docs/DOCKER.md.

No mutable latest tag is published for v0.1.0.

Python CLI

Download the wheel from the v0.1.0 GitHub Release, then install it into Python 3.13:

python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install security_anomaly_ml-0.1.0-py3-none-any.whl
security-anomaly version

The Python wheel intentionally does not embed the model. Obtain the existing artifact from the model-context-rf-v2 release, or from a source checkout run:

python tools/fetch_frozen_model.py \
  --tag model-context-rf-v2 \
  --destination models/context-rf-v2.joblib

security-anomaly model-info --model models/context-rf-v2.joblib
security-anomaly analyze flows.csv \
  --model models/context-rf-v2.joblib \
  --output incidents.jsonl

The downloader verifies the frozen SHA-256 before success and never silently replaces a different file. Full CLI behavior and exit codes are documented in docs/CLI.md.

Reproducibility and CI

Public CI runs on every pull request and push to main and requires only a clean checkout plus the public frozen-model release. It verifies:

  • unit and frozen-contract tests;
  • pinned runtime dependency vulnerability audit;
  • clean wheel/sdist build and outside-checkout installation;
  • public model download and SHA verification;
  • real-model end-to-end golden regression;
  • non-root offline Docker build and byte-identical golden output;
  • exclusion of datasets and research artifacts from the runtime image.

Goldens are never rewritten automatically. Details are in docs/CI.md.

Model artifact

Field Frozen value
Model version context-rf-v2
Release tag model-context-rf-v2
Filename context-rf-v2.joblib
SHA-256 4730a06506d8c5f2af93679c492e1544b3c2b11acd16fe74120d64d4dbfc5c72
Python 3.13.7
Feature builder causal-temporal-v2
Feature contract cicflow-v2-128
Flow threshold >= 0.10
Incident policy Policy B, gap > 300s
Promotion max_attack_score >= 0.25

Scores are ranking signals, not calibrated real-world probabilities. The model is excluded from Git history and is never reserialized by the product build.

Security and privacy

Security Anomaly ML processes sensitive network-flow metadata locally. Normal inference performs no telemetry, cloud upload, hidden download, or other outbound network call; the Docker path is tested with --network none.

Do not attach real packet captures, raw flow exports, internal IP inventories, or unredacted incidents to public issues.

Limitations

  • Research/evaluation grade; not production-ready and not a SOC replacement.
  • Batch CSV processing only; no streaming, API, dashboard, or persistent state service.
  • CICFlowMeter-compatible input only.
  • Frozen Python 3.13 serialization/runtime compatibility.
  • Input timestamps have source-defined, timezone-naive semantics and one-second granularity.
  • Validation covers one future day from an overlapping network/dataset family, not arbitrary networks.
  • Flow-level weaknesses remain concentrated in Fuzzers and Analysis traffic.
  • The score is not calibrated as a real-world attack probability.
  • Alert workload remains too high for normal Tier-1 production operations.

Research methodology

The production-facing v0.1 pipeline was selected using chronological capture days:

2015-01-22 -> training
2015-02-17 -> validation
2015-02-18 -> locked temporal holdout

Temporal context resets at split and batch boundaries. February 18 was not used for training, feature selection, threshold selection, aggregation selection, or promotion selection. Research scripts remain available for audit, but datasets and generated evaluation artifacts are not redistributed.

The research uses UNSW-NB15 and CIC-UNSW-NB15 under their publishers' terms. Third-party dataset terms are not covered by this repository's Apache-2.0 license.

Development and tests

Python 3.13 is required for the frozen product runtime.

python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python -m pytest -q

Some research-reproduction tests require non-redistributed datasets or generated artifacts and skip explicitly in a clean public checkout. Product CI is fully reproducible from public inputs.

License

Original source code is licensed under the Apache License 2.0. Dataset licenses and terms remain with their original publishers.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

security_anomaly_ml-0.1.0.tar.gz (55.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

security_anomaly_ml-0.1.0-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

Details for the file security_anomaly_ml-0.1.0.tar.gz.

File metadata

  • Download URL: security_anomaly_ml-0.1.0.tar.gz
  • Upload date:
  • Size: 55.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for security_anomaly_ml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dba8df843cb7d6c6858d778b43792bfc0149f1c1cb946d515cd496c6ed836f3c
MD5 4b807c5dc9a5c9dd9e0ae0f728cbf017
BLAKE2b-256 506c4b7d57080dc1b43dc31249ddd29fca33b2cce556b5fd77cb18418834bebe

See more details on using hashes here.

Provenance

The following attestation bundles were made for security_anomaly_ml-0.1.0.tar.gz:

Publisher: publish-pypi.yml on ibondarenko1/security-anomaly-ml

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file security_anomaly_ml-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for security_anomaly_ml-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ed9739fb1958ed8b2092190d91f87dabc3e1c579c8f9e914a1566d6a4c04f51
MD5 e3d294fffcb9ffb0b83d48aaef4c91c8
BLAKE2b-256 fab9a7f92cd1f70a191cb12f73c060734630ac4cc7dc0a255c5d3e2f2eb03b6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for security_anomaly_ml-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on ibondarenko1/security-anomaly-ml

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page