Skip to content

Incident Response Playbook — BatleHub ​

This playbook covers security and availability incidents for BatleHub deployments. Follow the phases in order.

Guidance, not a commitment

A template for the playbook you write, not a service the project runs. The severity levels, response times and notification recipients below are examples — replace them with your organisation's, because the only people who can meet them are yours. Nobody is paged by this page.


Severity Levels ​

LevelDefinitionResponse SLA
P0 — CriticalData breach, token compromise, registry unavailable >15 minRespond immediately (24/7)
P1 — HighUnauthorized access to admin endpoints, persistent DoSWithin 2 hours
P2 — MediumAnomalous access patterns, failed-but-caught attackWithin 8 hours
P3 — LowPolicy misconfiguration, expired token alertsNext business day

Phase 1 — Detection ​

Automated signals ​

SourceAlertWhere to check
PrometheusBatleHubDown, BatleHubHighErrorRate, BatleHubHighDeniedRequestRatedeploy/prometheus-alerts.yaml
Audit logSpike in denied outcomes, unknown user IDs in user_id columnGET /api/v1/admin/audit-log
Rate limiterSustained 429 responses from one IPAudit log filter by IP
Container scanTrivy HIGH/CRITICAL finding in deployed image.github/workflows/image-scan.yaml
GitleaksSecret exposed in commit.github/workflows/secret-scan.yaml

Manual detection ​

Query the audit log for anomalies:

bash
# All denied events in the last hour
batlehub-cli audit log --denied-only --from "$(date -u -d '1 hour ago' +%FT%TZ)"

# Access events from a specific IP
batlehub-cli audit log | jq '[.[] | select(.ip_address == "1.2.3.4")]'

# What disappeared, and whether a person or a policy took it
batlehub-cli audit log --action delete,retention_reclaim --from <start>

# Export a full 24-hour window for offline analysis
batlehub-cli audit export --from <start> --to <end> --format csv --output incident-$(date +%Y%m%d).csv

Phase 2 — Containment ​

Act within the first 15 minutes for P0/P1. Do not wait for root-cause analysis before containing.

Block a suspicious IP ​

bash
batlehub-cli ip-block add 1.2.3.4

Or via the Admin UI → IP Blocks → Add.

Revoke a compromised token ​

A token is revoked by the user who owns it:

bash
batlehub-cli auth token delete <token-id>

An administrator cannot revoke another user's token. Block the account instead (below): every request from it is refused, whatever token it carries.

Block a user account ​

bash
batlehub-cli user block <user-id>

Blocks all future requests from that user ID until unblocked.

Quarantine a malicious package ​

bash
# Refuse these versions to every client, with the reason recorded
batlehub-cli package block <registry>/<name>@<version>... --reason "<why>"

# Or only hide a version from listings; a pinned install still gets it
batlehub-cli package unlist <registry>/<name>@<version>

A block names versions, not a whole package: list them with batlehub-cli package versions <registry>/<name>. See Block a package version for what a block changes in each client's listing.

Flag a version from your SOC tooling ​

A [[flag_sources]] entry (configuration §3.11) lets the SOC platform push the verdict itself, signed, without a console login — and the push is the record the exposure report reads. The signature covers "{timestamp}.{body}", with the timestamp sent as X-BatleHub-Timestamp (unix seconds); one more than 300 s from the server's clock is refused, so a captured push or revoke cannot be replayed later.

bash
BODY='{"flags":[{"external_id":"CASE-2026-0912","registry":"npm","package_name":"left-pad",
  "version":"1.3.1","kind":"malware","effect":"hard_block","summary":"credential stealer in postinstall"}]}'
TS="$(date +%s)"
SIG="sha256=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$FLAG_SECRET" | sed 's/^.* //')"
curl -sS -X POST "$BATLEHUB/api/v1/flags/soc" \
  -H "Content-Type: application/json" -H "X-BatleHub-Timestamp: $TS" \
  -H "X-Hub-Signature-256: $SIG" --data "$BODY"

version_range = "*" flags every version of the package. On a registry with a [registries.security] profile the version is denied at once; elsewhere FlagsRule refuses it on the next request. Lift it with DELETE /api/v1/flags/soc/CASE-2026-0912 (signed over "{timestamp}." followed by DELETE\n/api/v1/flags/{source}/{external_id}, so the signature is bound to the flag it lifts): the row stays as a tombstone so the report below still answers.

Who pulled a flagged version ​

The exposure report joins the access log to the flags, one row per consumer, coordinate and flag, and says how many of the pulls preceded the flag — the retroactive case, where the developer did nothing wrong and still has the artifact.

bash
batlehub-cli exposure list --source soc --min-effect gate --when before-flag
batlehub-cli exposure list --registry npm --package left-pad --from 2026-09-01T00:00:00Z
batlehub-cli flag list --include-dead          # what every source has said, tombstones too

GET /api/v1/admin/exposure/export?format=csv is the same rows as a file for the ticket. Read the coverage block before quoting the numbers: it says how many registries have an SBOM extractor (so the CVE scan reaches them), when that scan last ran per registry, and which sources have pushed — a report that has never scanned knows only what was pushed.

Isolate a replica ​

If one replica is compromised, remove it from the load balancer before forensics. BatleHub state lives in Postgres and S3 — the replica itself is stateless.


Phase 3 — Eradication ​

  1. Rotate credentials — generate new API tokens for all service accounts; update downstream consumers.
  2. Patch the vulnerability — if a CVE triggered the incident, apply the patch, run cargo audit locally, and rebuild the image.
  3. Re-run SBOM scan — task security to confirm the patched dependency tree is clean.
  4. Review RBAC rules — use the RBAC simulator (POST /api/v1/admin/access-check) to validate that the affected policy gap is closed.

Phase 4 — Recovery ​

  1. Deploy patched image — run cargo build --release or trigger CI; push patched container.
  2. Verify health — GET /healthz returns 200 on all replicas. It is auth-exempt, which is what makes it usable from a probe or a script with no credential; GET /api/v1/admin/health is the detailed per-registry view and needs an admin token.
  3. Unblock legitimate traffic — remove IP blocks and unblock users that were collateral.
  4. Monitor — watch Prometheus for 30 minutes after restoration; confirm error rate returns to baseline.

Phase 5 — Post-Mortem ​

Within 5 business days of a P0/P1 incident:

  1. Write a timeline (detection → containment → eradication → recovery).
  2. Identify root cause and contributing factors.
  3. List corrective actions with owners and due dates.
  4. Update this playbook if any step was missing or unclear.
  5. Archive the exported audit log for the incident period (export-audit-log --format csv).

Post-mortem template: none yet. Write the first one against the five points above and keep it under operations/ so the next incident starts from a form rather than from a blank page.


NIS2 reporting timeline ​

An essential or important entity under NIS2 (Art. 23) owes its CSIRT or competent authority three reports about a significant incident. The reports are yours; BatleHub holds the evidence they are written from.

DeadlineWhat NIS2 asksWhere the evidence lives
24 h after becoming aware — early warningWhether the incident is suspected to be malicious or to have a cross-border impactThe audit stream in your SIEM and the Sigma rule that fired (SIEM integration)
72 h — incident notificationAn initial assessment: severity, impact, indicators of compromiseThe audit log for the window: batlehub-cli audit export --from <start> --to <end> --format json
One month — final reportRoot cause, mitigation applied, cross-border impactThe post-mortem of Phase 5, the exported log, and a verified chain for the window

Before you quote the exported log, show it was not altered:

bash
# <digest> is the newest audit_seal line your SIEM holds
batlehub-cli audit verify --from <start> --to <end> --head <digest>

It exits 0 when every sealed window verifies and 1 naming the first that does not. Without --head it says that truncation was not checked — a chain whose tail was deleted together with its seal records still verifies, and only the copy outside the database can show it. The stream copy is that copy; deploy/siem/sigma/audit_chain_gap.yml fires when two consecutive audit_seal lines do not chain.

What else NIS2 and DORA ask, and what is not built yet, is in NIS2 and DORA.


PII Handling ​

Audit rows carry user ids, IP addresses and user agents; token rows and block rows carry user ids. Retention and pseudonymisation of the trail run on their own once [audit] is configured (GDPR mapping). A request from one data subject is answered with two commands.

Access request (GDPR Art. 15):

bash
batlehub-cli gdpr export --user <id>

It lists every row about the subject, including the publication and ownership rows an erasure keeps, and is recorded as a gdpr_export audit event. It needs the audit:read verb (GET /api/v1/admin/gdpr/export?user_id=<id>).

Erasure request (GDPR Art. 17):

bash
batlehub-cli gdpr erase --user <id>

It replaces the id with erased:<hmac> in access_events, token rows and block rows, so the subject's rows stay linkable to each other and to nobody. It needs the gdpr:erase verb — audit:purge does not imply it — and [audit] erasure_key set, an HMAC secret you keep outside the database. The erasure is itself a gdpr_erase security event naming who ran it.

  • Publication and ownership rows are kept, under legitimate interest: who published a version stays answerable for every consumer of it. Tell the subject so; the export lists them.
  • A subject with an open quarantine or block decision is refused, because erasing them would erase the evidence of a live case. Close the case first, or pass --force and record why.
  • A copy already in your SIEM is not touched. Erase it there by your collector's own means, or let its retention expire it.

Never edit access_events with SQL: a hand-written UPDATE breaks the seal chain, and audit verify will report the window as altered.


Contacts ​

Populate these before deploying to production:

RoleContact
On-call engineer—
Security lead—
Legal / DPO—
Upstream registry contacts (GitHub, npm, PyPI)—

Released under the Apache 2.0 License. Made with care and too much coffee.