mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-12-03 02:16:29 +08:00
SOC 2 follow-ups from the 2026-10-06 firewall review (R3, R4) and incident INC-2026-001. ## Beacon rate limit (R3) `deploy/beacon/wrangler.toml` said a WAF rule limited `/v1/logs` to 60 req/min/IP. That rule could not exist: headroomlabs.ai is not a Cloudflare zone, so the Worker is only on `workers.dev`. This adds a [Workers rate-limit binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/) checked in `fetch()` **before** the body is read. - Keyed on one constant, not the IP: the Worker still never reads `cf-connecting-ip` (privacy promise in the file header). Trade-off: a flood also sheds real events for that minute. - 3000 req/min **per Cloudflare location** (~10x today's ~300/min total). - Returns 429, which the client does **not** treat as a gzip refusal (`_GZIP_REFUSED_STATUSES` is 400/415), so rate-limited clients keep compressing. - Fails open if the binding is absent **or the limiter itself errors** (review fix): a rate-limit service outage lets beacons through rather than dropping all of them. `node deploy/beacon/test-rollup.mjs` covers 429 over the limit, fail-open on outage and when unbound, and the single shared key. ## Dev environment (R4) `[env.dev]` deploys `headroom-beacon-dev` bound to the new `headroom-telemetry-dev` bucket (600/min limit). Already deployed and tested: a sample event returns 204, and a 2,500-request burst got 384 × 429. ## Weekly CodeQL triage `.github/workflows/codeql-triage.yml` opens an issue every Monday, assigned to @chopratejas (tejas@headroomlabs.ai), listing open critical/high alerts with checkboxes. Alert #63 sat unowned for five months; this gives alerts an owner and leaves an audit trail. **One issue per week, however often it runs (review fix).** The logic is in `scripts/codeql_triage.sh`: - It keys the issue on the ISO week, using a hidden marker in the body. - It finds the existing issue by listing security-labelled issues, closed ones included. It uses a listing, not search, so an issue created seconds earlier is not missed. - It reuses that issue and never edits, reopens or retitles it, so ticked boxes and closure stand. Alerts opened since then are added once, as a comment. - The jq programs live in quoted heredocs, which clears ShellCheck SC2016 without any shell expansion. - `tests/test_codeql_triage_script.py` runs the real script against a fake `gh`. It covers same-day re-runs, a Friday dispatch on a closed issue with ticked boxes, the next week, and the ISO year boundary (2027-01-01 is in 2026-W53). ### Test output ```text $ pytest -q tests/test_codeql_triage_script.py 6 passed $ node deploy/beacon/test-rollup.mjs rate limit: 429 over, fail-open on outage and when unbound ok $ shellcheck scripts/codeql_triage.sh && actionlint .github/workflows/codeql-triage.yml (clean) ``` ## ⚠️ Before deploying production The live `headroom-beacon` Worker predates #3253 (gzip inflate, schema v2 allowlist). `wrangler deploy` from main will ship that too, not just this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/4008" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a> <!-- devin-review-badge-end --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: JerrettDavis <mxjerrett@gmail.com>