Skip to content

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

Open
cebtenzzre wants to merge 3 commits into
mainfrom
mitigate-dns-rebind
Open

server: block server access via non-local domains#3587
cebtenzzre wants to merge 3 commits into
mainfrom
mitigate-dns-rebind

Conversation

@cebtenzzre

@cebtenzzre cebtenzzre commented May 27, 2025

Copy link
Copy Markdown
Member

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.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
@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
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
@cebtenzzre

cebtenzzre commented May 27, 2025

Copy link
Copy Markdown
Member Author

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