Description
The product 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 product to detect if a trusted DNS server has been compromised, DNS names do not constitute a valid authentication mechanism. When the product performs a reverse DNS resolution for an IP address, if an attacker controls the DNS 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.
Potential Impact
Access Control
Gain Privileges or Assume Identity, Bypass Protection Mechanism
Demonstrative Examples
struct hostent *hp;struct in_addr myaddr;char* tHost = "trustme.example.com";myaddr.s_addr=inet_addr(ip_addr_string);
hp = gethostbyaddr((char *) &myaddr, sizeof(struct in_addr), AF_INET);if (hp && !strncmp(hp->h_name, tHost, sizeof(tHost))) {trusted = true;} else {trusted = false;}String ip = request.getRemoteAddr();InetAddress addr = InetAddress.getByName(ip);if (addr.getCanonicalHostName().endsWith("trustme.com")) {trusted = true;}IPAddress hostIPAddress = IPAddress.Parse(RemoteIpAddress);IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);if (hostInfo.HostName.EndsWith("trustme.com")) {trusted = true;}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);h=gethostbyname(inet_ntoa(cliAddr.sin_addr));if (h->h_name==...) n = recvfrom(sd, msg, MAX_MSG, 0, (struct sockaddr *) & cli, &clilen);
}while(true) {
DatagramPacket rp=new DatagramPacket(rData,rData.length);outSock.receive(rp);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);outSock.send(sp);
}
}Mitigations & Prevention
Use other means of identity verification that cannot be simply spoofed. Possibilities include a username/password or certificate.
Perform proper forward and reverse DNS lookups to detect DNS spoofing.
Detection Methods
- Automated Static Analysis High — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| 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. |
Related Weaknesses
Taxonomy Mappings
- PLOVER: — Improperly Trusted Reverse DNS
- CLASP: — Trusting self-reported DNS name
- Software Fault Patterns: SFP29 — Faulty endpoint authentication
Frequently Asked Questions
What is CWE-350?
CWE-350 (Reliance on Reverse DNS Resolution for a Security-Critical Action) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The product 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 hostn...
How can CWE-350 be exploited?
Attackers can exploit CWE-350 (Reliance on Reverse DNS Resolution for a Security-Critical Action) to gain privileges or assume identity, bypass protection mechanism. This weakness is typically introduced during the Architecture and Design phase of software development.
How do I prevent CWE-350?
Key mitigations include: Use other means of identity verification that cannot be simply spoofed. Possibilities include a username/password or certificate.
What is the severity of CWE-350?
CWE-350 is classified as a Variant-level weakness (Low-Medium abstraction). It has been observed in 7 real-world CVEs.