Like the malicious worms that spread from computer to computer by self-replicating and automatically seeking out new computers to infect, the friendly worms will be used to distribute updates to users without forcing them to download anything from a central server.
The research is being spearheaded by a team from Microsoft Research in Britain, and opens up the possibility of worm races between virus writers and the software companies to see who can reach vulnerable machines faster.
Unlike malicious worms seek to exploit vulnerabilities in operating systems, the friendly worms would seek to patch those vulnerabilities before the computer is attacked.
Milan Vojnovic, who is part of the research team, told New Scientist his friendly worms would be more efficient than malicious worms because they were smarter at seeking out vulnerable, unpatched machines. They could then "infect" a network of computers using the smallest number of probes.
Vojnovic said his worms were capable of learning from past experience.
The worm starts by randomly probing for an uninfected host and then targets other computers on the same network. If it fails to find a cluster of uninfected hosts it changes its strategy in order to maximise the number of computers it can patch.