- Migration: er_ingest_keys.rate_limit_max and rate_limit_window_ms (nullable overrides). - Fingerprint policy v2: server-side digest includes normalized stacktrace (UUID/hex/line noise). - In-memory fixed-window limits: per API key after auth; per-IP for unauthenticated POSTs (INGEST_ANON_IP_*). Removed @fastify/rate-limit dependency. - OpenAPI documents 429; runbook at docs/operations/ingest-hardening-runbook.md. Paperclip-Agent: 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376 Paperclip-Issue: BIT-735 Paperclip-Run: 0a91be22-6f8f-4c60-b889-44b99048d3a2 Made-with: Cursor
2.6 KiB
2.6 KiB
Ingest hardening — validation runbook (BIT-735)
Use this after deploying ingest API or changing fingerprint / noise / rate-limit behaviour.
Prerequisites
- Apply DB migrations through
20260402140000_ingest_key_rate_limitssoer_ingest_keysexposesrate_limit_maxandrate_limit_window_ms. - Ingest keys are created in MariaDB (
er_ingest_keys); clients send the raw token viaAuthorization: BearerorX-Api-Key(never a shared WDMI env secret on the wire).
Environment
| Variable | Role |
|---|---|
INGEST_RATE_LIMIT_MAX / INGEST_RATE_LIMIT_WINDOW_MS |
Default per-key budget when DB columns are NULL |
INGEST_ANON_IP_MAX / INGEST_ANON_IP_WINDOW_MS |
Budget for POST /v1/ingest/events without credentials (abuse of 401 path) |
Per-key overrides: set rate_limit_max and/or rate_limit_window_ms on the key row; NULL means inherit the corresponding env default.
Fingerprint quality
- Server-side fingerprint policy version is returned on each ingest response as
fingerprint_policy_version. - When the client omits
fingerprint, the hub hashes: normalized first line ofmessage,contextlocation (file_path/stack_info), project slug/name hints, and a digest of a normalizedstacktrace(volatile tokens such as UUIDs and0x…addresses collapsed). - Check: send the same logical error twice from different hosts; incident count should stay stable (one fingerprint) if
stacktraceandcontextalign. - Check: change only a UUID inside the stack; fingerprint should remain stable.
Noise filter coverage
- Rules live in
ingest-api/src/lib/noisePolicy.ts; ruleset id:noise_ruleset_versionin the ingest response. - Check: send a known-noise payload (for example ResizeObserver message at non-fatal level); expect
skipped: true,noise_filtered_countincremented, and no newer_incidentsrow. - Check: send the same pattern at
fatal/criticallevel; expect not skipped (noise rules do not hide critical).
Rate limits
- Authenticated traffic:
429+Retry-Afterwhen the per-key window is exhausted (DB limits or env defaults). - Unauthenticated traffic: same for the client IP after
INGEST_ANON_*budget. - Check:
curlthree rapid unauthenticated posts; third should be429ifINGEST_ANON_IP_MAX=2. - Check: lower
rate_limit_maxon a test key to2and confirm the third authenticated request returns429.
Automated tests
From ingest-api/:
npm test
Integration tests need ERROR_REPORTING_TEST_DATABASE_URL and an applied schema including rate-limit columns.