CVE-2022-2421: Insufficient validation when decoding a Socket.IO packet in socket.io-parser

socket.io-parser Updated 02 Oct 2025

Summary

26/10/2022
Yes i
Critical
9.8

CVE-2022-2421: Insufficient validation when decoding a Socket.IO packet. Affects socket.io-parser across 4 version ranges.

< 3.3.3 >= 3.4.0, < 3.4.2 >= 4.0.0, < 4.0.5 >= 4.1.0, < 4.2.1

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Socket.IO is a JavaScript library that enables real-time, bidirectional communication between web clients and servers. It utilizes the WebSocket protocol and provides additional features such as event-based communication and room-based messaging. The socket.io-parser library is used by the socket.io and socket.io-client packages to encode and decode Socket.IO packets. This vulnerability arises from improper type validation in the socket.io-parser library, allowing an attacker to overwrite the _placeholder object and potentially place references to functions at arbitrary locations in the resulting query object.

Vulnerability Detail

The vulnerability in socket.io-parser allows an attacker to manipulate the decoding process of Socket.IO packets. By sending a crafted payload, an attacker can overwrite the _placeholder object and insert references to functions in the resulting query object. This can lead to various security issues, including remote code execution, privilege escalation, and denial of service. The impact of this vulnerability depends on how the decoded data is handled by the application. If the payload is not properly validated, it can result in the execution of arbitrary functions or unexpected behavior.

How To Fix

Latest published version: 4.2.7 as of 23 Oct 2026

npm install socket.io-parser@4.2.7

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 3.3.3 3.3.3
    npm install socket.io-parser@3.3.3
  • >= 3.4.0, < 3.4.2 3.4.2
    npm install socket.io-parser@3.4.2
  • >= 4.0.0, < 4.0.5 4.0.5
    npm install socket.io-parser@4.0.5
  • >= 4.1.0, < 4.2.1 4.2.1
    npm install socket.io-parser@4.2.1

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If updating the packages is not immediately feasible, a workaround can be implemented by manually validating the payload received from the client. The payload should be checked to ensure it is a Buffer object before further processing. If the payload is not a Buffer, the connection should be terminated. Here is an example of how to implement this workaround in a socket.io server:

io.on("connection", (socket) => {
  socket.on("hello", (val) => {
    if (!Buffer.isBuffer(val)) {
      socket.disconnect();
      return;
    }
    // Further processing of the valid payload
  });
});

Conclusion

The vulnerability in socket.io-parser can have severe security implications if not addressed. It is crucial to validate the payload received from clients and update the affected packages to the latest versions. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for socket.io-parser →

Share this vulnerability

FAQ

Socket.IO is a JavaScript library that enables real-time, bidirectional communication between web clients and servers. It provides features such as event-based communication and room-based messaging.

socket.io-parser is a library used by the socket.io and socket.io-client packages to encode and decode Socket.IO packets.

The impact of this vulnerability depends on how the decoded data is handled by the application. It can lead to remote code execution, privilege escalation, and denial of service.

To fix this vulnerability, ensure that the payload received from the client is a Buffer object. Update the socket.io-parser library to version 4.2.1 or higher, or update the socket.io or socket.io-client packages to versions that include the patched socket.io-parser library.

Yes, if updating the packages is not immediately feasible, you can manually validate the payload received from the client. Check if it is a Buffer object before further processing and terminate the connection if it is not.

Related vulnerabilities

Recent vulnerabilities recorded for socket.io-parser.

How To Fix

Latest published version: 4.2.7 as of 23 Oct 2026

npm install socket.io-parser@4.2.7

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 3.3.3 3.3.3
    npm install socket.io-parser@3.3.3
  • >= 3.4.0, < 3.4.2 3.4.2
    npm install socket.io-parser@3.4.2
  • >= 4.0.0, < 4.0.5 4.0.5
    npm install socket.io-parser@4.0.5
  • >= 4.1.0, < 4.2.1 4.2.1
    npm install socket.io-parser@4.2.1

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback