Skip to content

DOS Attack on our WS server, potential vulnerability? #5235

Answered by darrachequesne
FabianB12 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! Yes, I'd say that counts as a regular DOS attack.

You could catch the 'ping' messages in your application and close the connection:

function listenToPing(socket) {
  socket.on("ping", () => {
    console.warn("unexpected ping");
    socket.close();
  });
}

io.engine.on("connection", (engineSocket) => {
  if (engineSocket.transport.name === "websocket") {
    listenToPing(engineSocket.transport.socket);
  } else {
    engineSocket.on("upgrade", (transport) => {
      if (transport.name === "websocket") {
        listenToPing(transport.socket);
      }
    })
  }
});

I'm wondering whether we should include it in the library, as receiving ping / pong events is not really expected. Thoug…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FabianB12
Comment options

Answer selected by FabianB12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants