Skip to content

Reject API access from browsers - #3380

Merged
pm47 merged 1 commit into
masterfrom
api-cross-origin
Sep 15, 2026
Merged

pm47 merged 1 commit into
masterfrom
api-cross-origin

Conversation

@pm47

@pm47 pm47 commented Sep 15, 2026

Copy link
Copy Markdown
Member

Any request carrying an Origin header is now rejected with 403 before the inner route runs: browsers set it on every cross-site request and every non-GET/HEAD request, while curl and eclair-cli never do. Checking presence rather than value also covers Origin: null and DNS rebinding.

This is a defence against browser CSRF, not an authentication mechanism — Origin is trivially omitted by a non-browser client, and the API should still never be exposed beyond loopback.

Breaking change: the API can no longer be called from a web browser, even same-origin; anyone serving a web front-end against it now needs their own back-end in front.

Fixes project-loupe/audit-eclair#223, and by construction any other CSRF report against an individual endpoint.

@pm47
pm47 requested a review from sstone September 15, 2026 11:24
@pm47
pm47 merged commit eb077dd into master Sep 15, 2026
1 of 2 checks passed
@pm47
pm47 deleted the api-cross-origin branch September 15, 2026 13:58
pm47 added a commit that referenced this pull request Sep 15, 2026
Any request carrying an `Origin` header is now rejected with 403 before the inner route runs: browsers set it on every cross-site request and every non-GET/HEAD request, while `curl` and `eclair-cli` never do. Checking presence rather than value also covers `Origin: null` and DNS rebinding.

This is a defence against browser CSRF, not an authentication mechanism — `Origin` is trivially omitted by a non-browser client, and the API should still never be exposed beyond loopback.

Breaking change: the API can no longer be called from a web browser, even same-origin; anyone serving a web front-end against it now needs their own back-end in front.

Fixes project-loupe/audit-eclair#223, and by construction any other CSRF report against an individual endpoint.
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.

2 participants