CVE-2021-22931: Improper Null Termination (CWE-170) in NodeJS Node
Node.js before 16.6.0, 14.17.4, and 12.22.4 is vulnerable to Remote Code Execution, XSS, Application crashes due to missing input validation of host names returned by Domain Name Servers in Node.js dns library which can lead to output of wrong hostnames (leading to Domain Hijacking) and injection vulnerabilities in applications using the library.
AI Analysis
Technical Summary
CVE-2021-22931 is a vulnerability affecting multiple versions of Node.js prior to 16.6.0, 14.17.4, and 12.22.4. The root cause is improper null termination (CWE-170) in the Node.js DNS library, specifically in the handling of hostnames returned by Domain Name Servers (DNS). This flaw results from missing input validation on DNS responses, which can cause the library to output incorrect or malformed hostnames. The improper handling can lead to several security issues including remote code execution (RCE), cross-site scripting (XSS), application crashes, and domain hijacking. The vulnerability arises because maliciously crafted DNS responses can inject unexpected data or control characters into hostname strings, which are then processed by applications relying on the Node.js DNS module. This can allow attackers to manipulate domain resolution results, potentially redirecting traffic, injecting malicious scripts, or causing denial of service through application crashes. The vulnerability affects a broad range of Node.js versions from 4.0 up to 16.0, covering many legacy and current deployments. No public exploits have been reported in the wild to date, but the potential impact is significant due to the widespread use of Node.js in web applications and backend services. The lack of a CVSS score indicates that the vulnerability has not been formally scored, but the technical details and potential attack vectors suggest a serious security concern. The vulnerability requires no authentication but depends on the attacker’s ability to influence DNS responses received by the vulnerable Node.js application. User interaction is not necessarily required, making exploitation feasible in automated or network-based attack scenarios.
Potential Impact
For European organizations, the impact of CVE-2021-22931 can be substantial. Node.js is widely used across Europe in web services, cloud applications, and enterprise backend systems. Exploitation could lead to unauthorized remote code execution, allowing attackers to gain control over affected systems, steal sensitive data, or disrupt services. The possibility of domain hijacking through manipulated DNS responses can undermine trust in corporate domains, leading to phishing, fraud, or data interception. Cross-site scripting vulnerabilities can compromise web application users, potentially exposing personal data or enabling session hijacking. Application crashes caused by this vulnerability can result in denial of service, impacting availability and business continuity. Given the broad range of affected Node.js versions, many organizations running legacy or unpatched systems are at risk. The vulnerability's exploitation does not require user interaction, increasing the likelihood of automated attacks. The absence of known exploits in the wild suggests that proactive patching and mitigation can effectively reduce risk before widespread exploitation occurs.
Mitigation Recommendations
1. Immediate upgrade of Node.js to patched versions 16.6.0 or later, 14.17.4 or later, or 12.22.4 or later is the most effective mitigation. 2. Audit all applications using the Node.js DNS library to identify and isolate components that perform DNS lookups, especially those processing external or untrusted DNS responses. 3. Implement strict input validation and sanitization on all hostname data obtained from DNS queries before use in application logic or output rendering. 4. Employ DNS security extensions (DNSSEC) where possible to validate DNS responses and reduce the risk of DNS spoofing or poisoning attacks. 5. Monitor DNS traffic and application logs for anomalies indicative of DNS manipulation or injection attempts. 6. Use network-level protections such as DNS filtering and firewall rules to restrict access to trusted DNS servers and prevent malicious DNS responses. 7. For web applications, apply Content Security Policy (CSP) headers and other XSS mitigations to reduce the impact of potential script injection. 8. Conduct regular security assessments and penetration testing focusing on DNS-related attack vectors in Node.js environments. These steps go beyond generic patching advice by emphasizing DNS validation, application-level sanitization, and network controls tailored to the nature of this vulnerability.
Affected Countries
Germany, United Kingdom, France, Netherlands, Sweden, Italy, Spain, Poland, Belgium, Ireland
CVE-2021-22931: Improper Null Termination (CWE-170) in NodeJS Node
Description
Node.js before 16.6.0, 14.17.4, and 12.22.4 is vulnerable to Remote Code Execution, XSS, Application crashes due to missing input validation of host names returned by Domain Name Servers in Node.js dns library which can lead to output of wrong hostnames (leading to Domain Hijacking) and injection vulnerabilities in applications using the library.
AI-Powered Analysis
Technical Analysis
CVE-2021-22931 is a vulnerability affecting multiple versions of Node.js prior to 16.6.0, 14.17.4, and 12.22.4. The root cause is improper null termination (CWE-170) in the Node.js DNS library, specifically in the handling of hostnames returned by Domain Name Servers (DNS). This flaw results from missing input validation on DNS responses, which can cause the library to output incorrect or malformed hostnames. The improper handling can lead to several security issues including remote code execution (RCE), cross-site scripting (XSS), application crashes, and domain hijacking. The vulnerability arises because maliciously crafted DNS responses can inject unexpected data or control characters into hostname strings, which are then processed by applications relying on the Node.js DNS module. This can allow attackers to manipulate domain resolution results, potentially redirecting traffic, injecting malicious scripts, or causing denial of service through application crashes. The vulnerability affects a broad range of Node.js versions from 4.0 up to 16.0, covering many legacy and current deployments. No public exploits have been reported in the wild to date, but the potential impact is significant due to the widespread use of Node.js in web applications and backend services. The lack of a CVSS score indicates that the vulnerability has not been formally scored, but the technical details and potential attack vectors suggest a serious security concern. The vulnerability requires no authentication but depends on the attacker’s ability to influence DNS responses received by the vulnerable Node.js application. User interaction is not necessarily required, making exploitation feasible in automated or network-based attack scenarios.
Potential Impact
For European organizations, the impact of CVE-2021-22931 can be substantial. Node.js is widely used across Europe in web services, cloud applications, and enterprise backend systems. Exploitation could lead to unauthorized remote code execution, allowing attackers to gain control over affected systems, steal sensitive data, or disrupt services. The possibility of domain hijacking through manipulated DNS responses can undermine trust in corporate domains, leading to phishing, fraud, or data interception. Cross-site scripting vulnerabilities can compromise web application users, potentially exposing personal data or enabling session hijacking. Application crashes caused by this vulnerability can result in denial of service, impacting availability and business continuity. Given the broad range of affected Node.js versions, many organizations running legacy or unpatched systems are at risk. The vulnerability's exploitation does not require user interaction, increasing the likelihood of automated attacks. The absence of known exploits in the wild suggests that proactive patching and mitigation can effectively reduce risk before widespread exploitation occurs.
Mitigation Recommendations
1. Immediate upgrade of Node.js to patched versions 16.6.0 or later, 14.17.4 or later, or 12.22.4 or later is the most effective mitigation. 2. Audit all applications using the Node.js DNS library to identify and isolate components that perform DNS lookups, especially those processing external or untrusted DNS responses. 3. Implement strict input validation and sanitization on all hostname data obtained from DNS queries before use in application logic or output rendering. 4. Employ DNS security extensions (DNSSEC) where possible to validate DNS responses and reduce the risk of DNS spoofing or poisoning attacks. 5. Monitor DNS traffic and application logs for anomalies indicative of DNS manipulation or injection attempts. 6. Use network-level protections such as DNS filtering and firewall rules to restrict access to trusted DNS servers and prevent malicious DNS responses. 7. For web applications, apply Content Security Policy (CSP) headers and other XSS mitigations to reduce the impact of potential script injection. 8. Conduct regular security assessments and penetration testing focusing on DNS-related attack vectors in Node.js environments. These steps go beyond generic patching advice by emphasizing DNS validation, application-level sanitization, and network controls tailored to the nature of this vulnerability.
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- hackerone
- Date Reserved
- 2021-01-06T00:00:00
- Cisa Enriched
- true
- Cvss Version
- null
- State
- PUBLISHED
Threat ID: 682d983ac4522896dcbed453
Added to database: 5/21/2025, 9:09:14 AM
Last enriched: 6/25/2025, 2:33:24 PM
Last updated: 2/7/2026, 11:58:04 AM
Views: 55
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Related Threats
CVE-2026-2084: OS Command Injection in D-Link DIR-823X
HighCVE-2026-2083: SQL Injection in code-projects Social Networking Site
MediumCVE-2026-2082: OS Command Injection in D-Link DIR-823X
MediumCVE-2026-2080: Command Injection in UTT HiPER 810
HighCVE-2026-2079: Improper Authorization in yeqifu warehouse
MediumActions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console in Console -> Billing for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.