Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 203777
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo Security <security@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Devon Miller <devon.miller@verizon.net>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:
Flags: Requestee:
 
 
  ()

Filename Description Type Creator Created Size Actions
libcdio-info-buffer.patch libcdio-info-buffer.patch patch Robert Buchholz 2007-12-30 18:43 0000 1.41 KB Details | Diff
libcdio.patch Buffer patch with correction for +1 in the wrong place patch Devon Miller 2008-01-03 13:24 0000 1.41 KB Details | Diff
libcdio-buffer-offbyone.patch Upstream patch for misplaced +1 patch Devon Miller 2008-01-04 03:12 0000 1.65 KB Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 203777 depends on: Show dependency tree
Bug 203777 blocks:

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2007-12-30 14:49 0000
dev-libs/libcdio-0.78.2 provides iso-info and cd-info both exhibit this
vulnerability.

A properly formatted iso image can produce a coredump and may allow for
malicious code injection.

Reproducible: Always

Steps to Reproduce:
1. mkdir -p tmp/dir1
2. echo file_with_really_really_long_silly_name_to_test_iso_info_buffer
3. mkisofs -J -R -volid My_Image -o test.iso tmp
4. iso-info -l test.iso

Actual Results:  
iso-info lists files and directories up to the ver long file name at which
point it segfaults.

Expected Results:  
a listing of the directories

in src/iso-info.c, in function "print_iso9660_recurse" there is a block of code
that begins:

 _CDIO_LIST_FOREACH (entnode, entlist)
    {
      iso9660_stat_t *p_statbuf = _cdio_list_node_data (entnode);
      char *psz_iso_name = p_statbuf->filename;
      char _fullname[4096] = { 0, };
      char translated_name[MAX_ISONAME+1];


      if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) {
        iso9660_name_translate_ext(psz_iso_name, translated_name,
                                   i_joliet_level);
        snprintf (_fullname, sizeof (_fullname), "%s%s", psz_path,
                  translated_name);
      } else {
        snprintf (_fullname, sizeof (_fullname), "%s%s", psz_path,
                  psz_iso_name);


I believe either the test "yep != p_statbuf->rr.b3_rock" is incorrect, or
possibly the code in lib/iso9660 that sets "b3_rock". The field "b3_rock" is an
enumeration with the values "nope", "yep", "dunno". The test would be valid if
"b3_rock" was a boolean, but the additional "dunno" state causes a problem.

When the iso is created with the options given above, the value of "b3_rock" is
"dunno" (integer 2). This causes the code to enter the
"iso9660_name_translate_ext" which writes beyond the end of "translated_name"
and corrupts the stack.

I have also submitted this upstream as bug #21910

------- Comment #1 From Robert Buchholz 2007-12-30 15:30:31 0000 -------
The upstream bug report is marked private, so I restricted this bug for now.
Please be aware that this vulnerability cannot be considered confidential
anymore, as it was public in this bugtracker before.

Diego, please advise.

------- Comment #2 From Devon Miller 2007-12-30 16:36:02 0000 -------
Sorry about that, I didn't see an obvious way to enter a private bug.

It's currently fixed in upstream CVS (iso-info.c:1.36, cd-info.c:1.150).

I'm attaching a patch that fixes the current ebuild

------- Comment #3 From Robert Buchholz 2007-12-30 17:07:05 0000 -------
To enter restricted bugs, just click the "Only users in all of the selected
groups can view this bug:  Gentoo Security" checkbox in the expert bug filing
page.

------- Comment #4 From Diego E. 'Flameeyes' Pettenò 2007-12-30 18:21:50 0000 -------
I don't really know what to advise on such short notice as I didn't even know
of this before. I can tell there are quite some changes in libcdio CVS, good
ones mostly but I wouldn't fast track to stable a new release of it right now
(and I say this because I did make some of the changes ;)), so I'd suppose
extracting the commit patch would probably be the best thing.

------- Comment #5 From Robert Buchholz 2007-12-30 18:43:09 0000 -------
Created an attachment (id=139644) [details]
libcdio-info-buffer.patch

Upstream committed patch

------- Comment #6 From Robert Buchholz 2007-12-30 18:48:15 0000 -------
Diego, sounds good -- find the patch attached. As it is already in the upstream
CVS, please prepare an ebuild. 

------- Comment #7 From Diego E. 'Flameeyes' Pettenò 2007-12-30 19:20:51 0000 -------
libcdio-0.78.2-r2 added to portage.. although I'm not the libcdio ebuild
maintainer since almost an year ;)

Please when you add arches add also mips so that they can keyword a recent
version, thanks.

------- Comment #8 From Robert Buchholz 2007-12-30 19:35:58 0000 -------
Arch Security Liaisons, please test and mark stable dev-libs/libcdio-0.78.2-r2.
Target keywords : "alpha amd64 arm hppa ia64 ppc ppc64 sh sparc x86"

CC'ing current Liaisons:
  alpha : ferdy
  amd64 : welp
   hppa : jer
    ppc : dertobi123
  ppc64 : corsair
  sparc : fmccor
    x86 : opfer

------- Comment #9 From Christian Faulhammer 2007-12-30 21:53:04 0000 -------
(In reply to comment #8)
> Arch Security Liaisons, please test and mark stable dev-libs/libcdio-0.78.2-r2.
> Target keywords : "alpha amd64 arm hppa ia64 ppc ppc64 sh sparc x86"

 Works on x86, but I am not able to commit to other directories than profiles
at the moment...crappy lappy.  Anyway, anyone is free to fix it for x86.

------- Comment #10 From Jeroen Roovers 2007-12-31 06:16:57 0000 -------
Stable for HPPA and x86 (comment #9).

------- Comment #11 From Markus Rothe 2007-12-31 14:30:42 0000 -------
adding ranger because my machine is down.

ranger: comment #8

------- Comment #12 From Brent Baude 2007-12-31 16:05:47 0000 -------
ppc64 done

------- Comment #13 From Peter Weller 2007-12-31 17:40:27 0000 -------
amd64 done.

------- Comment #14 From Diego E. 'Flameeyes' Pettenò 2007-12-31 20:52:26 0000 -------
Rocky mailed this on libcdio-dev so it's now public. I'll mail the patch for
this in a few minutes and then work toward a new release, although I still want
0.78.2-r2 as target stable ;)

------- Comment #15 From Robert Buchholz 2008-01-01 15:46:15 0000 -------
public via
http://lists.gnu.org/archive/html/libcdio-devel/2007-12/msg00009.html

Arches, please test and mark stable dev-libs/libcdio-0.78.2-r2.
Target keywords : "alpha amd64 arm hppa ia64 ppc ppc64 sh sparc x86"
Already stabled : "amd64 hppa ppc x86"
Missing keywords: "alpha arm ia64 ppc64 sh sparc"

------- Comment #16 From Raúl Porcel 2008-01-01 15:57:43 0000 -------
alpha/ia64/sparc stable

------- Comment #17 From Brent Baude 2008-01-01 18:00:01 0000 -------
ppc64 done

------- Comment #18 From Robert Buchholz 2008-01-01 22:06:02 0000 -------
request filed

------- Comment #19 From bannedit 2008-01-03 03:34:49 0000 -------
(In reply to comment #0)
> dev-libs/libcdio-0.78.2 provides iso-info and cd-info both exhibit this
> vulnerability.
> 
> A properly formatted iso image can produce a coredump and may allow for
> malicious code injection.
> 
> Reproducible: Always
> 
> Steps to Reproduce:
> 1. mkdir -p tmp/dir1
> 2. echo file_with_really_really_long_silly_name_to_test_iso_info_buffer
> 3. mkisofs -J -R -volid My_Image -o test.iso tmp
> 4. iso-info -l test.iso
> 
> Actual Results:  
> iso-info lists files and directories up to the ver long file name at which
> point it segfaults.
> 
> Expected Results:  
> a listing of the directories
> 
> in src/iso-info.c, in function "print_iso9660_recurse" there is a block of code
> that begins:
> 
>  _CDIO_LIST_FOREACH (entnode, entlist)
>     {
>       iso9660_stat_t *p_statbuf = _cdio_list_node_data (entnode);
>       char *psz_iso_name = p_statbuf->filename;
>       char _fullname[4096] = { 0, };
>       char translated_name[MAX_ISONAME+1];
> 
> 
>       if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) {
>         iso9660_name_translate_ext(psz_iso_name, translated_name,
>                                    i_joliet_level);
>         snprintf (_fullname, sizeof (_fullname), "%s%s", psz_path,
>                   translated_name);
>       } else {
>         snprintf (_fullname, sizeof (_fullname), "%s%s", psz_path,
>                   psz_iso_name);
> 
> 
> I believe either the test "yep != p_statbuf->rr.b3_rock" is incorrect, or
> possibly the code in lib/iso9660 that sets "b3_rock". The field "b3_rock" is an
> enumeration with the values "nope", "yep", "dunno". The test would be valid if
> "b3_rock" was a boolean, but the additional "dunno" state causes a problem.
> 
> When the iso is created with the options given above, the value of "b3_rock" is
> "dunno" (integer 2). This causes the code to enter the
> "iso9660_name_translate_ext" which writes beyond the end of "translated_name"
> and corrupts the stack.
> 
> I have also submitted this upstream as bug #21910
> 

(In reply to comment #5)
> Created an attachment (id=139644) [edit] [details]
> libcdio-info-buffer.patch
> 
> Upstream committed patch
> 

Shouldn't the +1 go outside the strlen bracets? Likely won't cause a problem
now that things are on the heap but... worth mentioning I think

------- Comment #20 From Devon Miller 2008-01-03 13:15:28 0000 -------
(In reply to comment #19)
> >       char translated_name[MAX_ISONAME+1];
> > 
> 
> (In reply to comment #5)
> > Created an attachment (id=139644) [edit] [details]
> > libcdio-info-buffer.patch
> > 
> > Upstream committed patch
> > 
> 
> Shouldn't the +1 go outside the strlen bracets? Likely won't cause a problem
> now that things are on the heap but... worth mentioning I think
> 

Yes, good catch, As it is, the alloca'd string may be 2 bytes too small.I have
updated the upstream bug report with this information,

------- Comment #21 From Devon Miller 2008-01-03 13:24:39 0000 -------
Created an attachment (id=139967) [details]
Buffer patch with correction for +1 in the wrong place

Moved the +1 outside the strlen call so the size is the length of the string
plus 1, not the length of the string minus 1.

------- Comment #22 From Diego E. 'Flameeyes' Pettenò 2008-01-03 13:45:09 0000 -------
I think it the original version was by design: the translation strings remove
;1 suffix from filenames, so strlen(foo+1) is equivalent to writing
strlen(foo)-1, just making strlen faster (afair, strlen() is O(n)).

------- Comment #23 From Devon Miller 2008-01-04 03:12:36 0000 -------
Created an attachment (id=140011) [details]
Upstream patch for misplaced +1

Patch from upstream cvs repo.

------- Comment #24 From Devon Miller 2008-01-04 03:14:49 0000 -------
(In reply to comment #22)
> I think it the original version was by design: the translation strings remove
> ;1 suffix from filenames, so strlen(foo+1) is equivalent to writing
> strlen(foo)-1, just making strlen faster (afair, strlen() is O(n)).

Negative. Upstream has confirmed and patched. See attachment #140011 [details]

------- Comment #25 From Robert Buchholz 2008-01-04 03:35:57 0000 -------
media-video, your ball.

------- Comment #26 From Pierre-Yves Rofes 2008-01-04 22:35:05 0000 -------
*** Bug 204333 has been marked as a duplicate of this bug. ***

------- Comment #27 From Diego E. 'Flameeyes' Pettenò 2008-01-04 23:21:53 0000 -------
Committed 0.78.2-r3 straight-to-stable for those who already stabled -r2.

------- Comment #28 From Robert Buchholz 2008-01-04 23:38:02 0000 -------
Arches, please test and mark stable dev-libs/libcdio-0.78.2-r3.
Target keywords : "alpha amd64 arm hppa ia64 ppc ppc64 sh sparc x86"
Already stabled : "alpha amd64 hppa ia64 ppc ppc64 sparc x86"
Missing keywords: "arm sh"

------- Comment #29 From Robert Buchholz 2008-01-08 22:56:27 0000 -------
Stanislav Brabec from SUSE pointed out that allocating a larger string on the
stack might easier lead to stack exhaustion, which can be shown by using some
ten thousand files with long file names.
Not sure on whether upstream will apply his patches, but would you consider
this a regression (media-video/Diego)?

------- Comment #30 From Robert Buchholz 2008-01-09 21:11:06 0000 -------
Diego, do you consider this a regression? If not, we'd glsa this now, otherwise
we'll go stabling a new ebuild.

The patch has been committed to the upstream CVS.

------- Comment #31 From bannedit 2008-01-10 22:57:55 0000 -------
(In reply to comment #29)
> Stanislav Brabec from SUSE pointed out that allocating a larger string on the
> stack might easier lead to stack exhaustion, which can be shown by using some
> ten thousand files with long file names.
> Not sure on whether upstream will apply his patches, but would you consider
> this a regression (media-video/Diego)?
> 
I was looking at this scenario just recently. From the alloca() man page:

RETURN VALUE
       The  alloca()  function returns a pointer to the beginning of the allo-
       cated space.  If the allocation causes stack overflow, program behavior
       is undefined.

In some cases I think this could cause some major problems even further
security issues. In the simplest case this will only cause stability issues. My
suggestion would be to use the heap rather than alloca().

------- Comment #32 From Sune Kloppenborg Jeppesen 2008-01-13 14:08:14 0000 -------
Seems like we should go back to ebuild to get this fixed?

------- Comment #33 From Diego E. 'Flameeyes' Pettenò 2008-01-13 14:37:35 0000 -------
Sorry I was out of order because of the cold/fever, I'll see to handle this
today.

------- Comment #34 From Diego E. 'Flameeyes' Pettenò 2008-01-13 16:17:59 0000 -------
0.78.2-r4 and 0.79-r1 are in tree. I didn't commit straight to stable this
time, just for safety.

------- Comment #35 From Sune Kloppenborg Jeppesen 2008-01-13 16:39:33 0000 -------
Thx Diego. Arches please test and mark stable. Target keywords are:

libcdio-0.78.2-r4.ebuild:KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 sh sparc
~sparc-fbsd x86 ~x86-fbsd"

------- Comment #36 From Brent Baude 2008-01-13 17:56:54 0000 -------
ppc64 done

------- Comment #37 From Tobias Scherbaum 2008-01-13 20:19:39 0000 -------
ppc stable

------- Comment #38 From Markus Meier 2008-01-13 20:55:15 0000 -------
x86 stable

------- Comment #39 From Ferris McCormick 2008-01-14 14:16:09 0000 -------
Sparc stable.

------- Comment #40 From Raúl Porcel 2008-01-14 20:12:44 0000 -------
alpha/ia64 stable

------- Comment #41 From Jeroen Roovers 2008-01-14 20:38:05 0000 -------
Stable for HPPA.

------- Comment #42 From Robert Buchholz 2008-01-15 17:42:58 0000 -------
amd64 stable, [glsa] again.

------- Comment #43 From Robert Buchholz 2008-01-20 00:44:34 0000 -------
GLSA 200801-08, thanks.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug