Due to their low complexity and robustness in nature, wireless sensor networks are a key component in cyber-physical system. The integration of wireless sensor network in cyber-physical system provides immense benefits in distributed controlled environment. However, the layered structure of cyber-physical system and wireless sensor network make it susceptible to internal and external threats. These threats may lead toward financial or structural losses in networks. The chapter is structured as such to provide classification of layer-to-layer, external and internal attacks to wireless sensor network and cyber-physical system. In addition to that, the chapter identifies the known security detection and possible approaches against the threats for wireless sensor networks and cyber-physical system. Finally, a comparison of approaches to defend wireless sensor network and cyber-physical system against such attacks is presented.