However, the worm, known as Ikee, is only a threat to users who have jaibroken their phones to let them run unauthorised software, security experts say.
In fact, Ikee doesn't do anything particularly bad - it changes the victim's wallpaper to a photograph of 80s singer Rick Astley and then seeks out other phones to infect - but it could be modified to do something more dangerous such as stealing sensitive information from the iPhone.
"There is a real danger that someone could take this code and make it do something malicious," said Graham Cluley, a technology consultant with security vendor Sophos.
The worm does not affect most iPhone users; only those with jailbroken iPhones that are running a Unix utility called SSH (Secure Shell) with the iPhone's default password, "alpine", still in use.
SSH lets someone connect to the iPhone remotely over the internet, so installing this software with the default password in place is akin to adding an unlocked back-door to the device. It doesn't affect users who use the phone in conjunction with Network Address Translation (NAT), a popular networking technology that lets many users share the same IP address.
Security experts have known about this particular risk for some time now. Last week a Dutch hacker started hacking into iPhones that were vulnerable to this attack and demanded €5 for instructions on how to fix the problem.
The worm was written Wednesday by Ashley Towns, a 21 year-old unemployed programmer from Wollogong, Australia. He hadn't heard of the Dutch incident when he released his worm, he said Sunday in an instant-message interview. "It was supposed to be a small prank i definitely wasn't expecting it to get as far as it did," he said.
Towns wanted to make the point that people should change their default iPhone passwords, especially if they're using SSH. "A lot of people especially at first thanked me," he said. "I think most people are relieved it's not out to destroy their phone. I have had a few people abuse me though."
He didn't really consider the possible legal ramifications of releasing the code, something he said was "quite naive of me," Towns said.
Once the worm adds the Rick Astley wallpaper, it disables the iPhone's SSH daemon and then looks around and then looks around on the Internet for other vulnerable iPhones to infect.
Tricking victims into playing a video or looking at a picture of Rick Astley -- best known for his hit "Never Gonna Give You Up" - is a popular Internet prank called Rickrolling.
It's not clear how many people have been affected by the worm, but Towns said that his phone alone infected about 100 other devices.
On Sunday, security vendor F-Secure said it had no confirmed reports of the worm spreading outside of Australia. F-Secure advises jailbroken iPhone users who want to secure their phones to follow these instructions.
News of the worm first started spreading several days ago, when users on an Australian technology discussion board complained that their iPhone wallpaper had been changed without authorization.
The worm's code was published Sunday by Joshua "JD" Davison, managing director with Australian ISP reseller JelTel, who earlier published a technical interview with Towns.
The worm may have upset iPhone users, but Apple may not mind. The iPhone's creator has been trying to put an end to jailbreaking for years, saying that it causes security and performance problems.
"They might be a little bit pleased to hear that people have got themselves into hot water," Cluley said.