Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Security Bug Graphics Software IT

Zlib Security Flaw Could Cause Widespread Trouble 372

BlueSharpieOfDoom writes "Whitedust has an interesting article posted about the new zlib buffer overflow. It affects countless software applications, even on Microsoft Windows. Some of the most affected application are those that are able to use the PNG graphic format, as zlib is wildely used in compression of PNG images. Zlib was also in the news in 2002 because of a flaw found in the way it handled memory allocation. The new hole could allow remote attackers to crash the vulnerable program or even the possiblity of executing arbitrary code."
This discussion has been archived. No new comments can be posted.

Zlib Security Flaw Could Cause Widespread Trouble

Comments Filter:
  • by alanw ( 1822 ) * <alan@wylie.me.uk> on Sunday July 10, 2005 @08:45AM (#13025936) Homepage
    Here's the patch to inftrees.c (found on Debian.org):
    $ diff -Naur inftrees.c ../zlib-1.2.2.orig/
    --- inftrees.c 2005-07-10 13:38:37.000000000 +0100
    +++ ../zlib-1.2.2.orig/inftrees.c 2004-09-15 15:30:06.000000000 +0100
    @@ -134,7 +134,7 @@
    left -= count[len];
    if (left < 0) return -1; /* over-subscribed */
    }
    - if (left > 0 && (type == CODES || max != 1))
    + if (left > 0 && (type == CODES || (codes - count[0] != 1)))
    return -1; /* incomplete set */

    /* generate offsets into symbol table for each length for sorting */
    And here's the E-Week article [eweek.com] with the quote
    However, Ormandy said, "Zlib is very mature and stable, so development is sporadic, but it's certainly not dead. Mark Adler [a Zlib co-author] responded to my report with a patch and an in-depth investigation and explanation within 24 hours, and I believe he expects to release a new version of Zlib very soon."
  • Already patched (Score:4, Informative)

    by Anonymous Coward on Sunday July 10, 2005 @09:03AM (#13025996)
    Both Debian and Ubuntu released the patch for this problem 2 days ago. I assume the other big names in the Linux world have or will follow suit shortly.
  • Not just IE (Score:3, Informative)

    by mikael_j ( 106439 ) on Sunday July 10, 2005 @09:10AM (#13026030)
    Not just IE on WinXP, Firefox works equally well with this website if you are looking for a BSOD. (I just had to try it).

    /Mikael

  • by grahammm ( 9083 ) * <graham@gmurray.org.uk> on Sunday July 10, 2005 @09:10AM (#13026035)
    Also hardware support would help. Even 25 years ago the ICL 2900 series systems had a native hardware 'pointer' type (they called it a descriptor). This included in it the size of the object pointed to, and the hardware would check that any dereferences were not out of bounds.
  • by Anonymous Coward on Sunday July 10, 2005 @09:11AM (#13026038)
  • by yog ( 19073 ) on Sunday July 10, 2005 @09:13AM (#13026044) Homepage Journal
    I'm running RHN alert notification on Fedora Core 3, and my version of zlib has already been updated with a patch for CAN-2005-2096 [mitre.org], the zlib overflow bug.

    It's interesting to read about these as they occur, but it's a nice feeling that my operating system is so well taken care of. Too bad that all personal computers aren't set up for this kind of timely response. I wonder about those millions of library computers, home PCs, small business computers, and other institutional setups where no one even understands the concept of an update, let alone regularly runs the Windows "security" update program.

    Another reason to use Linux!
  • by bersl2 ( 689221 ) on Sunday July 10, 2005 @09:22AM (#13026081) Journal
    There also exist modifications to gcc that perform the same function. A little checking on your part was all that was necessary to not fall into the publicization trap.

    However, all such methods introduce a very noticable performance penalty.

    Furthermore, there are documented ways of bypassing all such stack protection mechanisms.

    Stop bitching. Audit your goddamn code already. Or would you rather all the bugs be found by the bad guys (this one was found by the Gentoo security team)?
  • by Anonymous Coward on Sunday July 10, 2005 @09:34AM (#13026121)
    ..there has been no security audit that found this flaw.

    Been at the crack pipe again? "Provided and/or discovered by: Tavis Ormandy, Gentoo Linux Security Audit Team" here [secunia.com].
  • by Haeleth ( 414428 ) on Sunday July 10, 2005 @09:37AM (#13026136) Journal
    I wonder if it'd be possible to create a binary patch for prebuilt binaries ?

    For specific builds of individual programs, trivial. There are dozens of good, fast, and robust binary patching systems available - xdelta, bsdiff, and jojodiff are three F/OSS options. Of course, bandwidth is cheap enough these days that most people who use binaries can just download the new version in its entirety.

    A general-purpose fix that could be applied to any application using a statically-linked zlib would be much harder, possibly even impossible. This is one of the major advantages of dynamic linking - that a security update to the library in question can automatically benefit any application that uses the library.
  • by putko ( 753330 ) on Sunday July 10, 2005 @09:38AM (#13026138) Homepage Journal
    It is really something that this flaw impacts so many applications.

    This situation is unnecessary; the problem is that C is not a type-safe language, like ML, CAML, Haskell, Common Lisp, Scheme, Java, etc.

    You could write that code in SML/CAML/Common Lisp and likely get it to run as fast or faster than the original (particularly if you did some space/time tradeoffs ala partial evaluation). Integration with the applications in the form of a library would be the tough part.

    Here's a provocative bit from Paul Graham (Lisp expert entrepreneur) on buffer overflows [paulgraham.com].
  • Re:Already patched (Score:2, Informative)

    by i_like_spam ( 874080 ) on Sunday July 10, 2005 @09:52AM (#13026192) Journal
    What took 'em so long?

    Gentoo announced the bug July 5th [gentoo.org] and had the patch a day later.
  • Automatic buffer overflow protection only covers the straightforward buffer overflow problems, i.e. array index overflows. In the case of more complex pointer arithmetic, where most of these problems occur, automatic protection is not possible (at least not without losing the option of pointer arithmetic).

    Actually, automatic checking is very much possible, and has been for years. For example, Bounds checking gcc [ic.ac.uk] (that website is down right now, so try my page on the subject [annexia.org]). That was written in 1994, and there are newer systems available now which don't have such a serious performance penalty.

    The real solution is to stop writing critical code in C. Other languages provide bounds checking, and are faster and safer than C: for example OCaml [cocan.org] which I prefer nowadays.

    Rich.

  • by Florian Weimer ( 88405 ) <fw@deneb.enyo.de> on Sunday July 10, 2005 @10:04AM (#13026230) Homepage
    Common Lisp (the language) is not completely safe, it permits unsafe constructs which can even lead to classic buffer overflows. Most implementations omit bounds checks which are not mandated by the standard when optimizing, so these problems can occur in practice.
  • by Anonymous Coward on Sunday July 10, 2005 @10:08AM (#13026251)
    the problem is that C is not a type-safe language

    Please. This is a very boring misconception about types. It's not a type error. It's a pointer arithmetic error. Nothing a type system à la ML, Java, CL, whatever would have corrected.

    However, mandatory bound checking on arrays, at runtime, in those languages would have caught the problem.

    There exist type systems that can catch these kind of errors, but they are very cumbersome, and not very practical.
  • Re:Already patched (Score:2, Informative)

    by udippel ( 562132 ) on Sunday July 10, 2005 @10:20AM (#13026295)
    004: SECURITY FIX: July 6, 2005

    On OpenBSD
  • by Anonymous Coward on Sunday July 10, 2005 @10:20AM (#13026298)
    Actually, x86 already does, but nobody uses these features. When they fixed segmentation with the 386, segments were now accessed through selectors and offsets. The selectors pointed to one of two tables (GDT - global descriptor table or LDT - local descriptor table). Whenever a memory access was made using a selector, the CPU would look up the descriptor corresponding to the selector. It would check whether the current program had necessary access rights and privilege. If not, then a GPF would be thrown. Segments can be marked as read-only, read-write, executable and maybe a few more combos. Although the GDT and LDT each have only room for 8192 entries, that's still probably more than most programs would need. Each segment could correspond to a single object or array of primitive objects. There would be no buffer overflows because the CPU catches attempts to go beyond the limit of a segment. Stack data couldn't be executed inadvertently because the stack segment would properly be marked as non-executable.

    There are a few reasons, though, why we don't use this system. One is that loading descriptors is slow because it was never optimized in the CPU with the equivalent of a TLB as for paging. The other is that using segmentation requires 48-bit pointers rather than 32-bit pointers, or it requires loading segmentation registers and doing a dance with those. I suppose using longer pointers was a problem back in the days when memory was scarce, but it's hardly a problem now (check out 64-bit). Intel *could have* made segment descriptor access checks and loading fast, but I guess there wasn't a demand for it once paging was available.
  • BSD Status (Score:5, Informative)

    by emidln ( 806452 ) <adam4300@kettering.edu> on Sunday July 10, 2005 @10:31AM (#13026329) Homepage
    For the undead crowd out there:

    OpenBSD is affected, and was patched [openbsd.org] on the 6th of June
    FreeBSD is affected, and was patched [freebsd.org] on the 6th of June
    NetBSD base system is not affected, but a zlib from pkgsrc is, and was patched [netbsd.org] on the 8th of June
  • Better yet... (Score:3, Informative)

    by Tyler Durden ( 136036 ) on Sunday July 10, 2005 @10:39AM (#13026358)
    ...instead of looking for information on the NX bit from the buffer overflow page in Wikipedia, look up the thing specifically here [wikipedia.org]. Yeah.
  • Re:BSD Status (Score:2, Informative)

    by i_like_spam ( 874080 ) on Sunday July 10, 2005 @10:41AM (#13026368) Journal
    Oops... You meant 'July', not June.
  • by djmurdoch ( 306849 ) on Sunday July 10, 2005 @11:26AM (#13026524)
    ...there has been no security audit that found this flaw. ...everybody's computers won't be automatically updated just because there is a patch that all total geeks love. ...the source haven't been read by all who uses it, and the flaw wasn't found.

    In fact, this flaw was found by a security audit of an open source project, not by any of the closed source projects (like Microsoft Office) that make use of it.

  • by po8 ( 187055 ) on Sunday July 10, 2005 @12:34PM (#13026847)

    Why does this topic bring the, uh, technically challenged out of the woodwork?

    I'm a Ph.D. computer science professor with 20 years of experience in design and implementation of programming languages, and the co-author of a C-like programming language [nickle.org] featuring static and dynamic typing and runtime operand checking. The parent poster is confused.

    Static type checking involves automatically recognizing type-unsafe operations at compile time. In many programming languages, including C, if you write"s" - 1 the + operation is ill-defined, because the left-hand operand is of the wrong type: i.e., there is no string that is a legal operation to the - operator. The compiler can detect this at compile time and refuse to compile the program.

    Dynamic type checking involves automatically recognizing type-unsafe operations at run time. In many programming languages, such as Python, if you write"s" - 1 inside a function definition, the compiler will not detect the problem, because the general problem of detecting this kind of error is unsolvable unless one restricts what programmers can write. Instead, the execution engine can detect the problem at runtime when the - is evaluated and refuse to continue executing the program.

    Runtime operand checking involves automatically recognizing at runtime that an operation has an operand that, while of a type that might be legal for the operation being performed, is nonetheless illegal for that operation. In many languages, including Python, if you write 1 / 0 no error will be reported at compile time, because detecting such errors is in general impossible. Instead, the execution engine can detect the problem at runtime, and prevent execution from continuing.

    (Of course, there also is such a thing as static operand checking, which bears the same relation to runtime operand checking that static type checking does to runtime type checking. This is a hot research topic right now.)

    C's problem is that it (a) does not have a "safe" static type system, (b) does not have any dynamic type checking, and (c) has no operand checking. This combination of misfeatures is incredibly and obviously error-prone; offhand, I can think of no other popular language (not derived from C) that is broken in this fashion. Fixing (a) and/or (b) is not sufficient---(c) also needs to be fixed. Java, for example, has shown that this can be done in a C-like compiled language without noticeable loss of efficiency. (This was shown for PL/I more than 30 years ago, so it's no surprise.)

    The parent post gives an example in which the index argument to an array dereference is of the correct type and has correct operands. If x[2] was evaluated, this would be an operand error, since the combination of arguments x and 2 is not a legal operand combination for the array dereference operator. With the statement as given in the parent post, I'm not sure what principle it was trying to illustrate. I think, though, that it doesn't much matter.

  • by iabervon ( 1971 ) on Sunday July 10, 2005 @01:08PM (#13027027) Homepage Journal
    This is really an argument for versioning dynamic libraries very carefully. The Linux dynamic linker has perfectly good support for avoiding problems like this. Each shared library has a "SONAME" field. Programs linked against the library should be able to use any later version of the library with the same SONAME. If the library changes in some way that breaks desireable behavior, it is supposed to get a new SONAME. The system keeps two sets of symlinks, in addition to the object files: libfoo.so is the latest version and libfoo.so.{version} is the latest version of a compatible series. When you link a program, you use the libfoo.so to find which series is newest. When you run a program, you use libfoo.so.{version}, so you get the newest compatible version.

    It sounds like the problem you had was that the common library version number wasn't changed when it should have been. If it had been changed, there would have been no effect on any of the existing programs, static or dynamic. Of course, for a two-line fix to a function which only changes the behavior of the library when dealing with corrupted files, and resulted in a buffer overflow instead of an error, the change won't break anything except attacks, so keeping the same SONAME is right.

    Note that you can see this by doing "ldd {program}", which will report how it looks for each library and what it finds. And you can see that zlib claims to be backwards compatible all the way through 1.x, while openssl is only to 0.9.7.
  • by Compenguin ( 175952 ) on Sunday July 10, 2005 @01:11PM (#13027040)
    > Nothing more fun than firing off a couple apt-get upgrades in the morning while watching your bsd/gentoo friends sit around rebuilding

    What!!! The gentoo/bsd crowd wouldn't staticly link zlib. They would only need to rebuild one package. You sir, are full of crap.
  • by Dun Malg ( 230075 ) on Sunday July 10, 2005 @01:29PM (#13027122) Homepage
    Stop bitching. Audit your goddamn code already.

    Oh please. When are we going to get past, "I know! Let's just write perfect software all the time!"

    There will always be some subset of people who refuse to accept the impossibility of absolute perfection. I believe their thinking goes like this:

    "Anyone can easily write a single line of bug-free code. If you can write twenty of those lines, you can write a bug free function. Write a dozen such bug-free functions and you've got a bug-free class. Write a half dozen or so bug-free classes and you have a bug free library. Using a collection of such bug free libraries you can write a few more bug-free classes held together by some bug-free lines of code and you've got a bug-free application. You're not so stupid that you can't write a single line of bug-free code, are you? There's no excuse for bugs. Just don't make mistakes. It's a choice, really."

    (I never had to work for anyone who said the above, but my brother in law, a coder for a large trucking company, had to put up with a "quality consultant" whose entire theory was essentially the above, punctuated with shouts of "attention to detail, people!" in between such lectures. A similar consultant is documented in an email in "The Dilbert Principle". Sadly, it's probably not the same guy.)

  • by excyl ( 685679 ) <excyl.m@nOSpAm.gmail.com> on Sunday July 10, 2005 @01:52PM (#13027261)
    Luckily there were some Gentooists recompiling their systems packages every so often, since the vulnerability was found by the Gentoo Linux Security Audit Team here [gentoo.org]. I've always thought the the more projects making use of the same library, as well as, the platforms a project is ported to eventually improves the quality and stability of the code. In this case the security was improved, but in general the abstracted parts of the code improve.
  • by DJ Rubbie ( 621940 ) on Sunday July 10, 2005 @03:18PM (#13027690) Homepage Journal
    What are you talking about? All I had to do was to rebuild zlib and restart apps that used zlib. Oh, I did that while I ssh back home from work, all I had to do was to fire off a couple commands to do the same fix as apt-get.

    Please, learn how a Linux/BSD system work, how linked/static binaries work before start critiquing other distributions with non-sense.
  • by Vantage13 ( 207635 ) on Sunday July 10, 2005 @03:46PM (#13027797) Homepage
    In Debian for instance, there is one zlib package that everything uses

    Not entirely true. See this list [google.com] from the debian-security mailing list for a few which are statically linked.

  • by m50d ( 797211 ) on Sunday July 10, 2005 @04:05PM (#13027900) Homepage Journal
    I haven't used Python or OCaml, but if either of those languages can produce C-style .lib's, .dll's, .so's, .obj's, whatever, then they'll work as well from C.

    Python can't, at least without embedding the python interpreter in the dll.

    What's more, you say that C can work with (at least as a library) every other language out there. So what's the problem with a small C-language interface that just calls the Python function and returns the result?

    Any language supports calling C libraries from that language. You have to, because for many things the only library available is in C, and there are millions of C libraries. Not so many support calling that language libraries from C - why would they? A big part of their attractiveness is their extensive standard library.

  • by CharlesEGrant ( 465919 ) on Sunday July 10, 2005 @05:23PM (#13028291)
    jesus. i am glad the people who build bridges, dams, etc... don't have your attitude.
    The people who build dams, bridges, etc., don't simply tell the construction crew to be be careful. They know that mistakes will be made, so they create protocols to minimize the likelihood of mistakes, and to maximize the likelihood of finding the mistakes that are made. For example, an in-law who works in avionics tells me that in any cable run that carries multiple cables, the cables are required to have physically incompatible connectors. They could just tell the manufacturing crew to be careful, but they know from long experience that if two cables can be confused, they will be, so they do their best to make it physically impossible to do so.

    Personally, I work down a suite of tools to help ensure reliability:

    1. Use a language and run-time that enforces bounds checking and managed memory. This is not always practial because of performance issues.

    2. If I can't do that, use libraries that hide the complexity of managing memory (smart pointers, smart arrays, and the like). This is not entirely reliable because it depends on the discipline of the programmer.

    3. If I can't do that, I use tools like valgrind in conjunctgion with unit testing, so that l can find memory errors after the fact. This can't be completely trusted because it depends on the completeness of the test suite.

    4. Code carefully and cross my fingers.

New York... when civilization falls apart, remember, we were way ahead of you. - David Letterman

Working...