The information-rich world of Twitter was almost converted into total gobbledegook yesterday as hackers took advantage of a security flaw to create self-replicating "worms" that automatically posted themselves to users' accounts.

Any Twitter user who hovered their cursor over the unintelligible messages immediately risked spreading them to the accounts of their own followers. At its peak, more than 100 such messages were being generated every second, causing consternation among the Twitter community, who rely on the service for everything from breaking news to inconsequential amusement.

The effects of the worm ranged from harmless messing about to malicious redirects to unsavoury websites; at one point Sarah Brown, wife of the former British Prime Minister, unwittingly guided her 1.1 million devoted followers towards a Japanese pornography site.

"Don't touch the earlier tweet," she posted later. "This twitter feed has something very odd going on!"

Odd indeed - but also something that was easily preventable, and which will have caused embarrassment to Twitter in the week following the much-publicised roll-out of its relaunched website.

The way Twitter works meant the biggest damage was wrought by those with the largest number of followers. Sarah Brown was the most notable, but others included former deputy Prime Minister John Prescott, White House press secretary Robert Gibbs ("Absolutely no clue why it sent that message or even what it is") and comedian David Mitchell ("Apologies ... more evil robots, basically. Get used to them, I say.")

Users who had already been granted access to the new-look version weren't affected, and nor were those who interact with the service using applications on their computers or mobile devices.

The worm targeted those who access their accounts by logging on to the main Twitter site - the vast majority - hence the worms' rapid spread.

This type of attack is known as XSS or "cross-site scripting", and is the most common way for web security to be compromised. If a hacker can find a way to execute a script on a website, that script can gain access to sensitive details the browser might be holding on our behalf - including, as was the case here, the ability to automatically post messages on Twitter.

Awareness of the problem came to light yesterday, when the person behind an account called @RainbowTwtr realised the site's automatic conversion of website addresses within messages could be embellished with a potentially powerful code known as JavaScript.

Twitter patched this vulnerability within three hours, but XSS attacks will continue to affect users of popular websites as there will always be geeks keen to wreak havoc for financial gain.