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
| Level | Definition | Response SLA |
|---|---|---|
| P0 — Critical | Data breach, token compromise, registry unavailable >15 min | Respond immediately (24/7) |
| P1 — High | Unauthorized access to admin endpoints, persistent DoS | Within 2 hours |
| P2 — Medium | Anomalous access patterns, failed-but-caught attack | Within 8 hours |
| P3 — Low | Policy misconfiguration, expired token alerts | Next business day |
Phase 1 — Detection
Automated signals
| Source | Alert | Where to check |
|---|---|---|
| Prometheus | BatleHubDown, BatleHubHighErrorRate, BatleHubHighDeniedRequestRate | deploy/prometheus-alerts.yaml |
| Audit log | Spike in denied outcomes, unknown user IDs in user_id column | GET /api/v1/admin/audit-log |
| Rate limiter | Sustained 429 responses from one IP | Audit log filter by IP |
| Container scan | Trivy HIGH/CRITICAL finding in deployed image | .github/workflows/image-scan.yaml |
| Gitleaks | Secret exposed in commit | .github/workflows/secret-scan.yaml |
Manual detection
Query the audit log for anomalies:
# 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).csvPhase 2 — Containment
Act within the first 15 minutes for P0/P1. Do not wait for root-cause analysis before containing.
Block a suspicious IP
batlehub-cli ip-block add 1.2.3.4Or via the Admin UI → IP Blocks → Add.
Revoke a compromised token
A token is revoked by the user who owns it:
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
batlehub-cli user block <user-id>Blocks all future requests from that user ID until unblocked.
Quarantine a malicious package
# 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.
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.
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 tooGET /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
- Rotate credentials — generate new API tokens for all service accounts; update downstream consumers.
- Patch the vulnerability — if a CVE triggered the incident, apply the patch, run
cargo auditlocally, and rebuild the image. - Re-run SBOM scan —
task securityto confirm the patched dependency tree is clean. - 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
- Deploy patched image — run
cargo build --releaseor trigger CI; push patched container. - Verify health —
GET /healthzreturns200on 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/healthis the detailed per-registry view and needs an admin token. - Unblock legitimate traffic — remove IP blocks and unblock users that were collateral.
- 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:
- Write a timeline (detection → containment → eradication → recovery).
- Identify root cause and contributing factors.
- List corrective actions with owners and due dates.
- Update this playbook if any step was missing or unclear.
- 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.
| Deadline | What NIS2 asks | Where the evidence lives |
|---|---|---|
| 24 h after becoming aware — early warning | Whether the incident is suspected to be malicious or to have a cross-border impact | The audit stream in your SIEM and the Sigma rule that fired (SIEM integration) |
| 72 h — incident notification | An initial assessment: severity, impact, indicators of compromise | The audit log for the window: batlehub-cli audit export --from <start> --to <end> --format json |
| One month — final report | Root cause, mitigation applied, cross-border impact | The 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:
# <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):
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):
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
--forceand 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:
| Role | Contact |
|---|---|
| On-call engineer | — |
| Security lead | — |
| Legal / DPO | — |
| Upstream registry contacts (GitHub, npm, PyPI) | — |