Wireless sensor networks (WSNs) are widely used for environmental monitoring, industrial control, and smart agriculture, and “bad worm” outbreaks can lead to irreversible data loss, large-scale network failure, and even cascading damage to connected physical systems. In this paper, a novel i-SIR model is proposed to characterize the co-propagation dynamics of malicious worms (“bad worms”) and defensive worms (“good worms”) in wireless sensor networks (WSNs). Here, the “bad worm” refer to the malware that invades sensor nodes, steal data, disrupt communication, or paralyze network functions, while the “good worm” refers to the benign software that repairs infected nodes, blocks “bad worm” intrusion, and builds immune barriers. Th designed i-SIR model is able to comprehensively analyze worm spread and the corresponding countermeasures within a complex and resource-constrained WSN environment, especially capable of addressing the critical threat of “bad worms”. Through rigorous mathematical analysis, a basic reproduction number R0 (serving as a critical threshold to determine the extinction or persistence of worm propagation) is determined, and its sensitivity is further analyzed to key network parameters such as node density, communication range, and energy constraints. Numerical simulations demonstrate that the proposed i-SIR model is superior to classical statistical immune models in terms of speed and scale reducing rates of worm outbreak by 50% and 60%, respectively. Furthermore, by considering temporal variations in worm activity patterns, we investigate the impact from the infection rate ratio (between bad and good worms) on propagation dynamics. Such a ratio significantly suppresses the virulence and the scale of malicious worm spread, with more suppressing efficiency in densely deployed networks. This work provides a robust theoretical foundation for designing dynamic defense strategies in WSNs, and offers performable insights into time and density optimization of “good” worms in real-world WSNs.



