Skip to content

Commit a8343a8

Browse files
Merge pull request #1802 from frieck/main
Securing websockets
2 parents dab66fc + fb11f3f commit a8343a8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/api/integrations/event/websocket/websocket.controller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ export class WebsocketController extends EventController implements EventControl
3030
const url = new URL(req.url || '', 'http://localhost');
3131
const params = new URLSearchParams(url.search);
3232

33+
const { remoteAddress } = req.socket;
34+
const isLocalhost =
35+
remoteAddress === '127.0.0.1' || remoteAddress === '::1' || remoteAddress === '::ffff:127.0.0.1';
36+
3337
// Permite conexões internas do Socket.IO (EIO=4 é o Engine.IO v4)
34-
if (params.has('EIO')) {
38+
if (params.has('EIO') && isLocalhost) {
3539
return callback(null, true);
3640
}
3741

0 commit comments

Comments
 (0)