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

admin 2021年12月16日16:00:57评论136 views字数 4768阅读15分53秒阅读模式

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;
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;

}

bad Java

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

trusted = true;

}

bad C#

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

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);
h=gethostbyname(inet_ntoa(cliAddr.sin_addr));
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);
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);

}

}

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. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2001-1488
CVE-2001-1500 Does not verify reverse-resolved hostnames in DNS. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2001-1500
CVE-2000-1221 Authentication bypass using spoofed reverse-resolved DNS hostnames. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2000-1221
CVE-2002-0804 Authentication bypass using spoofed reverse-resolved DNS hostnames. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0804
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. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2001-1155
CVE-2004-0892 Reverse DNS lookup used to spoof trusted content in intermediary. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-0892
CVE-2003-0981 Product records the reverse DNS name of a visitor in the logs, allowing spoofing and resultant XSS. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-0981

Notes

分类映射

映射的分类名 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

引用

文章来源于互联网:scap中文网

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月16日16:00:57
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CWE-350 不恰当地信任反向DNShttp://cn-sec.com/archives/613169.html

发表评论

匿名网友 填写信息