Wireless sensor network (WSN) is the Internet of Things by a large number of sensors in the external physical environment to obtain data information, and use wireless communication technology to provide users with information transmission services. At this stage, communication and security mechanisms are the main problems faced by WSN. This is because most of the existing sensors are powered by batteries with very limited energy, and most of them are deployed in an outdoor open environment, which is easy to be captured as a malicious node. Network attacks. However, the existing malicious node detection methods have shortcomings such as low efficiency, high energy consumption, and insufficient performance. Therefore, this paper proposes a WSN malicious node intrusion detection method based on genetic algorithm optimization of LEACH hierarchical routing protocol. Based on the optimization of the LEACH protocol by genetic algorithm, the method integrates the reputation evaluation mechanism, and screens and eliminates malicious nodes by calculating direct reputation, indirect reputation and comprehensive reputation, thereby ensuring the safe operation of WSN. The simulation results show that this method can effectively resist the attack of malicious nodes on WSN, and has obvious advantages over other methods.