Reject API access from browsers - #3380
Merged
Merged
Conversation
pm47
force-pushed
the
api-cross-origin
branch
from
September 15, 2026 11:25
78e3f8a to
9184d5e
Compare
sstone
approved these changes
Sep 15, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Any request carrying an
Originheader is now rejected with 403 before the inner route runs: browsers set it on every cross-site request and every non-GET/HEAD request, whilecurlandeclair-clinever do. Checking presence rather than value also coversOrigin: nulland DNS rebinding.This is a defence against browser CSRF, not an authentication mechanism —
Originis 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.