Skip to content

Harden Cloudflare Worker origin checks - #10

Merged
f1devbin merged 1 commit into
mainfrom
security/worker-origin-check
Nov 21, 2026
Merged

f1devbin merged 1 commit into
mainfrom
security/worker-origin-check

Conversation

@f1devbin

Copy link
Copy Markdown
Owner

What changed

  • The optional Cloudflare Worker now rejects requests from origins not listed in ALLOWED_ORIGIN, and requests without an Origin header, with 403 instead of proxying them. A deployed worker can no longer be used as an open Telegram proxy by non-browser clients.
  • ALLOWED_ORIGIN="*" remains an explicit opt-in for a deliberately public proxy.
  • Allowed origins are trimmed and tolerate a trailing slash; comma-separated lists still work.
  • Added tests/proxy.test.mjs: origin rejection, preflight, allowed POST, file GET, path/method validation, wildcard and multiple origins.
  • Updated the worker comments, README, README.ru, SECURITY.md and CHANGELOG; version 3.3.1.

Testing

  • npm test — 48/48 pass (8 new tests).
  • npm run build — 25 pages.
  • CI will run the Playwright e2e and Lighthouse checks.

The worker itself is not deployed by GitHub Pages; this changes the bundled file users paste into Cloudflare.

- reject requests from unknown origins and requests without Origin (403)
- keep ALLOWED_ORIGIN=* as an explicit public-proxy opt-in
- add unit tests for origin checks, preflight, paths and proxying
- update docs and SECURITY.md; version 3.3.1
@f1devbin
f1devbin merged commit b7898b8 into main Nov 21, 2026
3 checks passed
@f1devbin
f1devbin deleted the security/worker-origin-check branch November 21, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant