Single misplaced '&' caused latest IE exploit
A security hole in Internet Explorer that opened the browser to hackers since early July was caused by a single typo in Microsoft's code.
An errant ampersand ("&") took the blame for the exploit, admitted Microsoft in a blog published Tuesday at its Security Development Lifecycle (SDL) Web site.
Michael Howard, a security program manager at Microsoft, explained in his blog that the typo corrupted the code of an ActiveX control used by the browser. The control was created by Microsoft using an older library of code, which Howard admitted has flaws. Because of those flaws, the typo caused the code to write untrusted data, exposing the browser to the bad guys.
Outside of its regular Patch Tuesday routine, Microsoft issued an emergency fix for IE, which it said would block attempts to exploit the flaw in ActiveX controls.
Development tools like Microsoft's own Visual Studio use the same library of code, known as Active Template Library (ATL). On the same day it released the emergency patch for IE, the company also released a Visual Studio fix.
Howard said the typo would have been difficult to spot in a review of the code, and that none of Microsoft's code analysis methods would have uncovered it either.
In his blog, Howard played a high-tech version of "Where's Waldo?" by challenging readers to find the typo amid a few short lines of code, even hinting that it was a single character.
The code lines he listed were:
__int64 cbSize;
hr = pStream->Read((void*) &cbSize, sizeof(cbSize), NULL);
BYTE *pbArray;
HRESULT hr = SafeArrayAccessData(psa, reinterpret_cast
hr = pStream->Read((void*)&pbArray, (ULONG)cbSize, NULL);
And his riddle for readers:
"I'll give you one more clue - it's a one character typo. Give up? Look at the last line. The first argument is incorrect. It should be: hr = pStream->Read((void*)pbArray, (ULONG)cbSize, NULL);"
The hole was originally uncovered earlier this month by a pair of German researchers. Thomas Dullien (also known as Halvar Flake), CEO of Zynamics GmbH, and his friend Dennis Elser detailed their discovery in a blog. After the exploit became known, the two did some digging into the code and found the unwanted "&" character.
So what will Microsoft do to guard against future typos?
In his blog, Howard acknowledged the need to clean up the company's coding process. He said that Microsoft will update the tools it uses to find these types of errors. The company will also require its programmers to use the newer ATL code. In the past, Microsoft never told its programmers what to use. But says Howard in his blog, "We're going to change that!"
Lance Whitney wears a few different technology hats--journalist, Web developer, and software trainer. He's a contributing editor for Microsoft TechNet Magazine and writes for other computer publications and Web sites. You can follow Lance on Twitter at @lancewhit. Lance is a member of the CNET Blog Network, and he is not an employee of CNET. 





The compiler should have shown a warning, though. Static code analysis would have found that. Heck, Visual Studio has a static code analyzer (not the best one, but it works). Seem they don't switch that on.
Wonder how many other typos will be discovered.
C++ doesn't hold your hand. You have to know what's safe and what isn't. If you do what isn't safe, then you can't blame the language/compiler for not helping you. For those that want hand holding at every turn, choose another language.
Time to move to modern languages guys...
C++ is a bloated mess, worse than Ada.C is an excellent lower level language, but you do need to know what you are doing, most "programmers" do not.
Amen
Most modern languages will greatly mitigate problems like this.
No one, however, writes an OS in a high level language. There are lots of reasons.
It would be curious to see what language they did write it in, though.
Scroll up to the absolute bang middle of the article and see the three lines of C++ staring you sqare in the face. I've long suspected (from reading your posts) that you aren't very tech savvy, but now I know..
One major problem though: Microsoft meets h@te in America, where as Navy and Coast Guard do not. If anything, what is funny is the SS Trashintosh went on a Safari and ended up swimming with the fishes on the bottom of the sea... along with the 20th Anniversary Macintosh!
PS: It's the SS Trashintosh because its a universally-respected POS. What it was doing on a Safari when Mozilla could have saved it is nobody's business, unless they rent scuba gear to fix it.
Unfortunately there is always social exploits.
Microsoft, where is *my* job?
Yeaaaaaaaaaah, I don't know that you should be throwing stones so close to your glass house.
I mean really now, look at that code again. It looks like something you'd see on an exam in a first year C++ course - spot the problem here. Anyone who doesn't get it shouldn't be writing any type of networking software, let alone a web browser, and that includes most API monkeys at Redmond.
The actual code also has a memory leak in case pStream->Read failed. This can be used for DOS.
All they have to do is actually switching it on...
Oh wait, or was that Linux? Okay, we'll send the EU hit squads out again to take out all the Macs and replace them with Linux systems.
Or... you could get al ife. Of all those options, I think this one is the most productive.
Or are some magical exceptions going to be caught somewhere upstream?
Reason #4,260 that Microsoft's software engineering ain't exactly MILSPEC.
Thank goodness for that! Go take a look at what MILSPEC means when implemented and you'll have all sorts of fun there.
Wow. Thats really special.
As I said, it's been a slow morning (not that unusual, considering the company has Mac clients connecting to an AIX server) so I thought I'd join in the fun.
Oh, one last thing (trying to throw napalm on the fire here) - fista, including sp3 (aka w7) comes with WGA built right in. Look it up, it's yet another "feature" that you won't find in a real OS. But that's OK, why would you want to have control of your own computer anyway? Tis better to blame others than to assume responsibility, right? The M$ killswitch is there for your protection, to protect you from your own stupidity and criminal intent. Resistance is useless! Submit to your master, slave!
Like some commenters mentioned, this should have been flagged by compile-time code analysis.
- by Patrick5651 July 31, 2009 9:06 PM PDT
- It seems that I've read somewhere that someone is attaching sound to code. Would it be doable to 'hear' something in the code that would be useful as an identifier for difficult situations as described?
- Like this Reply to this comment
-
(52 Comments)