CWE-350 不恰当地信任反向DNS

Reliance on Reverse DNS Resolution for a Security-Critical Action

结构: Simple

Abstraction: Variant

状态: Draft

被利用可能性: unkown


The software performs reverse DNS resolution on an IP address to obtain the hostname and make a security decision, but it does not properly ensure that the IP address is truly associated with the hostname.


Since DNS names can be easily spoofed or misreported, and it may be difficult for the software to detect if a trusted DNS server has been compromised, DNS names do not constitute a valid authentication mechanism.

When the software performs a reverse DNS resolution for an IP address, if an attacker controls the server for that IP address, then the attacker can cause the server to return an arbitrary hostname. As a result, the attacker may be able to bypass authentication, cause the wrong hostname to be recorded in log files to hide activities, or perform other attacks.

Attackers can spoof DNS names by either (1) compromising a DNS server and modifying its records (sometimes called DNS cache poisoning), or (2) having legitimate control over a DNS server associated with their IP address.


  • cwe_Nature: ChildOf cwe_CWE_ID: 290 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 290 cwe_View_ID: 699 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 923 cwe_View_ID: 1000

  • cwe_Nature: ChildOf cwe_CWE_ID: 807 cwe_View_ID: 1000

  • cwe_Nature: CanPrecede cwe_CWE_ID: 923 cwe_View_ID: 1000


Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}


范围 影响 注释
Access Control ['Gain Privileges or Assume Identity', 'Bypass Protection Mechanism'] Malicious users can fake authentication information by providing false DNS information.


Architecture and Design


Use other means of identity verification that cannot be simply spoofed. Possibilities include a username/password or certificate.

MIT-42 Implementation


Perform proper forward and reverse DNS lookups to detect DNS spoofing.


The following code samples use a DNS lookup in order to decide whether or not an inbound request is from a trusted host.

bad C

struct hostent hp;struct in_addr myaddr;
tHost = "";

hp = gethostbyaddr((char *) &myaddr, sizeof(struct in_addr), AF_INET);
if (hp && !strncmp(hp->h_name, tHost, sizeof(tHost))) {
trusted = true;
} else {
trusted = false;

bad Java

String ip = request.getRemoteAddr();
InetAddress addr = InetAddress.getByName(ip);
if (addr.getCanonicalHostName().endsWith("")) {
trusted = true;

bad C#

IPAddress hostIPAddress = IPAddress.Parse(RemoteIpAddress);
IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
if (hostInfo.HostName.EndsWith("")) {
trusted = true;

If an attacker can poison the DNS cache, they can gain trusted status.

In these examples, a connection is established if a request is made by a trusted host.

bad C

sd = socket(AF_INET, SOCK_DGRAM, 0);
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = htonl(INADDR_ANY);
servr.sin_port = htons(1008);
bind(sd, (struct sockaddr ) & serv, sizeof(serv));
while (1) {

memset(msg, 0x0, MAX_MSG);
clilen = sizeof(cli);
if (h->h_name==...) n = recvfrom(sd, msg, MAX_MSG, 0, (struct sockaddr
) & cli, &clilen);

bad Java

while(true) {
DatagramPacket rp=new DatagramPacket(rData,rData.length);
String in = new String(p.getData(),0, rp.getLength());
InetAddress IPAddress = rp.getAddress();
int port = rp.getPort();
if ((rp.getHostName()==...) & (in==...)) {

out = secret.getBytes();
DatagramPacket sp =new DatagramPacket(out,out.length, IPAddress, port);

These examples check if a request is from a trusted host before responding to a request, but the code only verifies the hostname as stored in the request packet. An attacker can spoof the hostname, thus impersonating a trusted client.


标识 说明 链接
CVE-2001-1488 Does not do double-reverse lookup to prevent DNS spoofing.
CVE-2001-1500 Does not verify reverse-resolved hostnames in DNS.
CVE-2000-1221 Authentication bypass using spoofed reverse-resolved DNS hostnames.
CVE-2002-0804 Authentication bypass using spoofed reverse-resolved DNS hostnames.
CVE-2001-1155 Filter does not properly check the result of a reverse DNS lookup, which could allow remote attackers to bypass intended access restrictions via DNS spoofing.
CVE-2004-0892 Reverse DNS lookup used to spoof trusted content in intermediary.
CVE-2003-0981 Product records the reverse DNS name of a visitor in the logs, allowing spoofing and resultant XSS.



映射的分类名 ImNode ID Fit Mapped Node Name
PLOVER Improperly Trusted Reverse DNS
CLASP Trusting self-reported DNS name
Software Fault Patterns SFP29 Faulty endpoint authentication


  • CAPEC-142
  • CAPEC-275
  • CAPEC-73
  • CAPEC-89