Two weeks before a browser hacking contest is to kick off in Vancouver, British Columbia, Apple yesterday patched 16 vulnerabilities in Safari, 12 of them critical bugs that could be used to hijack a machine.

Apple updated Safari for both Mac OS X and Windows to version 4.0.5, hardening the browser before it's tossed into the ring with Microsoft's Internet Explorer (IE), Mozilla's Firefox and Google's Chrome at this year's Pwn2Own hacking challenge. The contest organizer has predicted that Safari would be the first to fall when researchers battle for $40,000 in prize money beginning March 24 at the CanSecWest security conference.

According to Apple's advisory , three-fourths of the vulnerabilities -- 12 of the 16 -- were labeled with Apple's "arbitrary code execution" phrase, meaning the flaws are critical and could be exploited to compromise a Mac or a Windows machine. Unlike other vendors, such as Microsoft and Oracle, Apple does not assign a threat ranking to the bugs it discloses.

Nine of the 16 flaws patched Thursday were in the open-source WebKit browser engine that forms the foundation of Safari; six affected only the Windows version, which runs on XP, Vista and Windows 7. Of the half-dozen Windows-only vulnerabilities, four were in the Image IO component, and could be triggered by specially-crafted TIFF or BMG image files when rendered by Safari.

Two of the 16 were reported to Apple by browser rivals. Billy Rios, a browser bug researcher who formerly worked for VeriSign but now is on the Microsoft Vulnerability Research (MSVR) team, was credited with one of the Windows-only flaws; Robert Swiecki of Google found one of the WebKit vulnerabilities.

The WebKit fixes may be timely. Last month, Aaron Portnoy, security research team lead with 3Com TippingPoint, the sponsor of Pwn2Own, bet that Safari would crumble at the contest in part because it's built "on the notoriously buggy WebKit."

Safari 4.0.5 also included stability improvements for unspecified third-party browser plug-ins, performance improvements for the Top Sites feature that shows users domains they visit most often, and fixes for non-security bugs in how the browser handles router settings and works with the iWork suite's Web-based document sharing site.

Safari is currently the world's No. 4 browser according to Web measurement company NetApplications.com, after being pushed down a spot in late 2009 by Chrome.