Wireless sensor network (WSN), which serves as one of the key components of the cyber physical system, is a wireless network composed of many stationary or moving sensors in a self-organizing and multi-hop manner. It cooperatively senses, collects, processes and transmits the information of the perceived objects in the geographical area covered by the network, and finally sends this information to the owner of the network. There are some typical attacks in WSN, such as Blackhole, Grayhole, Flooding and Scheduling attacks, which may cause damages to the WSN system in a short time. Moreover, intrusion detection methods for WSN suffer from the disadvantages of low detection rate, large calculation overhead, and high false alarm rate due to the limited resources of sensor nodes and a large amount of redundancy as well as high correlation of network data. In view of the above problems, we propose SLGBM, an intrusion detection method for wireless sensor networks. First, the sequence backward selection (SBS) algorithm is applied to reduce the data dimension on the feature space of the original traffic data so as to reduce the computational overhead. A LightGBM algorithm is then utilized to detect different network attacks. The experimental results based on the WSN-DS dataset show that F-measure of our proposed SLGBM are obviously superior to current typical detection methods, which are 99.8%, 99.4%, 99.1%, 96.5%, and 96.1% in Normal, Blackhole, Grayhole, Flooding, and Scheduling (TDMA) attack detections respectively.