# CVE-2022-2421: Socket.io - Improper type validation in attachment parsing

> Attackers can inject arbitrary function references into query objects via improper type validation in Socket.io parser, potentially leading to code execution.

- **Severity:** Critical 10.0 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 25 Oct 2022
- **Updated:** 11 Mar 2025
- **Also known as:** GHSA-qm95-pgcg-qqfq

## What is CVE-2022-2421?

CVE-2022-2421 is a critical code injection vulnerability in Socket.io-Parser, published on 25 Oct 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Due to improper type validation in attachment parsing the Socket.io js library, it is possible to overwrite the _placeholder object which allows an attacker to place references to functions at arbitrary places in the resulting query object.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command)

## Which versions are affected by CVE-2022-2421?

8 open source packages ship an affected version, including socket.io-parser. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `socket.io-parser` | npm | All versions | 3.3.3 |
| `socket.io-parser` | npm | All versions | 3.3.3 |
| `socket.io-parser` | npm | From 3.4.0 | 3.4.2 |
| `socket.io-parser` | npm | From 3.4.0 | 3.4.2 |
| `socket.io-parser` | npm | From 4.0.0 | 4.0.5 |
| `socket.io-parser` | npm | From 4.0.0 | 4.0.5 |
| `socket.io-parser` | npm | From 4.1.0 | 4.2.1 |
| `socket.io-parser` | npm | From 4.1.0 | 4.2.1 |

Products: Socket Socket.io-Parser.

## How do I fix CVE-2022-2421?

Upgrade socket.io-parser to a fixed version for your release line: 3.3.3, 3.4.2, 4.0.5 or 4.2.1.

## Is CVE-2022-2421 being exploited?

There is no known exploitation of CVE-2022-2421 in the wild and no public exploit code.

## Other vulnerabilities in Socket.io-Parser

- [CVE-2026-33151](https://insights.sbomify.com/CVE-2026-33151/): socket.io allows an unbounded number of binary attachments (high 8.7)
- [CVE-2020-36049](https://insights.sbomify.com/CVE-2020-36049/): Resource exhaustion in socket.io-parser (high 7.5)
- [CVE-2023-32695](https://insights.sbomify.com/CVE-2023-32695/): Insufficient validation when decoding a Socket.IO packet (high 7.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-2421 and fix it if it is affected.

What it is: CVE-2022-2421 is a critical code injection vulnerability in Socket.io-Parser, published on 25 Oct 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-2421 in the wild and no public exploit code.

Affected packages and fixed versions:
- socket.io-parser (npm): affected all versions; fixed in 3.3.3
- socket.io-parser (npm): affected all versions; fixed in 3.3.3
- socket.io-parser (npm): affected from 3.4.0; fixed in 3.4.2
- socket.io-parser (npm): affected from 3.4.0; fixed in 3.4.2
- socket.io-parser (npm): affected from 4.0.0; fixed in 4.0.5
- socket.io-parser (npm): affected from 4.0.0; fixed in 4.0.5
- socket.io-parser (npm): affected from 4.1.0; fixed in 4.2.1
- socket.io-parser (npm): affected from 4.1.0; fixed in 4.2.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-2421/ (Markdown: https://insights.sbomify.com/CVE-2022-2421/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-2421
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-2421
- OSV: https://osv.dev/vulnerability/CVE-2022-2421

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-2421/
Summaries are generated and may contain mistakes; the official description above is the record.
