Skip to main content

BAD: Behavior Anomaly Detection

Ask DeepWiki

Cross-platform user behavior analytics for Linux, Windows and macOS.

Collect telemetry, normalize it, train on what users normally do, and hand your SIEM a vendor-neutral alert when they stop doing that. A tool for agents, SIEMs and monitoring stacks, not an agent itself.

The import package is behavior_anomaly, so nobody ever has to type from bad import Alert with a straight face. The CLI and the executables are bad. The pip distribution is behavior-anomaly-detection, because someone parked a dead Android driver on the name bad in 2018 and PyPI keeps names forever, like a dragon with worse taste in treasure.

The pipeline

Linux / Windows / macOS
          |
          v
     OS collectors  or  normalized JSONL from your agent
          |
          v
    BehaviorEvent  (the one schema that rules them all)
          |
          v
   feature extraction  (per user, per host, per time window)
          |
          v
     trained model  (Isolation Forest baseline)
          |
          v
     anomaly score
          |
          v
   detection policy  (thresholds, severities, evidence)
          |
          v
        Alert  (vendor-neutral, typed, boring on purpose)
          |
          v
   SIEM sink  (webhook or syslog, ECS mapping included)

The package separates collection, normalization, feature extraction, modeling, detection, storage and SIEM transport so each layer can evolve independently, and so a bug in one layer cannot moonlight as a bug in another.

Principles

  • Vendor-neutral findings. No Splunk-isms, no Sentinel-isms. Alerts are a typed JSON shape any SIEM, XDR or agent can consume. An ECS mapping ships with the package for the Elastic-inclined.
  • Tool, not agent (but it can loop). The CLI commands are one-shot verbs you wire into your own scheduler. The optional daemon command loops collect, train and monitor on a timer, all enabled by default and configurable via the [daemon] section of the TOML config. Feed it events, get verdicts, on your schedule or its own.
  • Conservative collectors. Entries we cannot identify get skipped, not guessed. A tool that hallucinates telemetry is worse than no tool.
  • Privacy by construction. Input dynamics (typing cadence, mouse motion) are aggregates only, reported by an agent over the JSONL front door. BAD never records keystrokes and never reads content. There is no option to turn it on, on any platform, ever.
  • One TOML config. config.example.toml documents every toggle: detection knobs, SIEM sink, input dynamics on/off. Flags beat the file, the file beats the defaults.

The signal nobody else listens for

Process and auth telemetry tells you what a user did. Typing cadence and mouse motion tell you who was at the keyboard. A hijacked session almost always types and mouses differently from the legitimate owner, no matter how careful the attacker is about which commands they run. Pure process telemetry is deaf to that signal. BAD is not.

BAD derives behavioral biometrics from typing cadence (keystroke counts, mean and stddev of inter-key intervals, typing velocity) and mouse movement patterns (distance, speed, direction changes). These are aggregates only, reported by an agent over the JSONL front door. BAD never records keystrokes, never reads content, and there is no option to turn that on, on any platform, ever. The timing of typing is a signature. The content of typing is a lawsuit.

This is the part that makes BAD more than a process-log counter with a threshold: the model can flag a session where the commands look normal but the human behind them does not. That is the difference between "something happened" and "someone else happened".

Quick start

python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'

bad --help
pytest

A full worked session: collect (or hand over your agent's normalized JSONL), train, score, monitor:

bad collect --platform jsonl --source agent-events.jsonl --output events.jsonl
bad train --input events.jsonl --output model.joblib
bad score --input events.jsonl --model model.joblib
bad monitor --input events.jsonl --model model.joblib --siem webhook --endpoint https://siem.example.test/hook

# Or run the continuous monitoring daemon (collects, scores, retrains, loops):
bad daemon --config /etc/bad/config.toml
bad daemon --once    # single cycle, for cron or smoke tests

Documentation

The full documentation lives in the docs directory and is published to GitHub Pages and ReadTheDocs via mkdocs:

pip install -e '.[docs]'
mkdocs serve    # live preview at http://localhost:8000

Deploying to a fleet? Deployment covers prerequisites per platform, and the deploy/ directory ships the templates: a PowerShell installer plus Intune packaging for Windows, an ansible role and a plain install.sh for Linux, and a pkg recipe plus install.sh for macOS MDMs. BAD can run as a daemon (bad daemon) or as one-shot commands wired into your own scheduler; your platform's scheduler runs it on the cadence you chose, which is the "tool, not agent" contract with the boring parts already written for you. The daemon ships with systemd and cron examples.

Releases

Releases are automated by conventional commits:

  • feat: ... bumps the minor version, fix: ... bumps the patch, BREAKING CHANGE bumps the major. Chores do nothing, which is the nicest thing anyone has ever said about chores.
  • The changelog (CHANGELOG.md) regenerates itself on release.
  • Standalone executables (Linux binary, Windows exe, macOS dmg) build on every release and attach to the GitHub release. A tool nobody can run is a hobby.

Model

The baseline is an Isolation Forest trained over per-user, per-host time windows. The model interface is intentionally replaceable, so per-user baselines, temporal models, clustering or supervised classifiers can move in without touching anything outside their own module.

License

MIT, see LICENSE. If you need a lawyer to read it first, that is a you problem, and also correct.

Metadata

Release files for behavior-anomaly-detection 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for behavior-anomaly-detection 2.0.1
File Size Uploaded Provenance Actions
behavior_anomaly_detection-2.0.1.tar.gz 122.3 kB With provenance Details for behavior_anomaly_detection-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for behavior-anomaly-detection 2.0.1
File Interpreter ABI Platform Actions
behavior_anomaly_detection-2.0.1-py3-none-any.whl Python 3 none any Details for behavior_anomaly_detection-2.0.1-py3-none-any.whl

Total release size: 182.0 kB

Release files / behavior_anomaly_detection-2.0.1.tar.gz

Download URL behavior_anomaly_detection-2.0.1.tar.gz
Size 122.3 kB
Tags Source
SHA-256 checksum
How to use checksums
44c158e0c5765266df674f14463756ce02742114c78ddc07bcb1a1c54f0cc2be
BLAKE2b-256 checksum
How to use checksums
a5d559a5dc4c73631d3070e51b280c071b2e3b45c69bf67414cc3d00a9abc287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release files / behavior_anomaly_detection-2.0.1-py3-none-any.whl

Download URL behavior_anomaly_detection-2.0.1-py3-none-any.whl
Size 59.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a26788dd100f61fa7e115659a8dad5cf7e5c2f6e7a536236d8b7c1ad971c3aea
BLAKE2b-256 checksum
How to use checksums
82c8d4cd7aff49ce1bf8798b764036fc14e9f3f050987592c3f25d7f6c0f2956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Security for behavior-anomaly-detection 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for behavior_anomaly_detection-2.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files Full provenance

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