Collaborative computing among peer mobile devices via device-to-device (D2D) links, a.k.a. D2D offloading, is a promising technology to enhance mobile computing performance and reduce core wireless network traffic. However, D2D offloading also creates new security risks as malware can relatively easily compromise mobile devices participating in D2D offloading and propagate across the entire network. In this paper, we build a new epidemic model to understand the malware propagation process in the D2D offloading-enabled network where mobile devices are strategically deciding their participation level. The system operator only indirectly controls their participation level via offering participation rewards. Based on this model, we further model the strategic interaction between the defender (i.e. the system operator) and the attacker (i.e. malware) as a zero-sum differential game. The existence of a saddle-point equilibrium is proved, and the optimal dynamic defender and attacker strategies are derived based on the Pontryagin's maximum principle. Numerical results validate the proposed model and show that the dynamic optimal strategies significantly improve the system utility compared with baseline strategies.