A serious bug that led to a series of fast-spreading worms on Twitter's website Tuesday had been fixed in August but was accidentally re-introduced.

The bug caused havoc until Twitter got it under control later on Tuesday morning. One of the worms sent out a blacked-out Twitter message to all the victim's followers. Another distributed Japanese pornography.

The worms were particularly virulent because victims didn't need to click on a link to spread them to their followers. All they had to do was hover over a specially written link sent in a Twitter message. That was enough to execute the malicious code.

"Probably hundreds of thousands of people were affected," said Beth Jones, a senior threat researcher with Sophos, which was early to report the issue. The cause: a basic Web programming error that allowed Twitter users to add JavaScript to their tweets.

It turns out that the whole mess could easily have been avoided. Indeed, it should have been.

"We discovered and patched this issue last month," Twitter said in a blog post Tuesday. "However, a recent site update (unrelated to new Twitter) unknowingly resurfaced it."

The bug had apparently been public knowledge since Aug. 23, when it was patched in the open-source text processing library used by Twitter.

That was bad news for Sarah Brown, the wife of former British Prime Minister Gordon Brown, who inadvertently spread the pornographic version of the worm to her 1.2 million followers.

White House Press Secretary Robert Gibbs was also hit. "My Twitter went haywire -- absolutely no clue why it sent that message or even what it is," he wrote in a Twitter message. "[P]aging the tech guys..."

This isn't the first time Twitter has been wormed. Last year, 17-year-old Michael Mooney unleased a series of worms on the social media site.

This time around, it was a Japanese hacker named Masato Kinugawa who discovered the issue, according to a report in the Guardian. Kinugawa had been sending Twitter messages about the issue for several days, but on Tuesday he decided to test it out with some worm code.

He created the worm that sent redacted text messages.

That first worm was soon copied by many others.

"The vast majority of exploits related to this incident fell under the prank or promotional categories," Twitter said in its blog posting. "Users may still see strange retweets in their timelines caused by the exploit. However, we are not aware of any issues related to it that would cause harm to computers or their accounts. And, there is no need to change passwords because user account information was not compromised through this exploit."

(Computerworld's Gregg Keizer contributed to this report.)

Robert McMillan covers computer security and general technology breaking news for The IDG News Service. Follow Robert on Twitter at @bobmcmillan. Robert's e-mail address is robert_mcmillan@idg.com