Re: More on Shatter

From: Daniel Newby (dnewby@nomadics.com)
Date: 08/24/02


Date: Fri, 23 Aug 2002 19:07:25 -0500
To: dr@kyx.net, vuln-dev@securityfocus.com
From: "Daniel Newby" <dnewby@nomadics.com>

I don't want to belabor this issue, but I strongly disagree with the
pronouncements that the problem is "inherent to the Win32 API" and "unfixable".

At 03:33 PM 8/23/2002 +0000, Dragos Ruiu wrote:
>Filtering and lookups in tables can be computationally
>intensive tasks. And parsing every message to weed
>out some is not only potentially slow, but could be
>a cure worse than the disease... because it might
>break potentially sloppy code in some critical app...

I've been out of the Win32 scene for a couple of years, so I talked with my
Win32 colleagues to find out exactly how WM_TIMER is used. According to
them, WM_TIMER is usually used for low-precision user interface stuff
(e.g., timing for tool tips). A typical application has perhaps half a
dozen of these timers active at once.

The overhead of checking half a dozen pointers ought to be negligible
relative to the substantial overhead of the message queue. Rejecting
WM_TIMERs from other processes would be even faster.

As far as breaking code goes, the security patch should be
configurable. Operators of critical servers could leave the filtering
turned off to minimize surprises. Operators of terminal servers and
public-access computers could turn it on to keep untrusted users from
running amok.

>The added latency might be a serious issue in a time
>critical place like a *timer* service (or message) routine.

WM_TIMER messages are processed at a low priority: the message queue has
to be empty of everything else (mouse movements, keyboard messages, etc.)
before a WM_TIMER will be processed. Windows has other timers (e.g., the
multimedia timers) for applications that need precision timing.

>Yep, this is a hard problem. The real solution is not to
>pass the call back in this way, but such is the curse of the
>pre-defined API you have to maintain backwards compatibility
>with. Maybe another few hundered MB of code might fix
>it? :-) Probably not. If it's any consolation there are some
>similar locked into stone API architectural issues in
>things like POSIX too that ought to be fixed but
>cannot while retaining backwards compatibility - though
>perhaps not of this magnitude of impact.

My colleagues tell me that using the callback is poor technique
anyway. It's just as easy to manually handle the WM_TIMER message when you
process the message queue.

>As much as it seems easy to bash MS for this one, it isn't
>their fault some applications are lame :-).

Yes it is. The "feature" is useless, surprising, and makes it easy to
shoot yourself in the foot. A skilled software engineer may be able to
work around it, but it's still a flaw for the average programmer.

>Though it seems
>to me they *should* fix the default handler for WM_TIMER
>in DefWindowProc() to avoid the arbitrary callback use but
>I don't know enough to say whether this too would break a
>lot of stuff since someone at MS who probably knows more
>about this seems to think this is a bad idea.

I bet this is why a patch hasn't been forthcoming. They have to make it
configurable for people who can't accept breakage, the gradations of
breakage have to be carefully chosen for different user environments, and
then it has to be regression tested against zillions of apps. (Hopefully
I'm not giving them too much credit...)

     -- Daniel Newby, speaking for myself



Relevant Pages

  • Re: What can .Net do for me?
    ... >> object-oriented API. ... If you're not writing OOP apps then you'll probably ... WIN32 is here *now*. ... > "If you don't use the Windows API directly then you'll probably never ...
    (borland.public.delphi.non-technical)
  • Re: Suggested base class additions
    ... If you think of Dolphin as primarily a Smalltalk-flavoured front-end to Win32, ... then it'd seem quite natural to have all the API wrapped/exposed. ... on Windows, then the less you see of the Win32 cesspit the better. ...
    (comp.lang.smalltalk.dolphin)
  • Re: What can .Net do for me?
    ... > How is .NET a benefit over WIN32 API? ... > better than the mess that is WIN32. ... >> specific development languages. ... Because it's OOP? ...
    (borland.public.delphi.non-technical)
  • Re: Windows message -> .NET method
    ... of knowing how Windows messages translate into .NET events. ... use InterOp just to drop to the Windows API level. ... I might not have to ever go the Win32 API ... >> .NET methods. ...
    (microsoft.public.dotnet.framework)
  • Re: Why 64bit Delphi compiler from Borland may be meaningless!
    ... M$ have a reputation for having written APIs that are deemed to be unsafe ... If they were to continue to use the Win32 API underneath the .NET API, ... You are free to continue using the Win32 ... Penalty for private use. ...
    (borland.public.delphi.non-technical)