Bug 75714 (CVE-2005-0877)

Summary: VUL-0: CVE-2005-0877: dnsmasq cache poisoning&DoS
Product: [Novell Products] SUSE Security Incidents Reporter: Ludwig Nussel <lnussel>
Component: IncidentsAssignee: Security Team bot <security-team>
Status: RESOLVED FIXED QA Contact: Security Team bot <security-team>
Severity: Normal    
Priority: P5 - None CC: security-team
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: All   
Whiteboard: CVE-2005-0877: CVSS v2 Base Score: 5.0 (AV:N/AC:L/Au:N/C:N/I:P/A:N)
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Ludwig Nussel 2005-04-04 12:12:08 UTC
We received the following report via full-disclosure.
The issue is public.

Date: Mon, 04 Apr 2005 13:38:37 +0200
From: Thierry Carrez <koon@gentoo.org>
To: gentoo-announce@robin.gentoo.org
Cc: full-disclosure@lists.grok.org.uk, bugtraq@securityfocus.com,
	security-alerts@linuxsecurity.com
Subject: [Full-disclosure] [ GLSA 200504-03 ] Dnsmasq: Poisoning and Denial
	of Service vulnerabilities

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Gentoo Linux Security Advisory                           GLSA 200504-03
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                            http://security.gentoo.org/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  Severity: Low
     Title: Dnsmasq: Poisoning and Denial of Service vulnerabilities
      Date: April 04, 2005
      Bugs: #86718
        ID: 200504-03

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Synopsis
========

Dnsmasq is vulnerable to DNS cache poisoning attacks and a potential
Denial of Service from the local network.

Background
==========

Dnsmasq is a lightweight and easily-configurable DNS forwarder and DHCP
server.

Affected packages
=================

    -------------------------------------------------------------------
     Package          /  Vulnerable  /                      Unaffected
    -------------------------------------------------------------------
  1  net-dns/dnsmasq       < 2.22                              >= 2.22

Description
===========

Dnsmasq does not properly detect that DNS replies received do not
correspond to any DNS query that was sent. Rob Holland of the Gentoo
Linux Security Audit team also discovered two off-by-one buffer
overflows that could crash DHCP lease files parsing.

Impact
======

A remote attacker could send malicious answers to insert arbitrary DNS
data into the Dnsmasq cache. These attacks would in turn help an
attacker to perform man-in-the-middle and site impersonation attacks.
The buffer overflows might allow an attacker on the local network to
crash Dnsmasq upon restart.

Workaround
==========

There is no known workaround at this time.

Resolution
==========

All Dnsmasq users should upgrade to the latest version:

    # emerge --sync
    # emerge --ask --oneshot --verbose ">=net-dns/dnsmasq-2.22"

References
==========

  [ 1 ] Dnsmasq Changelog
        http://www.thekelleys.org.uk/dnsmasq/CHANGELOG

Availability
============

This GLSA and any updates to it are available for viewing at
the Gentoo Security Website:

  http://security.gentoo.org/glsa/glsa-200504-03.xml

Concerns?
=========

Security is a primary focus of Gentoo Linux and ensuring the
confidentiality and security of our users machines is of utmost
importance to us. Any security concerns should be addressed to
security@gentoo.org or alternatively, you may file a bug at
http://bugs.gentoo.org.

License
=======

Copyright 2005 Gentoo Foundation, Inc; referenced text
belongs to its owner(s).

The contents of this document are licensed under the
Creative Commons - Attribution / Share Alike license.

http://creativecommons.org/licenses/by-sa/2.0




_______________________________________________
Full-Disclosure - We believe in it.
Charter: http://lists.grok.org.uk/full-disclosure-charter.html
Hosted and sponsored by Secunia - http://secunia.com/
Comment 1 Uwe Gansert 2005-04-06 08:40:55 UTC
The Buffer overflow does not exist in SUSE Linux 9.2 and I'll fix it for 9.3 
 
The poisoning bug is very theoretical because you have to guess a 16Bit value 
in a very short time frame and the fix would make this a 48Bit value which is 
just harder to guess.  
I talked to the Author of dnsmasq about this and he has the same opinion, that 
this bug is not too important to fix for older versions (quote: "My opinion is 
that this is not a security hole that that needs a backport") 
 
So after talking to Ludwig, I'll fix the buffer overflow for 9.3 only. 
 
Comment 2 Ludwig Nussel 2005-04-06 08:44:53 UTC
SM-Tracker-833 
Comment 3 Uwe Gansert 2005-04-06 09:37:52 UTC
package for 9.3 submitted 
 
 
Comment 4 Ludwig Nussel 2005-04-06 12:27:49 UTC
Can this bug actually be triggered? According to the patch you made it's a 
wrong length in fscanf (257 instead of 256). The file that is read is written 
by the daemon itself. AFAICS the same buffer of 257 chars is used also for 
creating the records that are later written to disk so the string read from 
the file can never be longer than 256 characters. 
Comment 5 Uwe Gansert 2005-04-06 12:39:51 UTC
I did not look too close to the fix but I got it directly from the author. 
The buffer overflow is documented as "The buffer overflows might allow an 
attacker on the local network to crash Dnsmasq upon restart." so I think it 
can be triggered somehow but I don't have an exploit at hand. 
 
 
 
Comment 6 Thomas Biege 2005-04-08 10:23:27 UTC
The cache poisoning attack can be executed very easily and the time-window can 
be increased by the attacker by stopping the queried DNS to answer. 
 
The poisoning can be done from remote, right? 
 
I would suggest to include this patch as part of our distributed package. 
(Even if the new solution is not perfect but the best for the environment 
and purpose of dnsmasq.) 
Comment 7 Uwe Gansert 2005-04-08 10:28:16 UTC
> The cache poisoning attack can be executed very easily and the time-window  
> can be increased by the attacker by stopping the queried DNS to answer.   
  
how can an attacker stop the queried DNS to answer?  
And without sniffing the network, how can the poisoning be done very easily?  
I don't see this but maybe I overlooked something.  
  
 
Comment 8 Thomas Biege 2005-04-08 11:46:24 UTC
You can stop or slow down the queried DNS server by overloading it with lots 
of recursive queries or by using one of the various ordinary denial-of-service 
techniques. 
 
The attacker only needs to send a continues stream of packets (2^15 on 
average) till he hits the right transaction ID. There is not much effort 
needed. Just a bit of time and luck. 
 
If I assume a target bandwidth of 100 KByte/s and a DNS response package size 
of about 300 bytes the attacker needs less then 100 seconds to send all 2^15 
packages. 
 
The bar for making this attack happen is too low in versions prior 2.22 to 
make me feel comfortable. 
 
 
Comment 9 Uwe Gansert 2005-04-08 14:09:08 UTC
okay, I saw that scenario too but I did not think it has a practical relevance 
for an environment where dnsmasq is used.  
Just out of curiosity. Don't we have a problem with nearly all nameservers 
then? Including the resolver of the glibc? AFAIK at least bind 9.2.1 uses 
16Bit query IDs to protect himself against spoofed answers. But I don't know 
if they changed it after 9.2.1 
 
 
Comment 10 Thomas Biege 2005-04-08 14:25:15 UTC
16bit is the standardized size for the transaction ID. 
 
If other solutions only make use of the ID they have the same problem. 
They should use a random port which doubles the bits to guess. 
so: 100 sec * 2^15 about 38 days. :) 
 
AFAIK BIND does so. 
 
 
Comment 11 Thomas Biege 2005-04-08 14:26:46 UTC
oh.. * 2^16 I think. 76 days therefore. 
Comment 12 Uwe Gansert 2005-04-11 08:30:30 UTC
can't one scan for an open UDP port instead of sending all packages to all 
ports? An UDP package to a closed port should send an ICMP package doesn't it? 
 
Anyway. I think for the version on 9.3 (2.20) it's possible to port the 
poisoning fix but for 2.13 on the 9.2 it might be a little bit too much what 
do you think? 
 
But I still have the opinion, that the fix is not necessary for the 
environment where dnsmasq is used (answers queries only to a small local 
network and the ISP dns has to be knocked down to poison the cache) but I'm 
not a security guy as you can see :) 
 
 
 
Comment 13 Thomas Biege 2005-04-11 10:08:30 UTC
- scanning may be more expensive because: 
  + sending a 300 byte DNS package with poisoning data to an port seems 
    faster then just sending an arbitrary UDP packet, waiting for an response, 
    evaluate it, an then send the DNS poisoning package 
 
  Every query gets its own random port. dnsmasq seems to use a fixed port for 
  this (32851/UDP). 
 
- I do not know if it is much work to backport the patch. Please ask the PM 
  for a version upgrade if you think it's too much. 
 
- The attack is too easy to accomplish and is therefore even dangerous for 
  home users. Think about all the man-in-the-middle attacks possible with 
  SSL and SSH. :( 
 
 
Comment 14 Thomas Biege 2005-04-11 10:13:12 UTC
Scanning: If you limit the attack to just open UDP ports it may be faster. 
That is right. 
Comment 15 Ludwig Nussel 2005-04-11 10:20:35 UTC
aj already said ok to the version update so lets just do it. 
Comment 16 Uwe Gansert 2005-04-11 14:03:07 UTC
version update for 9.2 and 9.3 in /work/src/done/... 
 
 
Comment 17 Thomas Biege 2005-04-11 14:37:23 UTC
Thank you Uwe. 
 
I'll handle the patchinfo files and a like. 
Comment 18 Thomas Biege 2005-04-11 14:51:48 UTC
/work/src/done/PATCHINFO/dnsmasq.patch.box 
Comment 19 Thomas Biege 2005-04-11 14:52:43 UTC
CAN-2005-0876 
CAN-2005-0877 
Comment 20 Thomas Biege 2005-04-14 06:27:50 UTC
packages released
Comment 21 Thomas Biege 2009-10-13 21:15:56 UTC
CVE-2005-0877: CVSS v2 Base Score: 5.0 (AV:N/AC:L/Au:N/C:N/I:P/A:N)