DNS resolution is a basic part of most Node.js applications. Whenever an application connects to an external API, sends an HTTP request, or communicates with another service by hostname, DNS helps determine where the connection should go.
However, DNS handling can become a security risk when an application validates a hostname differently from the way the runtime resolves it. An attacker may exploit this difference to make an application connect to an unintended destination.
The Node.js security release published on October 21, 2026, addressed a high-severity DNS vulnerability, CVE-2026-105482. The issue affects the dns.resolve*() functions and dns.reverse(), which could silently truncate hostnames containing a null byte. The vulnerability affects Node.js 22.x, 24.x, and 26.x.
In this article, you will learn how the issue works, how to check your Node.js version, and how to update your application while reducing the risk of deployment problems.
Understanding the Node.js DNS Vulnerability
Node.js provides DNS functions for looking up hostnames and retrieving DNS records. Developers commonly use these functions when building API clients, network services, and applications that need to resolve hostnames explicitly.
The problem occurs when an application supplies a hostname containing a null byte (\0) to a vulnerable DNS function.
For example, consider this hostname:
const hostname = "attacker.example\0.trusted.example";
An application might validate the hostname against an allowlist before passing it to a DNS resolution function.
However, in affected versions, the DNS operation could interpret the null byte as the end of the hostname and resolve attacker.example instead of rejecting the entire input.
This creates a mismatch between the name the application validated and the name used for DNS resolution. If the application relies on hostname validation to enforce access restrictions, that mismatch can undermine the restriction.
The vulnerability is identified as CVE-2026-105482. It was reported as a high-severity issue and fixed in the October 2026 Node.js security release.
Which Node.js Versions Are Affected?
The official security release identifies the following fixed versions for this DNS issue and the associated security updates.
Node.js release line | Fixed version | Recommended action |
|---|
Node.js 22.x | 22.23.4 | Upgrade to the fixed version or a later supported security release |
Node.js 24.x | 24.22.1 | Upgrade to the fixed version or a later supported security release |
Node.js 26.x | 26.12.1 | Upgrade to the fixed version or a later supported security release |
Older end-of-life versions | No corresponding supported fix guaranteed | Move to a supported release line |
These are the fixed versions identified in the October 21, 2026, security release. Check the current release information before deploying, as later security updates may be available. End-of-life versions should not be assumed safe simply because they are outside the listed release lines.
How to Check Your Node.js Version
Before changing your application, identify the Node.js version used by your development environment and production deployment.
Open a terminal and run:
node --version
For example, the output might be:
v22.23.1
Compare the result with the fixed version for that release line.
You should also check npm:
npm --version
The npm version does not establish whether the Node.js runtime is affected, but it helps you understand the package management environment.
Check the Runtime Used by Your Application
A version check on your laptop is not enough if the application runs inside Docker, a cloud service, or a CI/CD pipeline.
You can print the runtime version when the application starts:
console.log("Node.js version:", process.version);
For a running deployment, check the runtime configuration and the actual version inside the container or execution environment.
An application may use one Node.js version locally and another in production. Verify each environment separately.
How to Update Node.js Safely
Updating Node.js is the primary remediation for this vulnerability. Input validation is also important, but it should not replace the security update.
Update a Local Installation
If you manage Node.js directly, install a patched version from the appropriate supported release line.
After updating, verify the version:
node --version
Then reinstall or rebuild dependencies when required by your project's setup.
Update a Docker-Based Application
If your application uses Docker, review the base image in the Dockerfile.
For example:
FROM node:22.23.4
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["node", "server.js"]
This example uses the fixed Node.js 22.x version identified in the October 2026 advisory.
For production, prefer a maintained image tag appropriate for your deployment requirements. Pinning an exact version makes the intended runtime explicit, but your team must still update that version when future security fixes become available.
Rebuild and redeploy the image after changing the base image. Updating Node.js on the host does not automatically update an application running in an existing container.
Update CI/CD Configuration
Check your build and deployment configuration for Node.js version declarations. These may appear in workflow files, runtime configuration files, Dockerfiles, or deployment settings.
For example, a GitHub Actions workflow can specify a Node.js version:
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22.23.4"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
The example illustrates version selection and testing. In a production workflow, review action versions and repository policies as part of the normal security process.
Updating the workflow alone is insufficient if the production environment uses a separate runtime configuration.
How to Validate Hostnames in Node.js
Runtime updates should be combined with application-level input validation.
Consider an application that accepts a hostname from a user and checks whether it belongs to an approved list.
A basic allowlist might look like this:
const allowedHosts = new Set([
"api.example.com",
"services.example.com"
]);
function validateHostname(hostname) {
if (typeof hostname !== "string") {
throw new TypeError("Hostname must be a string.");
}
if (hostname.includes("\0")) {
throw new Error("Hostname contains an invalid null byte.");
}
if (!allowedHosts.has(hostname)) {
throw new Error("Hostname is not allowed.");
}
return hostname;
}
This function rejects non-string input, explicitly blocks null bytes, and accepts only exact hostname matches.
The exact-match check is important. A check such as hostname.endsWith("example.com") can accept unintended names if it does not account for hostname boundaries and other normalization rules.
For a fixed list of trusted services, an exact allowlist is often simpler to maintain than a broad hostname pattern.
However, validation alone does not fix a vulnerable Node.js runtime. Update the runtime even if your application already validates hostnames.
Use DNS Resolution After Validation
Once the hostname has passed validation, the application can perform its DNS lookup.
For example:
const dns = require("node:dns");
async function resolveApprovedHost(hostname) {
const validatedHostname = validateHostname(hostname);
return await dns.promises.resolve4(
validatedHostname
);
}
This function resolves IPv4 records for an approved hostname.
It is important to understand what the function does not guarantee. A successful DNS lookup does not establish that the destination is safe, and DNS records can change over time. If the application uses the result to enforce network access restrictions, it may also need to validate the resolved addresses and control the destination used by the subsequent connection.
For security-sensitive applications, consider the complete request path rather than treating hostname validation as the only security check.
Common Mistakes to Avoid
Updating Only the Development Machine
A developer may install a fixed version locally while leaving a production container on an affected version.
Check every runtime environment, including CI runners, staging deployments, production containers, and background workers.
Assuming Dependency Updates Fix the Runtime
Running npm update does not necessarily update Node.js itself. The runtime is managed separately from most application dependencies.
Update the Node.js installation or base image, then verify the runtime actually used by the application.
Relying Only on Input Validation
Rejecting null bytes and checking hostnames against an allowlist are useful defensive measures. They do not replace patching the vulnerable DNS implementation.
Accepting Partial Hostname Matches
Broad string checks can accidentally accept hostnames outside the intended domain. Prefer exact allowlists where practical, and define clear normalization rules when dynamic subdomains are required.
Skipping Regression Tests
Runtime updates can expose compatibility issues in applications and dependencies. Run the project's tests before deploying the updated runtime.
Best Practices for Production Applications
Keep Node.js on a supported release line and monitor security advisories for the runtime and its bundled dependencies.
Use automated dependency and runtime checks in CI/CD so that outdated versions are detected before deployment. For containerized applications, rebuild images from patched base images and verify the resulting runtime version.
Validate hostnames at the application boundary, reject malformed input, and avoid relying on string matching alone to enforce network access restrictions.
For applications that connect to user-controlled destinations, review DNS resolution, redirects, proxy settings, and destination IP addresses as part of the security design. Hostname validation and DNS resolution must work together with the application's network access policy.
Finally, maintain a clear update process that includes testing, deployment verification, and rollback planning. Security fixes should be applied promptly, but production changes should still follow a controlled release process.
Advantages and Disadvantages of Updating Node.js
Advantages
Addresses the known DNS vulnerability in the affected runtime.
Includes other security fixes bundled in the relevant release.
Reduces exposure to known runtime-level security issues.
Encourages consistent runtime management across environments.
Disadvantages
Runtime updates may reveal compatibility issues in application dependencies.
Docker images and CI/CD configurations may require changes.
Regression testing and deployment verification require engineering time.
Older applications may need additional work before moving to a supported release line.
These costs are reasons to plan updates carefully, not reasons to postpone security fixes indefinitely.
Summary
The Node.js DNS vulnerability CVE-2026-105482 can cause DNS resolution functions to truncate hostnames containing a null byte. This becomes a security concern when an application validates one hostname but the runtime resolves a different name.
The appropriate response is to update affected Node.js installations to a fixed, supported version, verify the runtime used in every deployment environment, and test the application after upgrading.
Developers should also reject malformed hostnames, use exact allowlists where appropriate, and review how resolved addresses are used for network connections.
Keeping the runtime patched and validating untrusted input at the application boundary provides a stronger defense than relying on either measure alone.
Join the conversation! Your thoughts help the community grow.