Google has patched a hole that could have allowed malicious hackers to modify the content of search results pages, but a new hole may have already appeared.

The vulnerability concerns the Google Custom WebSearch service, which allows third-party Web portals and other sites to use Google's servers to search content on their website. A flaw in Google's servers allowed malicious hackers to insert javascript instead of links to image files, allowing them to alter the appearance of the Google search results page or steal search data.

After being alerted to the hole, Google fixed the vulnerability, said Nathan Tyler, a Google spokesman. "Google was recently alerted to a potential security vulnerability affecting users of our website. We have since fixed this vulnerability, and all current and future Google.com users are protected," Tyler said.

The company is also aware of a second vulnerability, discovered by UK security firm Netcraft and will be fixing its systems shortly to remove the vulnerability, he said.

The Custom WebSearch vulnerability was first reported in the online security newsgroup Bugtraq. Google's servers fail to validate URLs for image files to make sure they actually point to images. Malicious hackers could trigger the vulnerability using a Google custom search form, or even through a customized HTML link, by feeding Google's servers computer script instead of an image URL, according to the notice's author, who used the name "Jim Ley."

According to the notice's author, the vulnerability has existed for around two years without being fixed by Google, which was notified twice of the hole. The recent release of a desktop search tool from Google worsened the impact of the flaw, allowing hackers to use the Desktop Search feature to search for and steal content, such as passwords or personal financial information, from files on the local hard drive.

A number of major websites use the Google Custom WebSearch service, including Netscape, The Washington Post and Virgin.net.

In another example of how the flaw could be used, Ley posted a link on his Web site, www.jibbering.com, that replaced Google's main page with a page announcing that Google was becoming a for-fee search service and asking visitors to provide credit card information to sign up for the service.

The Google hole is an example of a common security problem affecting websites that dynamically generate pages based on input from unknown sources, according to a vulnerability note written in 2000 by the Computer Emergency Readiness Team.

Google developers appear to have missed that four-year-old warning and the company did not respond to repeated e-mails sent to an address for reporting security holes, Ley said. In patching it, Google developers changed their code to prevent javascript and vbscript, but may have left open other avenues of attack, Ley wrote in an e-mail.

"The problem with this approach is that it relies on them thinking of every possible thing they could exclude. There's so many ways to execute script, attempting to cover all the bases with this approach is risky," he wrote.

However, even as the company patched one hole, Netcraft said it discovered a different vulnerability that could allow attackers to inject malicious content in the Google site for online identity theft scams or other purposes.

The new hole is a script injection hole similar to the one reported by Ley and was found in a Google search feature that is accessible by anybody, said Paul Mutton, an Internet services developer at Netcraft. Like the vulnerability reported in Bugtraq, the new hole also allows malicious hackers to use malicious script to replace the content of the Google search results page and could be used to trick users into trusting the content displayed, Mutton said.

The company does not want to discuss specific details about the vulnerability. Mutton notified Google and was informed that the hole will be patched very soon, he said.