We study how the spread of computer viruses, worms and other self-replicating malware is affected by the logical topology of the network over which they propagate. We consider a model in which each host can be in one of 3 possible states—susceptible, infected or removed (cured and no longer susceptible to infection). We characterize how the size of the population that eventually becomes infected depends on the network topology. Specifically, we show that if the ratio of cure to infection rates is larger than the spectral radius of the graph, and the initial infected population is small, then the final infected population is also small in a sense that can be made precise. Conversely, if this ratio is smaller than the spectral radius, then we show in some graph models of practical interest (including power law random graphs) that the average size of the final infected population is large. These results yield insights into what the critical parameters are in determining virus spread in networks.