Bug 12092 - denyhosts new security issue CVE-2013-6890
Summary: denyhosts new security issue CVE-2013-6890
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: Security (show other bugs)
Version: 3
Hardware: i586 Linux
Priority: Normal normal
Target Milestone: ---
Assignee: QA Team
QA Contact: Sec team
URL: http://lwn.net/Vulnerabilities/578015/
Whiteboard: has_procedure mga3-64-ok mga3-32-ok a...
Keywords: validated_update
Depends on:
Blocks:
 
Reported: 2013-12-23 14:32 CET by David Walser
Modified: 2014-02-17 01:34 CET (History)
8 users (show)

See Also:
Source RPM: denyhosts-2.6-7.mga4.src.rpm
CVE:
Status comment:


Attachments

Description David Walser 2013-12-23 14:32:57 CET
Debian has issued an advisory on December 22:
http://www.debian.org/security/2013/dsa-2826

Mageia 3 is also affected.

More info on this is is contained in this thread:
http://openwall.com/lists/oss-security/2013/12/22/4

Note the recommendation to obsolete this package in favor of fail2ban.

Reproducible: 

Steps to Reproduce:
David Walser 2013-12-23 14:33:15 CET

Whiteboard: (none) => MGA3TOO

Comment 1 Johnny A. Solbu 2013-12-23 15:37:39 CET
Fixed and pushed in Cauldron.


Suggested Advisory:
========================

A flaw discovered in denyhosts, a tool preventing SSH brute-force attacks, could be used to perform remote denial of service against the SSH daemon. Incorrectly specified regular expressions used to detect brute force attacks in authentication logs could be exploited by a malicious user to forge crafted login names in order to make denyhosts ban arbitrary IP addresses.

References:
http://openwall.com/lists/oss-security/2013/12/22/4
http://www.debian.org/security/2013/dsa-2826
========================

Updated mageia 3 packages in core/updates_testing:
denyhosts-2.6-4.2.mga3

Source RPM:
denyhosts-2.6-4.2.mga3.src.rpm

Status: NEW => ASSIGNED
URL: (none) => http://openwall.com/lists/oss-security/2013/12/22/4
CC: (none) => cooker
Assignee: cooker => qa-bugs

Comment 2 David Walser 2013-12-23 15:40:04 CET
Thanks Johnny!

Just some minor formatting changes to the advisory.

Advisory:
========================

Updated denyhosts package fixes security vulnerability:

Helmut Grohne discovered that denyhosts, a tool preventing SSH brute-force
attacks, could be used to perform remote denial of service against the SSH
daemon. Incorrectly specified regular expressions used to detect brute force
attacks in authentication logs could be exploited by a malicious user to forge
crafted login names in order to make denyhosts ban arbitrary IP addresses
(CVE-2013-6890).

References:
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-6890
http://www.debian.org/security/2013/dsa-2826

Version: Cauldron => 3
Whiteboard: MGA3TOO => (none)

David Walser 2013-12-23 22:21:57 CET

URL: http://openwall.com/lists/oss-security/2013/12/22/4 => http://lwn.net/Vulnerabilities/578015/

Dave Hodgins 2014-01-02 18:34:01 CET

CC: (none) => davidwhodgins
Whiteboard: (none) => advisory

Comment 3 claire robinson 2014-01-22 18:06:48 CET
Testing mga3 64 

tl;dr - it doesn't seem to close the CVE.

PoC: http://openwall.com/lists/oss-security/2013/12/22/4

Edited /etc/denyhosts.conf and changed DENY_THRESHOLD_INVALID to equal 1 to save time.

Started denyhosts service and then..

Before
------
$ ssh -l 'Invalid user root from 123.123.123.123' localhost
Password: 

Interrupt with ctrl-c and repeat.

then..

# cat /etc/hosts.deny 

#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!

# DenyHosts: Wed Jan 22 16:55:16 2014 | sshd: 123.123.123.123
sshd: 123.123.123.123

showing it has added the faked IP address to /etc/hosts.deny
removed it manually, not sure if there is a proper way.

After
-----
Restarted the service and checked /etc/hosts.deny

Repeated the PoC but checking /etc/hosts.deny it has added it again.

# cat /etc/hosts.deny 

#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!
# DenyHosts: Wed Jan 22 17:02:46 2014 | sshd: 123.123.123.123
sshd: 123.123.123.123

# rpm -q denyhosts
denyhosts-2.6-4.2.mga3

Also it leaves it there when the package is removed.

Whiteboard: advisory => advisory feedback

Comment 4 claire robinson 2014-01-22 18:38:21 CET
rpmdiff shows nothing changed in the rpm Johnny, might be worth checking cauldron too.
Comment 5 David Walser 2014-01-22 18:41:25 CET
Indeed, the patch was added to the package, but not actually applied in the %prep section.  Assigning back to Johnny.

CC: (none) => qa-bugs
Version: 3 => Cauldron
Assignee: qa-bugs => cooker
Whiteboard: advisory feedback => MGA3TOO

Comment 6 Johnny A. Solbu 2014-01-23 02:18:04 CET
(In reply to David Walser from comment #5)
> Indeed, the patch was added to the package, but not actually applied in the
> %prep section.  Assigning back to Johnny.

Gaah.
The patch had to be rediffed, as one of our patches (P10) made it incompatible with P12 from Debian.

Have uploaded a new release in mga3 core/updates_testing:
denyhosts-2.6-4.3.mga3

Source RPM:
denyhosts-2.6-4.3.mga3.src.rpm

Please someone look over the changed patch, to make sure I didn't screw it up by adding a new security hole.
I have renamed P12 slightly (renamed "deb" to "deb-mga") to reflect that the Debian patch is modified my us.

If the patch looks ok, I'll commit and ask for a freeze push to Cauldron also.
Johnny A. Solbu 2014-01-23 02:21:23 CET

Assignee: cooker => qa-bugs

Comment 7 Johnny A. Solbu 2014-01-23 02:26:20 CET
(In reply to Johnny A. Solbu from comment #6)
> The patch had to be rediffed, as one of our patches (P10) made it
> incompatible with P12 from Debian.

Specifically it's the "FAILED_ENTRY_REGEX7" line in the patch that I had to modify to make the patch work. I /think/ I understand the change good enouch to make the required changes to our version of the file. But I'm not a python developer, do I could be wrong. :-)
Comment 8 claire robinson 2014-01-23 08:02:58 CET
Did you check cauldron package too Johnny?
Comment 9 Johnny A. Solbu 2014-01-23 09:27:49 CET
(In reply to claire robinson from comment #8)
> Did you check cauldron package too Johnny?

Yes, and it have the same issue. Which is why I'm waiting a little to see if the rediffed patch looks ok before commiting and asking for a freeze push.
Comment 10 claire robinson 2014-01-23 10:50:29 CET
Testing complete Mga3 64

Set all the thresholds to 1 occurrence.

$ ssh -l 'Invalid user root from 123.123.123.123' localhost

No longer triggers a false set so the potential DoS is fixed.

Tested logins from another computer with false user (ie. ssh xyz@host) which did trigger it and prevents further logins from that host which IINM should test invalid user still works ok. Also tried with root@ which triggered it too.
claire robinson 2014-01-23 10:50:48 CET

Whiteboard: MGA3TOO => MGA3TOO has_procedure mga3-64-ok

Comment 11 claire robinson 2014-01-23 10:52:04 CET
Seems to do the trick Johnny but we can't push this until it has been pushed in cauldron first.
Comment 12 claire robinson 2014-01-23 11:08:14 CET
Testing complete mga3 32

Actually, using the PoC from a remote computer does trigger the blocking but it blocks the correct IP rather than the faked IP, so proves the regex is good.


Advisory already uploaded, now updated.

Validating


Could sysadmin please push to updates only after cauldron freeze push to fix the patching.

Thanks

Keywords: (none) => validated_update
Version: Cauldron => 3
Whiteboard: MGA3TOO has_procedure mga3-64-ok => has_procedure advisory mga3-64-ok mga3-32-ok
CC: (none) => sysadmin-bugs

Comment 13 David Walser 2014-01-23 21:10:44 CET
The fix has been submitted in Cauldron.
Comment 14 David Walser 2014-01-24 14:18:15 CET
Debian has corrected a regression caused by the fix for this on January 23:
https://lists.debian.org/debian-security-announce/2014/msg00018.html

Johnny, you might want to update this again...
Comment 15 Johnny A. Solbu 2014-01-24 18:07:59 CET
(In reply to David Walser from comment #14)
> Debian has corrected a regression caused by the fix for this on January 23:
> https://lists.debian.org/debian-security-announce/2014/msg00018.html
> 
> Johnny, you might want to update this again...

I have uploaded a new release in mga3 core/updates_testing with the new fix:
denyhosts-2.6-4.4.mga3

Source RPM:
denyhosts-2.6-4.4.mga3.src.rpm

Have just asked for a freeze push in Cauldron, too.
Comment 16 David Walser 2014-01-24 18:20:59 CET
Thanks Johnny!  denyhosts-2.6-10.mga4 uploaded for Cauldron.

This will need to be revalidated for Mageia 3.

Keywords: validated_update => (none)
Whiteboard: has_procedure advisory mga3-64-ok mga3-32-ok => has_procedure

Comment 17 Colin Guthrie 2014-02-15 12:56:36 CET
I just tested denyhosts-2.6-4.4.mga3 on mga3-64. As per Claires previous tests, all seems to behave properly (albeit aggressively blocking the machine I was testing from, but then that's kinda the point :p).

CC: (none) => mageia
Whiteboard: has_procedure => has_procedure mga3-64-ok

Comment 18 Malo Deniélou 2014-02-16 15:02:36 CET
Testing mga3-i586.

CC: (none) => pierre-malo.denielou

Comment 19 Malo Deniélou 2014-02-16 15:57:34 CET
I noticed that denyhosts would fail to start properly if sshd is not running. The error message is ugly and not helpful.

Feb 16 14:04:34 localhost denyhosts[13078]: Starting denyhosts: Can't read: /var/log/auth.log
Feb 16 14:04:34 localhost denyhosts[13078]: [Errno 2] No such file or directory: '/var/log/auth.log'
Feb 16 14:04:34 localhost denyhosts[13078]: Error deleting DenyHosts lock file: /var/lock/subsys/denyhosts
Feb 16 14:04:34 localhost denyhosts[13078]: [Errno 2] No such file or directory: '/var/lock/subsys/denyhosts'

Shouldn't there be a service dependency from denyhosts to sshd? As it is, at install, if sshd is running, then denyhosts will run fine. If sshd is not running, then denyhosts will not start automagically when sshd is activated.

On the proper testing, the fix works.

Whiteboard: has_procedure mga3-64-ok => has_procedure mga3-64-ok mga3-32-ok

Comment 20 Rémi Verschelde 2014-02-16 17:48:26 CET
Validating update for the security fix. Another bug report can be used if some fixing is required as per Malo's comment 19.

Advisory has been updated for the latest SRPM (and a mention added regarding the fixed regression). Please push to 3 core/updates.

Keywords: (none) => validated_update
CC: (none) => remi
Whiteboard: has_procedure mga3-64-ok mga3-32-ok => has_procedure mga3-64-ok mga3-32-ok advisory

Comment 21 Thomas Backlund 2014-02-17 01:34:27 CET
Update pushed:
http://advisories.mageia.org/MGASA-2014-0080.html

Status: ASSIGNED => RESOLVED
CC: (none) => tmb
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.