-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
feat: add test
/.test
to server.allowedHosts
/server.cors.origin
by default
#19250
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
13764a3
fix: allow CORS from loopback addresses by default
sapphi-red aebc56a
chore: add comment
sapphi-red 576e87d
test: add a bit more cases
sapphi-red 46fd0d2
feat: add `test`/`.test` to `server.allowedHosts`/`server.cors.origin…
sapphi-red 3dbd702
chore: update default value in docs
sapphi-red File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { expect, test } from 'vitest' | ||
import { defaultAllowedOrigins } from '../constants' | ||
|
||
test('defaultAllowedOrigins', () => { | ||
const allowed = [ | ||
'http://localhost', | ||
'http://foo.localhost', | ||
'http://foo.test', | ||
'http://localhost:3000', | ||
'https://localhost:3000', | ||
'http://127.0.0.1', | ||
'http://[::1]', | ||
'http://[::1]:3000', | ||
] | ||
const denied = [ | ||
'file:///foo', | ||
'http://localhost.example.com', | ||
'http://foo.example.com:localhost', | ||
'http://', | ||
'http://192.0.2', | ||
'http://[2001:db8::1]', | ||
'http://vite', | ||
'http://vite:3000', | ||
] | ||
|
||
for (const origin of allowed) { | ||
expect(defaultAllowedOrigins.test(origin), origin).toBe(true) | ||
} | ||
|
||
for (const origin of denied) { | ||
expect(defaultAllowedOrigins.test(origin), origin).toBe(false) | ||
} | ||
}) |
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the
test
domain name / hostname, the document mentions:Should we not handle the test hostname in that case?
For TLDs I think it's fine since it doesn't mention anything like that https://datatracker.ietf.org/doc/rfc2606/
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that sentence is meant to include both
test
and*.test
s. So I think we should include bothtest
/*.test
or not include both.(FYI the last dot of
test.
/.test.
is to clarify that it's the last item)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should not add
.test
anyway as trusting the (cache) DNS server does not necessarily mean you can trust the IPs listed in that DNS server.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Then I guess technically it discourages treating
test
TLDs differently, so I think I'm somewhat leaning on not adding.test
as a special case 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand this reasoning. You would never hit a public (potentially malicious) site under the
.test
TLD, so a remote attacker could never change DNS resolving of such a domain. Do you mean there is no built-in security on any modern system that prevents local DNS cache from containing (injected) .test domains? (don't know, thought the system would be responsible of ensuring this)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say there's an internal DNS server and you and your team all uses that DNS server. Then, a member of your team added
foo.test
that points to some IP. You know that the DNS server would not fool you, but don't know whether the IPfoo.test
is pointing is trustable. In most cases, you would never add a DNS record that points to an IP that you don't hold, but you can point to an IP you don't have control of.You may say that you should never put an IP you don't control, but it's not enforced by something, and there maybe a user that is using
.test
like that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation. I just thought there would be system level safeguards that would prevent any modern system from ever resolving the
.test
domain via DNS. But I am probably asking for too much here and we cannot count on such (potential) system level implementations, and anyway that would be against the rfc6761Application software SHOULD NOT recognize test names as special
principle.