Skip to content

server: block server access via non-local domains #3587

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cebtenzzre
Copy link
Member

@cebtenzzre cebtenzzre commented May 27, 2025

This PR contains the necessary code to prevent a potential DNS rebind attack of the local server, in which a malicious remote host points their domain name to a local IP address to bypass CORS, allowing a client-side script in a web browser to access the local GPT4All instance. This is exacerbated by the fact that the local server currently provides no authentication mechanism.

TODO: Test this change. done.

@cebtenzzre cebtenzzre force-pushed the mitigate-dns-rebind branch from 314b589 to 86326bb Compare May 27, 2025 19:47
@cebtenzzre cebtenzzre marked this pull request as ready for review May 27, 2025 19:48
@cebtenzzre
Copy link
Member Author

cebtenzzre commented May 27, 2025

If you add 127.0.0.1 example.com to your /etc/hosts, you can simulate a DNS rebind attack. This PR blocks these requests:

$ curl 'http://localhost:4891/v1/models'
{"data": ...}
$ curl 'http://example.com:4891/v1/models'
{"error":"Access to the server via non-local host example.com is forbidden."}

This also makes it more difficult to expose the local server to the internet, which I believe is a good thing.

@cebtenzzre cebtenzzre requested a review from manyoso May 27, 2025 20: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