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

"null" origin should be allowed #62

Open
tomaszkiewicz opened this issue Mar 8, 2020 · 1 comment
Open

"null" origin should be allowed #62

tomaszkiewicz opened this issue Mar 8, 2020 · 1 comment

Comments

@tomaszkiewicz
Copy link

According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin the header may be one of:

Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: <origin>
Access-Control-Allow-Origin: null

However, when I try to specify "null" as one of the origins:

r.Use(cors.New(cors.Config{
		AllowOrigins: []string{
...
			"null",
		},

I get:

panic: bad origin: origins must contain '*' or include http://,https://

The use case is PWA sharing files on Android using POST to the app - in that case we get "null" in the Origin header. I saw that it's not recommended, however I think it should be supported as an option.

Best regards

Łukasz Tomaszkiewicz

@jub0bs
Copy link

jub0bs commented Oct 25, 2022

Allowing the null origin is a bad idea, in particular because any malicious client can get hold of it by issuing requests from a sandboxed document (e.g. an iframe with the sandbox attribute).

If you allow the null origin with credentials, you're essentially deactivating all of the SOP's restrictions on network access; you're leaving the door wide open to cross-origin attacks against your users. And if you want to allow the null origin without credentials, you might as well have Access-Control-Allow-Origin: * instead in your responses.

More details at https://portswigger.net/research/exploiting-cors-misconfigurations-for-bitcoins-and-bounties

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

No branches or pull requests

2 participants