This document proposes a model for characterizing the propagation of Internet worms using a branching process model. It develops this model for uniform scanning worms and extends it to preference scanning worms. This model leads to the development of an automatic worm containment strategy that limits the total number of IP addresses contacted per host. The strategy is shown to effectively contain uniform and preference scanning worms through simulations and analysis, while having minimal impact on normal network operations.