The study of tumour virology has traditionally focused on oncogenic viruses and their associated mechanisms of cancer initiation and promotion. Yet certain viral exposures can be beneficial by enhancing antitumour immunity. In this Review, Wang et al. explore the increasingly emerging evidence of protective roles of viruses in cancer immunity and how this knowledge could be harnessed to develop a virome-guided framework for cancer immunoprevention.