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

CORS issue #264

Open
lotuspolarbear opened this issue Jun 10, 2021 · 7 comments
Open

CORS issue #264

lotuspolarbear opened this issue Jun 10, 2021 · 7 comments

Comments

@lotuspolarbear
Copy link

Hi, I'd like to set only trusted origins to the socket server so it won't be exposed to any origins.

I usde $io->origins to allow the requests from my domain but it is still being exposed to any domains.
Here's my code.

$io = new SocketIO(2020, $context);
$io->origins('https://mydomain.com:*');
$io->on('workerStart', function()use($io){
$io->adapter('\PHPSocketIO\ChannelAdapter');
});

Are there any ways to fix the CORS issue with/without using $io->origins ?

Thank you!

@walkor
Copy link
Owner

walkor commented Jun 11, 2021

It works fine for me.

$sender_io = new SocketIO(2120);
$sender_io->origins('http://127.0.0.1:*');

image

When I changed $sender_io->origins('http://127.0.0.1:*'); to $sender_io->origins('http://128.0.0.1:*');

image

@lotuspolarbear
Copy link
Author

Hi, thanks for your response.

Yeah, it returns 403 on my end as well but the response has Access-Control-Allow-Origin value.

Here's what I got.
Screenshot_21

The vulnerability scan result still says socket.io is exposed to any origin.

Screenshot_22
Screenshot_23

I don't want the Access-Control-Allow-Credentials and Access-Control-Allow-Origin to come back as a response.

Any ideas?

Thank you!

@lotuspolarbear
Copy link
Author

Instead of the 403 Forbidden error, is it possible to send a 404 Page Not Found error?

@walkor
Copy link
Owner

walkor commented Jun 14, 2021 via email

@lotuspolarbear
Copy link
Author

I think it's possible if I modify the sendErrorMessage() function in /src/Engine/Engine.php?

@walkor
Copy link
Owner

walkor commented Jun 14, 2021 via email

@lotuspolarbear
Copy link
Author

Thank you!

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