Skip to content

chore(deps): update dependency socket.io to v4.6.2 [security]#558

Closed
renovate[bot] wants to merge 1 commit intomainfrom
renovate/npm-socket.io-vulnerability
Closed

chore(deps): update dependency socket.io to v4.6.2 [security]#558
renovate[bot] wants to merge 1 commit intomainfrom
renovate/npm-socket.io-vulnerability

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Jun 19, 2024

This PR contains the following updates:

Package Change Age Confidence
socket.io (source) 4.5.3 -> 4.6.2 age confidence

GitHub Vulnerability Alerts

CVE-2024-38355

Impact

A specially crafted Socket.IO packet can trigger an uncaught exception on the Socket.IO server, thus killing the Node.js process.

node:events:502
    throw err; // Unhandled 'error' event
    ^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. (undefined)
    at new NodeError (node:internal/errors:405:5)
    at Socket.emit (node:events:500:17)
    at /myapp/node_modules/socket.io/lib/socket.js:531:14
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
  code: 'ERR_UNHANDLED_ERROR',
  context: undefined
}

Affected versions

Version range Needs minor update?
4.6.2...latest Nothing to do
3.0.0...4.6.1 Please upgrade to socket.io@4.6.2 (at least)
2.3.0...2.5.0 Please upgrade to socket.io@2.5.1

Patches

This issue is fixed by socketio/socket.io@15af22f, included in socket.io@4.6.2 (released in May 2023).

The fix was backported in the 2.x branch today: socketio/socket.io@d30630b

Workarounds

As a workaround for the affected versions of the socket.io package, you can attach a listener for the "error" event:

io.on("connection", (socket) => {
  socket.on("error", () => {
    // ...
  });
});

For more information

If you have any questions or comments about this advisory:

  • Open a discussion here

Thanks a lot to Paul Taylor for the responsible disclosure.

References


Release Notes

socketio/socket.io (socket.io)

v4.6.2

Compare Source

Bug Fixes
Links

v4.6.1

Compare Source

Bug Fixes
  • properly handle manually created dynamic namespaces (0d0a7a2)
  • types: fix nodenext module resolution compatibility (#​4625) (d0b22c6)
Links

v4.6.0

Compare Source

Bug Fixes
  • add timeout method to remote socket (#​4558) (0c0eb00)
  • typings: properly type emits with timeout (f3ada7d)
Features
Promise-based acknowledgements

This commit adds some syntactic sugar around acknowledgements:

  • emitWithAck()
try {
  const responses = await io.timeout(1000).emitWithAck("some-event");
  console.log(responses); // one response per client
} catch (e) {
  // some clients did not acknowledge the event in the given delay
}

io.on("connection", async (socket) => {
    // without timeout
  const response = await socket.emitWithAck("hello", "world");

  // with a specific timeout
  try {
    const response = await socket.timeout(1000).emitWithAck("hello", "world");
  } catch (err) {
    // the client did not acknowledge the event in the given delay
  }
});
  • serverSideEmitWithAck()
try {
  const responses = await io.timeout(1000).serverSideEmitWithAck("some-event");
  console.log(responses); // one response per server (except itself)
} catch (e) {
  // some servers did not acknowledge the event in the given delay
}

Added in 184f3cf.

Connection state recovery

This feature allows a client to reconnect after a temporary disconnection and restore its state:

  • id
  • rooms
  • data
  • missed packets

Usage:

import { Server } from "socket.io";

const io = new Server({
  connectionStateRecovery: {
    // default values
    maxDisconnectionDuration: 2 * 60 * 1000,
    skipMiddlewares: true,
  },
});

io.on("connection", (socket) => {
  console.log(socket.recovered); // whether the state was recovered or not
});

Here's how it works:

  • the server sends a session ID during the handshake (which is different from the current id attribute, which is public and can be freely shared)
  • the server also includes an offset in each packet (added at the end of the data array, for backward compatibility)
  • upon temporary disconnection, the server stores the client state for a given delay (implemented at the adapter level)
  • upon reconnection, the client sends both the session ID and the last offset it has processed, and the server tries to restore the state

The in-memory adapter already supports this feature, and we will soon update the Postgres and MongoDB adapters. We will also create a new adapter based on Redis Streams, which will support this feature.

Added in 54d5ee0.

Compatibility (for real) with Express middlewares

This feature implements middlewares at the Engine.IO level, because Socket.IO middlewares are meant for namespace authorization and are not executed during a classic HTTP request/response cycle.

Syntax:

io.engine.use((req, res, next) => {
  // do something

  next();
});

// with express-session
import session from "express-session";

io.engine.use(session({
  secret: "keyboard cat",
  resave: false,
  saveUninitialized: true,
  cookie: { secure: true }
}));

// with helmet
import helmet from "helmet";

io.engine.use(helmet());

A workaround was possible by using the allowRequest option and the "headers" event, but this feels way cleaner and works with upgrade requests too.

Added in 24786e7.

Error details in the disconnecting and disconnect events

The disconnect event will now contain additional details about the disconnection reason.

io.on("connection", (socket) => {
  socket.on("disconnect", (reason, description) => {
    console.log(description);
  });
});

Added in 8aa9499.

Automatic removal of empty child namespaces

This commit adds a new option, "cleanupEmptyChildNamespaces". With this option enabled (disabled by default), when a socket disconnects from a dynamic namespace and if there are no other sockets connected to it then the namespace will be cleaned up and its adapter will be closed.

import { createServer } from "node:http";
import { Server } from "socket.io";

const httpServer = createServer();
const io = new Server(httpServer, {
  cleanupEmptyChildNamespaces: true
});

Added in 5d9220b.

A new "addTrailingSlash" option

The trailing slash which was added by default can now be disabled:

import { createServer } from "node:http";
import { Server } from "socket.io";

const httpServer = createServer();
const io = new Server(httpServer, {
  addTrailingSlash: false
});

In the example above, the clients can omit the trailing slash and use /socket.io instead of /socket.io/.

Added in d0fd474.

Performance Improvements
  • precompute the WebSocket frames when broadcasting (da2b542)
Links:

v4.5.4

Compare Source

This release contains a bump of:

Links:

Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from e9d9f1d to 96297ea Compare January 23, 2025 18:16
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 96297ea to 923dadf Compare February 9, 2025 13:04
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 923dadf to 32f2d6a Compare March 3, 2025 17:19
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch 3 times, most recently from c116e8d to b2e2a4f Compare March 17, 2025 16:25
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch 2 times, most recently from ac8e4f6 to 6fcb4d3 Compare April 8, 2025 11:26
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 6fcb4d3 to bfc280a Compare April 24, 2025 06:53
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from bfc280a to 7cc506a Compare May 19, 2025 16:54
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 7cc506a to b3a4515 Compare May 28, 2025 09:15
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from b3a4515 to 28bd872 Compare June 4, 2025 11:11
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 28bd872 to 7053dec Compare June 22, 2025 14:52
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 7053dec to b5622b4 Compare July 2, 2025 14:09
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch 2 times, most recently from b14e845 to 648275a Compare August 13, 2025 16:51
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 648275a to 4eb9d0e Compare August 19, 2025 17:03
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 4eb9d0e to cf639a0 Compare August 31, 2025 10:14
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from cf639a0 to b127032 Compare September 25, 2025 16:42
@renovate renovate bot changed the title fix(deps): update dependency socket.io to v4.6.2 [security] chore(deps): update dependency socket.io to v4.6.2 [security] Sep 25, 2025
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from b127032 to 689a043 Compare October 21, 2025 14:01
@renovate renovate bot force-pushed the renovate/npm-socket.io-vulnerability branch from 689a043 to d6d0510 Compare October 25, 2025 08:06
@johngerome johngerome closed this Oct 31, 2025
@renovate
Copy link
Contributor Author

renovate bot commented Oct 31, 2025

Renovate Ignore Notification

Because you closed this PR without merging, Renovate will ignore this update (^4.5.3). You will get a PR once a newer version is released. To ignore this dependency forever, add it to the ignoreDeps array of your Renovate config.

If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.

@renovate renovate bot deleted the renovate/npm-socket.io-vulnerability branch October 31, 2025 12:46
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

Successfully merging this pull request may close these issues.

1 participant

Comments