We introduce and analyze models for the propagation of malware in pure D2D networks given via stationary Cox–Gilbert graphs. Here, the devices form a Poisson point process with random intensity measure λΛ, where Λ is stationary and given, for example, by the edge-length measure of a realization of a Poisson–Voronoi tessellation that represents an urban street system. We assume that, at initial time, a typical device at the center of the network carries a malware and starts to infect neighboring devices after random waiting times. Here we focus on Markovian models, where the waiting times are exponential random variables, and non-Markovian models, where the waiting times feature strictly positive minimal and finite maximal waiting times. We present numerical results for the speed of propagation depending on the system parameters. In a second step, we introduce and analyze a counter measure for the malware propagation given by special devices called white knights, which have the ability, once attacked, to eliminate the malware from infected devices and turn them into white knights. Based on simulations, we isolate parameter regimes in which the malware survives or is eliminated, both in the Markovian and non-Markovian setting.