Skip to content

Socket.io server crashes upon receiving invalid data #3036

@x052

Description

@x052

You want to:

  • report a bug
  • request a feature

Current behaviour

Socket.io server crashes when the client sends invalid data.

Steps to reproduce (if the current behaviour is a bug)

Sending the data 442["some","data","that","breaks","stuff"] to the socket.io server.
Reproduces on most servers, sample server code:

const http = require('http')
const server = http.createServer()

server.listen(1337)

const io = require('socket.io').listen(server)

io.sockets.on('connection', (socket) => {})

Client-side (although this could come from any untrusted source)

var ws = new WebSocket('ws://localhost:1337/socket.io/?EIO=3&transport=websocket')
ws.send(`442["some","data","that","breaks","stuff"]`)

Expected behaviour

The server should not crash upon receiving this data.

Setup

  • OS: Linux
  • browser: Any, including headless clients
  • socket.io version: 2.0.3

Other information (e.g. stacktraces, related issues, suggestions how to fix)

events.js:187
      throw err;
      ^

Error: Unhandled "error" event. (some,data,that,breaks,stuff)
    at Socket.emit (events.js:185:19)
    at Socket.emit (/node_modules/socket.io/lib/socket.js:141:10)
    at Socket.onpacket (/node_modules/socket.io/lib/socket.js:343:12)
    at /node_modules/socket.io/lib/client.js:193:16
    at _combinedTickCallback (internal/process/next_tick.js:95:7)
    at process._tickCallback (internal/process/next_tick.js:161:9)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions