Debian Bug report logs -
#403075
cryptsetup luksOpen can kill unrelated processes (out of memory killer)
Reported by: Rob Walker <rob@tenfoot.org.uk>
Date: Thu, 14 Dec 2006 14:18:01 UTC
Severity: normal
Tags: moreinfo
Found in version cryptsetup/2:1.0.4-8
Fixed in version cryptsetup/2:1.0.4+svn26-1
Done: Jonas Meurer <mejo@debian.org>
Bug is archived. No further changes may be made.
Toggle useless messages
Report forwarded to debian-bugs-dist@lists.debian.org, Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>:
Bug#403075; Package cryptsetup.
(full text, mbox, link).
Acknowledgement sent to Rob Walker <rob@tenfoot.org.uk>:
New Bug report received and forwarded. Copy sent to Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: cryptsetup
Version: 2:1.0.4-8
Severity: grave
Tags: security
Justification: user security hole
If I run cryptsetup luksOpen, giving it a file instead of a device, it tries
to allocate lots of memory, eventually triggering the oomkiller to kill
processes.
A normal user can do this, so this could be used for some kind of
denial of service attack: system performance will be impaired and processes of
other users may be killed. Hence the grave serverity.
To reproduce
# produce a dummy file
dd if=/dev/zero of=/tmp/foo bs=1k count=1024
# try to run cryptsetup
/sbin/cryptsetup luksOpen /tmp/foo /dev/mapper/_tmp_foo
The user will be prompted for a password. After entering it, the system
freezes until the oomkiller kills cryptsetup.
Regards
Rob
-- System Information:
Debian Release: 4.0
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-3-686
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Versions of packages cryptsetup depends on:
ii dmsetup 2:1.02.08-1 The Linux Kernel Device Mapper use
ii libc6 2.3.6.ds1-8 GNU C Library: Shared libraries
ii libdevma 2:1.02.08-1 The Linux Kernel Device Mapper use
ii libgcryp 1.2.3-2 LGPL Crypto library - runtime libr
ii libgpg-e 1.4-1 library for common error values an
ii libpopt0 1.10-3 lib for parsing cmdline parameters
ii libuuid1 1.39+1.40-WIP-2006.11.14+dfsg-1 universally unique id library
cryptsetup recommends no packages.
-- no debconf information
Information forwarded to debian-bugs-dist@lists.debian.org, Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>:
Bug#403075; Package cryptsetup.
(full text, mbox, link).
Acknowledgement sent to David Härdeman <david@hardeman.nu>:
Extra info received and forwarded to list. Copy sent to Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #10 received at 403075@bugs.debian.org (full text, mbox, reply):
severity 403075 normal
tags 403075 -security
tags 403075 +moreinfo
thanks
On Thu, Dec 14, 2006 at 01:46:33PM +0000, Rob Walker wrote:
>Package: cryptsetup
>Version: 2:1.0.4-8
>Severity: grave
>Tags: security
>Justification: user security hole
>
>If I run cryptsetup luksOpen, giving it a file instead of a device, it tries
>to allocate lots of memory, eventually triggering the oomkiller to kill
>processes.
>
>A normal user can do this, so this could be used for some kind of
>denial of service attack: system performance will be impaired and processes of
>other users may be killed. Hence the grave serverity.
Ehh..any user can run a process which uses any amount of memory
unless you use ulimit.
I agree this would be a bug in crypsetup, but calling it a user security
hole is not correct.
>To reproduce
>
> # produce a dummy file
> dd if=/dev/zero of=/tmp/foo bs=1k count=1024
>
> # try to run cryptsetup
> /sbin/cryptsetup luksOpen /tmp/foo /dev/mapper/_tmp_foo
The first argument after luksOpen should be a device, the second should
be a mapping name.
/tmp/foo is no device, it's a file.
/dev/mapper/_tmp_foo is no mapping name, it's a complete path.
The correct syntax would be something like:
/sbin/cryptsetup luksOpen /dev/something tmpfoo
Furthermore, I can't reproduce this (using the version currently in unstable):
# dd if=/dev/zero of=/tmp/foo bs=1k count=1024
# losetup -f /tmp/foo
# crypsetup luksOpen /dev/loop0 tmpfoo
# Enter LUKS passphrase:
# /dev/loop0 is not a LUKS partition
# cryptsetup luksFormat /dev/loop0
WARNING!
========
This will overwrite data on /dev/loop0 irrevocably.
Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase:
Verify passphrase:
Command successful.
# cryptsetup luksOpen /dev/loop0 footmp
Enter LUKS passphrase:
key slot 0 unlocked.
Command successful.
# ls -al /dev/mapper/footmp
brw-rw---- 1 root disk 254, 3 2006-12-14 19:14 /dev/mapper/footmp
# cryptsetup remove footmp
# losetup -d /dev/loop0
--
David Härdeman
Severity set to `normal' from `grave'
Request was from David Härdeman <david@hardeman.nu>
to control@bugs.debian.org.
(full text, mbox, link).
Tags removed: security
Request was from David Härdeman <david@hardeman.nu>
to control@bugs.debian.org.
(full text, mbox, link).
Tags added: moreinfo
Request was from David Härdeman <david@hardeman.nu>
to control@bugs.debian.org.
(full text, mbox, link).
Information forwarded to debian-bugs-dist@lists.debian.org, Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>:
Bug#403075; Package cryptsetup.
(full text, mbox, link).
Acknowledgement sent to "Rob Walker" <rob@tenfoot.org.uk>:
Extra info received and forwarded to list. Copy sent to Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #21 received at 403075@bugs.debian.org (full text, mbox, reply):
> >A normal user can do this, so this could be used for some kind of
> >denial of service attack: system performance will be impaired and processes of
> >other users may be killed. Hence the grave serverity.
>
> Ehh..any user can run a process which uses any amount of memory
> unless you use ulimit.
>
> I agree this would be a bug in crypsetup, but calling it a user security
> hole is not correct.
>
Fair enough
> >To reproduce
> >
> > # produce a dummy file
> > dd if=/dev/zero of=/tmp/foo bs=1k count=1024
> >
> > # try to run cryptsetup
> > /sbin/cryptsetup luksOpen /tmp/foo /dev/mapper/_tmp_foo
>
> The first argument after luksOpen should be a device, the second should
> be a mapping name.
>
> /tmp/foo is no device, it's a file.
>
> /dev/mapper/_tmp_foo is no mapping name, it's a complete path.
>
> The correct syntax would be something like:
> /sbin/cryptsetup luksOpen /dev/something tmpfoo
>
I know the syntax to the cryptsetup command I gave is incorrect, but
crypt setup should catch such errors and print a useful warning
message rather than lock up the system
>
> Furthermore, I can't reproduce this (using the version currently in unstable):
>
> # dd if=/dev/zero of=/tmp/foo bs=1k count=1024
> # losetup -f /tmp/foo
> # crypsetup luksOpen /dev/loop0 tmpfoo
> # Enter LUKS passphrase:
> # /dev/loop0 is not a LUKS partition
> # cryptsetup luksFormat /dev/loop0
>
> WARNING!
> ========
> This will overwrite data on /dev/loop0 irrevocably.
>
> Are you sure? (Type uppercase yes): YES
> Enter LUKS passphrase:
> Verify passphrase:
> Command successful.
> # cryptsetup luksOpen /dev/loop0 footmp
> Enter LUKS passphrase:
> key slot 0 unlocked.
> Command successful.
> # ls -al /dev/mapper/footmp
> brw-rw---- 1 root disk 254, 3 2006-12-14 19:14 /dev/mapper/footmp
> # cryptsetup remove footmp
> # losetup -d /dev/loop0
>
>
Yes, these commands work OK. I only discovered the bug when I made a
mistake in experimenting with cryptsetup
Regards
Rob
Information forwarded to debian-bugs-dist@lists.debian.org, Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>:
Bug#403075; Package cryptsetup.
(full text, mbox, link).
Acknowledgement sent to David Härdeman <david@hardeman.nu>:
Extra info received and forwarded to list. Copy sent to Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #26 received at 403075@bugs.debian.org (full text, mbox, reply):
On Thu, Dec 14, 2006 at 11:08:26PM +0000, Rob Walker wrote:
>>The correct syntax would be something like:
>>/sbin/cryptsetup luksOpen /dev/something tmpfoo
>>
>I know the syntax to the cryptsetup command I gave is incorrect, but
>crypt setup should catch such errors and print a useful warning
>message rather than lock up the system
>
>>
>>Furthermore, I can't reproduce this (using the version currently in
>>unstable):
<snip>
>>...
>Yes, these commands work OK. I only discovered the bug when I made a
>mistake in experimenting with cryptsetup
Problem is I can't reproduce the bug with your commands either
(executing them as a regular user):
(david@austin:~)$ dd if=/dev/zero of=/tmp/foo bs=1k count=1024
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 0.0060463 seconds, 173 MB/s
(david@austin:~)$ /sbin/cryptsetup luksOpen /tmp/foo /dev/mapper/_tmp_foo
Enter LUKS passphrase:
/tmp/foo is not a LUKS partition
Enter LUKS passphrase:
/tmp/foo is not a LUKS partition
Enter LUKS passphrase:
/tmp/foo is not a LUKS partition
Command failed: No key available with this passphrase.
(david@austin:~)$
Are you able to reproduce the error with the version of cryptsetup that
is currently in unstable?
--
David Härdeman
Information forwarded to debian-bugs-dist@lists.debian.org, Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>:
Bug#403075; Package cryptsetup.
(full text, mbox, link).
Acknowledgement sent to Rob Walker <rob@tenfoot.org.uk>:
Extra info received and forwarded to list. Copy sent to Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #31 received at 403075@bugs.debian.org (full text, mbox, reply):
> Problem is I can't reproduce the bug with your commands either
> (executing them as a regular user):
>
> (david@austin:~)$ dd if=/dev/zero of=/tmp/foo bs=1k count=1024
> 1024+0 records in
> 1024+0 records out
> 1048576 bytes (1.0 MB) copied, 0.0060463 seconds, 173 MB/s
> (david@austin:~)$ /sbin/cryptsetup luksOpen /tmp/foo /dev/mapper/_tmp_foo
> Enter LUKS passphrase:
> /tmp/foo is not a LUKS partition
> Enter LUKS passphrase:
> /tmp/foo is not a LUKS partition
> Enter LUKS passphrase:
> /tmp/foo is not a LUKS partition
> Command failed: No key available with this passphrase.
>
> (david@austin:~)$
>
> Are you able to reproduce the error with the version of cryptsetup that
> is currently in unstable?
I can reproduce the bug using the cryptsetup from unstable. I've also tried
it on another machine with the same results.
The unrelated process killing only seems to happen when I try it as root;
running as a regular user usually only kills cryptsetup.
Regards
Rob
Information forwarded to debian-bugs-dist@lists.debian.org, Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>:
Bug#403075; Package cryptsetup.
(full text, mbox, link).
Acknowledgement sent to David Härdeman <david@hardeman.nu>:
Extra info received and forwarded to list. Copy sent to Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #36 received at 403075@bugs.debian.org (full text, mbox, reply):
On Tue, Dec 19, 2006 at 10:07:25PM +0000, Rob Walker wrote:
>> Problem is I can't reproduce the bug with your commands either
>> (executing them as a regular user):
>>
>> (david@austin:~)$ dd if=/dev/zero of=/tmp/foo bs=1k count=1024
>> 1024+0 records in
>> 1024+0 records out
>> 1048576 bytes (1.0 MB) copied, 0.0060463 seconds, 173 MB/s
>> (david@austin:~)$ /sbin/cryptsetup luksOpen /tmp/foo /dev/mapper/_tmp_foo
>> Enter LUKS passphrase:
>> /tmp/foo is not a LUKS partition
>> Enter LUKS passphrase:
>> /tmp/foo is not a LUKS partition
>> Enter LUKS passphrase:
>> /tmp/foo is not a LUKS partition
>> Command failed: No key available with this passphrase.
>>
>> (david@austin:~)$
>>
>> Are you able to reproduce the error with the version of cryptsetup that
>> is currently in unstable?
>
>I can reproduce the bug using the cryptsetup from unstable. I've also tried
>it on another machine with the same results.
Ok, could you then provide me with the exact steps that you took to
reproduce it cause so far I haven't managed to do so.
--
David Härdeman
Information forwarded to debian-bugs-dist@lists.debian.org, Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>:
Bug#403075; Package cryptsetup.
(full text, mbox, link).
Acknowledgement sent to Rob Walker <rob@tenfoot.org.uk>:
Extra info received and forwarded to list. Copy sent to Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #41 received at 403075@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
> >>
> >> Are you able to reproduce the error with the version of cryptsetup that
> >> is currently in unstable?
> >
> >I can reproduce the bug using the cryptsetup from unstable. I've also
> > tried it on another machine with the same results.
>
> Ok, could you then provide me with the exact steps that you took to
> reproduce it cause so far I haven't managed to do so.
I think I've found the problem. In lib/utils.c, the sector_size function is
this:
static int sector_size(int fd)
{
int bsize;
ioctl(fd,BLKSSZGET, &bsize);
return bsize;
}
For a file, the ioctl will fail. Since bsize is not initialized, it's value
will be random (when I ran it under gdb, I got several million) and as this
value will later be used to allocate a buffer, this explains the runaway
memory allocation I saw, but you didn't.
The attached patch checks the return code from ioctl and returns -EINVAL if it
fails. The users of sector_size are also changed to abort if sector_size
returns a negative value.
With this patch applied, I get the appropriate error messages from cryptsetup
if I give it a file instead of a block device.
Regards
Rob
[cryptsetup_sector_size_error.patch (text/x-diff, attachment)]
Information forwarded to debian-bugs-dist@lists.debian.org, Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>:
Bug#403075; Package cryptsetup.
(full text, mbox, link).
Acknowledgement sent to David Härdeman <david@hardeman.nu>:
Extra info received and forwarded to list. Copy sent to Debian Cryptsetup Team <pkg-cryptsetup-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #46 received at 403075@bugs.debian.org (full text, mbox, reply):
On Wed, December 20, 2006 11:32, Rob Walker said:
>> >I can reproduce the bug using the cryptsetup from unstable. I've also
>> > tried it on another machine with the same results.
>>
>> Ok, could you then provide me with the exact steps that you took to
>> reproduce it cause so far I haven't managed to do so.
>
>
> I think I've found the problem. In lib/utils.c, the sector_size function
> is
> this:
>
> static int sector_size(int fd)
> {
> int bsize;
> ioctl(fd,BLKSSZGET, &bsize);
> return bsize;
> }
>
>
> For a file, the ioctl will fail. Since bsize is not initialized, it's
> value will be random
Thanks, a self-fixing bug report is always nice :)
The patch looks sane, unfortunately I'm leaving for a two-week vacation in
about two hours. Hopefully Jonas will have time to add this fix and
release a new version.
Later it would probably be good to add checks too make sure that the
device argument is a block device and not something else, in order to
provide more helpful messages to the user. That can be implemented later
though.
--
David Härdeman
Tags added: pending
Request was from Jonas Meurer <mejo@debian.org>
to control@bugs.debian.org.
(full text, mbox, link).
Reply sent to Jonas Meurer <mejo@debian.org>:
You have taken responsibility.
(full text, mbox, link).
Notification sent to Rob Walker <rob@tenfoot.org.uk>:
Bug acknowledged by developer.
(full text, mbox, link).
Message #53 received at 403075-close@bugs.debian.org (full text, mbox, reply):
Source: cryptsetup
Source-Version: 2:1.0.4+svn26-1
We believe that the bug you reported is fixed in the latest version of
cryptsetup, which is due to be installed in the Debian FTP archive:
cryptsetup-udeb_1.0.4+svn26-1_amd64.udeb
to pool/main/c/cryptsetup/cryptsetup-udeb_1.0.4+svn26-1_amd64.udeb
cryptsetup_1.0.4+svn26-1.diff.gz
to pool/main/c/cryptsetup/cryptsetup_1.0.4+svn26-1.diff.gz
cryptsetup_1.0.4+svn26-1.dsc
to pool/main/c/cryptsetup/cryptsetup_1.0.4+svn26-1.dsc
cryptsetup_1.0.4+svn26-1_amd64.deb
to pool/main/c/cryptsetup/cryptsetup_1.0.4+svn26-1_amd64.deb
cryptsetup_1.0.4+svn26.orig.tar.gz
to pool/main/c/cryptsetup/cryptsetup_1.0.4+svn26.orig.tar.gz
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 403075@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Jonas Meurer <mejo@debian.org> (supplier of updated cryptsetup package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Format: 1.7
Date: Tue, 9 Jan 2007 21:53:06 +0100
Source: cryptsetup
Binary: cryptsetup cryptsetup-udeb
Architecture: source amd64
Version: 2:1.0.4+svn26-1
Distribution: unstable
Urgency: high
Maintainer: Jonas Meurer <mejo@debian.org>
Changed-By: Jonas Meurer <mejo@debian.org>
Description:
cryptsetup - configures encrypted block devices
cryptsetup-udeb - configures encrypted block devices (udeb)
Closes: 398429 402417 403075 405301
Changes:
cryptsetup (2:1.0.4+svn26-1) unstable; urgency=high
.
[ Jonas Meurer ]
* New upstream svn snapshot 1.0.4+svn26
- contains a slightly modified patch by Rob Walker
<rob@tenfoot.org.uk> to fix a sector size error. (closes: #403075)
- fixes a LUKS header corruption on arm, which downgrades bug
#403426 from critical to important.
- prevents password retrying with I/O errors.
* handle chainmode/essiv "plain" correctly in initramfs hook.
Thanks to Leonard Norrgard. (closes: #402417)
* remove 'rm -rf m4' from a clean target in debian/rules.
* urgency=high to get this into etch.
.
[ David Härdeman ]
* Document the difference in default hash functions between the
initramfs scripts and the plain cryptsetup binary. (closes: #398429)
* Verify symlinks for source devices when initramfs is generated and
correct if necessary. (closes: #405301)
Files:
f1f1fc2f3b0030f6597399017806ec40 831 admin optional cryptsetup_1.0.4+svn26-1.dsc
2124f81bdb586cdf103af4bf924d2b71 660171 admin optional cryptsetup_1.0.4+svn26.orig.tar.gz
51b6213e13f0c25ff85687e3badd75f8 43448 admin optional cryptsetup_1.0.4+svn26-1.diff.gz
65686e201302421e65c4cab7a5a54da2 263696 admin optional cryptsetup_1.0.4+svn26-1_amd64.deb
d088394912dd38aa25cd5f3610685386 184188 debian-installer optional cryptsetup-udeb_1.0.4+svn26-1_amd64.udeb
Package-Type: udeb
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFFpAGId6lUs+JfIQIRAjy/AKCcPF+P+GesjtACsWHh+OHj1zi6BACeIxyl
/exG6o8RXsmLmc7FlTVi0eg=
=n6cA
-----END PGP SIGNATURE-----
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Tue, 26 Jun 2007 14:26:40 GMT) (full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Sun Aug 20 18:18:23 2023;
Machine Name:
bembo
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.