Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CORS support for the REST services #3378

Merged
merged 1 commit into from
Feb 14, 2022
Merged

Add CORS support for the REST services #3378

merged 1 commit into from
Feb 14, 2022

Conversation

zah
Copy link
Contributor

@zah zah commented Feb 11, 2022

The added options work in opt-in fashion. If they are not specified,
the server will respond to all requests as if the CORS specification
doesn't exist. This will result in errors in CORS-enabled clients.

If the options are provided, the server will enforce the Origin by
returning 403 Forbidden when the requests headers don't match the
desired value.

Please note that future versions may support more than one allowed
origin. The option names will stay the same, but the user will be
able to repeat them on the command line (similar to other options
such as --web3-url).

To be documented in the guide in a separate PR.

@zah
Copy link
Contributor Author

zah commented Feb 11, 2022

The decision to disallow access from CORS-enabled clients by default was a security consideration. We don't want to make it possible for malicious web-sites to try connecting to locally running beacon node (on localhost) that can be attacked.

@github-actions
Copy link

github-actions bot commented Feb 11, 2022

Unit Test Results

     12 files     821 suites   30m 22s ⏱️
1 671 tests 1 625 ✔️   46 💤 0
9 755 runs  9 655 ✔️ 100 💤 0

Results for commit 3bf3a95.

♻️ This comment has been updated with latest results.

@arnetheduck
Copy link
Member

arnetheduck commented Feb 12, 2022

Geth appears to have separate option for options for client and server side enforcement - how are the two related?

  --http.corsdomain value             Comma separated list of domains from which to accept cross origin requests (browser enforced)
  --http.vhosts value                 Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")

@zah
Copy link
Contributor Author

zah commented Feb 14, 2022

The vhosts option sounds like something enforcing the Host header value on the requests. In other words, it would prevent requests to be accidentally routed to the API on a server with multiple DNS hostnames.

The added options work in opt-in fashion. If they are not specified,
the server will respond to all requests as if the CORS specification
doesn't exist. This will result in errors in CORS-enabled clients.

Please note that future versions may support more than one allowed
origin. The option names will stay the same, but the user will be
able to repeat them on the command line (similar to other options
such as --web3-url).

To be documented in the guide in a separate PR.
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