You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lab-ops-hub: public Worker has no auth on mutating, upload, AI and crawl endpoints (PR #436) #441
PR #436 (#436, head a772fc2f391234cbdd4ed169d9174b13e8994801, initial commit 98381153702ef50135230e1d941040e4bbb4f4db) adds pkgs/lab-ops-hub, a Worker the PR body says is live at lab-ops-hub.developing-today.workers.dev. Its entire request dispatch in pkgs/lab-ops-hub/src/index.ts (the fetch handler starting ~line 123) routes on pathname + method only — there is no authentication or authorization check anywhere in the file (no Authorization header, shared-secret, or Cloudflare Access check; the only "auth" mention in the package is deployment-time CLOUDFLARE_API_TOKEN in the README).
Unauthenticated callers can therefore use, among others:
POST /api/machines (src/index.ts:164), POST /api/notes (:178), POST /api/tasks (:206) — insert arbitrary rows into D1
POST /api/notes/:id/summarize (:186, AI.run at :190) — spend Workers AI neurons on demand
POST /api/files (:218, R2 FILES.put at :224) — upload arbitrary files to the labops-files R2 bucket, then read them back via GET /api/files/<key> (:232; keys are uploads/<epoch-ms>-<sanitised filename>, i.e. largely predictable)
POST /api/live (:239) — overwrite/broadcast the Durable Object live board
POST /api/crawl (:246) — make the Worker (fallback crawlFallback, :112) and the container (pkgs/lab-ops-hub/container/app.py:80, urllib.request.urlopen on the caller-supplied URL, no scheme/host validation in either crawler) fetch an arbitrary URL, archive the result to R2, and burn container minutes
Why it matters
The demo's design premise (README: "sized to stay inside the $5/mo plan's included amounts") only holds for a single well-behaved user. On a public workers.dev URL, anyone can fill D1/R2, store arbitrary content in the bucket and serve it back, invoke AI and container runs until quotas/overage apply, and use the crawler as an open fetch proxy (SSRF surface in both implementations). This was verified against the PR head code — the package is not on main yet, so this is the moment to fix it before merge/redeploy.
Deduped: issue searches for lab-ops-hub, lab-ops, budget, unauthenticated return no existing issue. Cross-repo: lab-ops-hub exists only in this repo/PR, so this is a single-repo issue.
Acceptance criteria
All mutating /api/* routes (and ideally all /api/* except /api/health) require a credential (e.g. a Worker secret compared in the handler, or Cloudflare Access in front of the app) — verified: an unauthenticated POST /api/notes, POST /api/files, POST /api/crawl each return 401/403, and the same calls with the credential succeed
Both crawlers validate the target URL: http:/https: only, and private / loopback / link-local targets refused (or an explicit, documented decision why not, in the README)
README's API section documents the auth requirement (the current "Auth:" note covers only deploy-time tokens)
OR, if a fully public demo is a deliberate decision: that decision and its abuse/cost exposure are recorded in the README, and the cost-incurring endpoints (crawl, summarize, file upload) are disabled by default
Fixed on PR #436's branch in commit f776001 (pushed onto cloudflare/cf-cli-and-lab-ops-hub):
Auth gate: every /api/* route except /api/health requires the API_TOKEN Worker secret — Authorization: Bearer <token> (or x-api-token, or ?token= for the WebSocket/file-download cases), compared via SHA-256 + constant-time compare. The gate fails closed: if the secret is unset the API returns 503, so a redeploy that forgets wrangler secret put API_TOKEN cannot silently re-open the endpoints. The dashboard prompts for the token once and keeps it in sessionStorage.
Crawl validation (validateCrawlUrl in src/lib.ts, re-implemented independently in container/app.py): http/https only; localhost-style names and private/loopback/link-local/CGNAT/documentation/multicast IP literals refused, including IPv4-mapped IPv6 and WHATWG-normalised integer/hex IPv4 forms; the container also validates redirect targets. Documented residual: literal-host check only — DNS rebinding is called out in the README.
README documents the auth requirement and the wrangler secret put API_TOKEN setup step.
Verified: Node unit tests 6/6 (npm test); the real fetch handler driven with stubbed bindings — unauthenticated POST /api/notes → 401, wrong token → 401, correct token → 201, secret unset → 503, /api/health public → 200, authed crawl of 169.254.169.254 → 400; tsc --noEmit clean. The same commit also fixes the branch's failing treefmt check (repo format-check now reports 0 changed on the PR's files).
Deploy note: set the secret before redeploying the live Worker (wrangler secret put API_TOKEN), or the live API will 503 by design. This issue stays open until PR #436 merges.
Activity
fix(lab-ops-hub): require API token auth, validate crawl targets, com…
dezren39 commentedon Oct 21, 2026
Fixed on PR #436's branch in commit f776001 (pushed onto
cloudflare/cf-cli-and-lab-ops-hub):/api/*route except/api/healthrequires theAPI_TOKENWorker secret —Authorization: Bearer <token>(orx-api-token, or?token=for the WebSocket/file-download cases), compared via SHA-256 + constant-time compare. The gate fails closed: if the secret is unset the API returns 503, so a redeploy that forgetswrangler secret put API_TOKENcannot silently re-open the endpoints. The dashboard prompts for the token once and keeps it insessionStorage.validateCrawlUrlinsrc/lib.ts, re-implemented independently incontainer/app.py): http/https only; localhost-style names and private/loopback/link-local/CGNAT/documentation/multicast IP literals refused, including IPv4-mapped IPv6 and WHATWG-normalised integer/hex IPv4 forms; the container also validates redirect targets. Documented residual: literal-host check only — DNS rebinding is called out in the README.wrangler secret put API_TOKENsetup step.Verified: Node unit tests 6/6 (
npm test); the real fetch handler driven with stubbed bindings — unauthenticated POST /api/notes → 401, wrong token → 401, correct token → 201, secret unset → 503, /api/health public → 200, authed crawl of 169.254.169.254 → 400;tsc --noEmitclean. The same commit also fixes the branch's failing treefmt check (repo format-check now reports 0 changed on the PR's files).Deploy note: set the secret before redeploying the live Worker (
wrangler secret put API_TOKEN), or the live API will 503 by design. This issue stays open until PR #436 merges.