dcraw: CVE-2021-3624: buffer-overflow caused by integer-overflow in foveon_load_camf()

Related Vulnerabilities: CVE-2021-3624  

Debian Bug report logs - #984761
dcraw: CVE-2021-3624: buffer-overflow caused by integer-overflow in foveon_load_camf()

version graph

Reported by: Wooseok Kang <kangwoosuk1@gmail.com>

Date: Mon, 8 Mar 2021 04:42:02 UTC

Severity: normal

Tags: security

Found in version dcraw/9.28-2

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, kangwoosuk1@gmail.com, Debian Astronomy Team <debian-astro-maintainers@lists.alioth.debian.org>:
Bug#984761; Package dcraw. (Mon, 08 Mar 2021 04:42:04 GMT) (full text, mbox, link).


Acknowledgement sent to Wooseok Kang <kangwoosuk1@gmail.com>:
New Bug report received and forwarded. Copy sent to kangwoosuk1@gmail.com, Debian Astronomy Team <debian-astro-maintainers@lists.alioth.debian.org>. (Mon, 08 Mar 2021 04:42:05 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Wooseok Kang <kangwoosuk1@gmail.com>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: dcraw: buffer-overflow caused by integer-overflow in foveon_load_camf()
Date: Mon, 08 Mar 2021 13:37:46 +0900
[Message part 1 (text/plain, inline)]
Package: dcraw
Version: 9.28-2
Severity: normal
X-Debbugs-Cc: kangwoosuk1@gmail.com

Dear Maintainer,

There is an integer overflow vulnerability in dcraw.
When the victim runs dcraw with a maliciously crafted X3F input image,
arbitrary code may be executed in the victim's system.

The vulnerability resides in foveon_load_camf() function in dcraw.c file.
The program reads data from the input image using get4().

type = get4();  get4();  get4();
wide = get4();
high = get4();

Since there is no sanitization for these variables, we can set their values freely.
Let type=4, and wide and high are enough large values which can make overflow.
Then, it will lead to small memory allocation at the below code.

} else if (type == 4) {
    free (meta_data);
    meta_length = wide*high*3/2;
    meta_data = (char *) malloc (meta_length);

Therefore, when we read data to this allocated buffer,
it causes the buffer overrun which may lead to arbitrary code execution or program crash.

I attach the maliciously crafted X3F file which crashes dcraw like below.
> dcraw dcraw-poc.X3F
dcraw-poc.X3F: Corrupt data near 0x651
[1]    1251 segmentation fault  dcraw dcraw-poc.X3F

Thank you.

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 5.4.72-microsoft-standard-WSL2 (SMP w/16 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: unable to detect

Versions of packages dcraw depends on:
ii  libc6            2.31-9
ii  libjpeg62-turbo  1:2.0.6-2
ii  liblcms2-2       2.12~rc1-2

dcraw recommends no packages.

Versions of packages dcraw suggests:
pn  gphoto2  <none>
pn  netpbm   <none>

-- no debconf information
[dcraw-poc.X3F (image/x-x3f, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian Astronomy Team <debian-astro-maintainers@lists.alioth.debian.org>:
Bug#984761; Package dcraw. (Tue, 09 Mar 2021 16:54:02 GMT) (full text, mbox, link).


Acknowledgement sent to Filip Hroch <hroch@physics.muni.cz>:
Extra info received and forwarded to list. Copy sent to Debian Astronomy Team <debian-astro-maintainers@lists.alioth.debian.org>. (Tue, 09 Mar 2021 16:54:02 GMT) (full text, mbox, link).


Message #10 received at 984761@bugs.debian.org (full text, mbox, reply):

From: Filip Hroch <hroch@physics.muni.cz>
To: 984761@bugs.debian.org
Subject: dcraw: buffer-overflow caused by integer-overflow in foveon_load_camf()
Date: Tue, 09 Mar 2021 17:41:51 +0100
Dear Wooseok,

I'll look on this.

Note, that I'm maintaining only Debian packaging.
I am not upstream autor; I can fix only the bugs
which does not induce extensive changes in whole
structure of the source code.

FH
--
F. Hroch <hroch@physics.muni.cz>, Masaryk University, Brno, 
Czechia.
Dept. of theor. physics and astrophysics, Kotlarska 2, CZ-611 37.



Added tag(s) security. Request was from Adrian Bunk <bunk@debian.org> to control@bugs.debian.org. (Mon, 31 May 2021 20:51:02 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Debian Astronomy Team <debian-astro-maintainers@lists.alioth.debian.org>:
Bug#984761; Package dcraw. (Wed, 02 Jun 2021 20:42:02 GMT) (full text, mbox, link).


Acknowledgement sent to Salvatore Bonaccorso <carnil@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian Astronomy Team <debian-astro-maintainers@lists.alioth.debian.org>. (Wed, 02 Jun 2021 20:42:02 GMT) (full text, mbox, link).


Message #17 received at 984761@bugs.debian.org (full text, mbox, reply):

From: Salvatore Bonaccorso <carnil@debian.org>
To: Filip Hroch <hroch@physics.muni.cz>, 984761@bugs.debian.org, 984761-submitter@bugs.debian.org
Subject: Re: Bug#984761: dcraw: buffer-overflow caused by integer-overflow in foveon_load_camf()
Date: Wed, 2 Jun 2021 22:40:19 +0200
Hi Filip, Wooseok

On Tue, Mar 09, 2021 at 05:41:51PM +0100, Filip Hroch wrote:
> Dear Wooseok,
> 
> I'll look on this.
> 
> Note, that I'm maintaining only Debian packaging.
> I am not upstream autor; I can fix only the bugs
> which does not induce extensive changes in whole
> structure of the source code.

Can you please report the issue upstream? Or was this reported
upstream?

Regards,
Salvatore



Message sent on to Wooseok Kang <kangwoosuk1@gmail.com>:
Bug#984761. (Wed, 02 Jun 2021 20:42:07 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Debian Astronomy Team <debian-astro-maintainers@lists.alioth.debian.org>:
Bug#984761; Package dcraw. (Thu, 03 Jun 2021 10:45:03 GMT) (full text, mbox, link).


Acknowledgement sent to Filip Hroch <hroch@physics.muni.cz>:
Extra info received and forwarded to list. Copy sent to Debian Astronomy Team <debian-astro-maintainers@lists.alioth.debian.org>. (Thu, 03 Jun 2021 10:45:03 GMT) (full text, mbox, link).


Message #25 received at 984761@bugs.debian.org (full text, mbox, reply):

From: Filip Hroch <hroch@physics.muni.cz>
To: Salvatore Bonaccorso <carnil@debian.org>
Cc: 984761@bugs.debian.org, 984761-submitter@bugs.debian.org
Subject: Re: Bug#984761: dcraw: buffer-overflow caused by integer-overflow in foveon_load_camf()
Date: Thu, 03 Jun 2021 12:35:21 +0200
Dear Salvatore,

unfortunatelly, I have not fixed it yet.

I suppose to report it to upstream author -- Mr. Coffin.
In past, I send patches without any response.

The last upstream version of dcraw has been issued
tree years ago, so I've some worry about him.

Regards,
FH


Salvatore Bonaccorso <carnil@debian.org> writes:

> Hi Filip, Wooseok
>
> On Tue, Mar 09, 2021 at 05:41:51PM +0100, Filip Hroch wrote:
>> Dear Wooseok,
>>
>> I'll look on this.
>>
>> Note, that I'm maintaining only Debian packaging.
>> I am not upstream autor; I can fix only the bugs
>> which does not induce extensive changes in whole
>> structure of the source code.
>
> Can you please report the issue upstream? Or was this reported
> upstream?
>
> Regards,
> Salvatore


--
F. Hroch <hroch@physics.muni.cz>, Masaryk University,
Dept. of theor. physics and astrophysics, Brno, Moravia, CZ



Message sent on to Wooseok Kang <kangwoosuk1@gmail.com>:
Bug#984761. (Thu, 03 Jun 2021 10:45:06 GMT) (full text, mbox, link).


Changed Bug title to 'dcraw: CVE-2021-3624: buffer-overflow caused by integer-overflow in foveon_load_camf()' from 'dcraw: buffer-overflow caused by integer-overflow in foveon_load_camf()'. Request was from Salvatore Bonaccorso <carnil@debian.org> to control@bugs.debian.org. (Tue, 29 Jun 2021 05:45:05 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: Tue Jun 29 16:15:05 2021; Machine Name: buxtehude

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.