CVE-2021-23386: Potential memory exposure in dns-packet

dns-packet Updated 02 Oct 2025

Summary

24/05/2021
Yes i
High
7.7

CVE-2021-23386: Potential memory exposure in dns-packet. Affects dns-packet across 2 version ranges.

< 1.3.2 >= 2.0.0, < 5.2.2

Fixed in 1.3.2 or 5.2.2, depending 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 Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The dns-packet package is an npm package that provides functionality for encoding and decoding DNS packets. It is commonly used in Node.js applications for DNS-related operations. The package allows users to create DNS packets and send them over the network. However, versions before 1.3.2 and 5.2.2 of dns-packet are vulnerable to a potential memory exposure issue. When crafting invalid domain names, the package creates buffers using the allocUnsafe function without always filling them before forming network packets. This can lead to the exposure of internal application memory over unencrypted networks.

Vulnerability Detail

The vulnerability in dns-packet arises from the improper handling of buffers created with allocUnsafe. By not always filling these buffers before forming network packets, the package exposes internal application memory when querying crafted invalid domain names. This can be exploited by an attacker to obtain sensitive information from the application's memory. The vulnerability has a CVSS score of 7.7, indicating a high severity level. It is important to note that this vulnerability affects versions before 1.3.2 and 5.2.2 of dns-packet.

How To Fix

Fixed versions by release line

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

  • < 1.3.2 1.3.2
    npm install dns-packet@1.3.2
  • >= 2.0.0, < 5.2.2 5.2.2
    npm install dns-packet@5.2.2

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

Workaround

As a workaround, if updating the package is not immediately feasible, it is recommended to avoid querying crafted invalid domain names that could trigger the vulnerability. By ensuring that only valid domain names are used in DNS queries, the risk of memory exposure can be mitigated.

Conclusion

In conclusion, the dns-packet package before versions 1.3.2 and 5.2.2 is vulnerable to a potential memory exposure issue. This can lead to the exposure of internal application memory over unencrypted networks when querying crafted invalid domain names. To mitigate this vulnerability, it is recommended to update the package to the latest secure version. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for dns-packet →

Share this vulnerability

FAQ

dns-packet is an npm package used for encoding and decoding DNS packets in Node.js applications.

Versions before 1.3.2 and 5.2.2 of dns-packet are affected by this vulnerability.

The vulnerability can be exploited by crafting invalid domain names and querying them, which can expose internal application memory over unencrypted networks.

The vulnerability has a CVSS score of 7.7, indicating a high severity level.

To fix this vulnerability, update the dns-packet package to version 1.3.2 or later, or version 5.2.2 or later.

How To Fix

Fixed versions by release line

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

  • < 1.3.2 1.3.2
    npm install dns-packet@1.3.2
  • >= 2.0.0, < 5.2.2 5.2.2
    npm install dns-packet@5.2.2

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