Wireless sensor networks (WSNs) are comprised of large collections of small devices having low operating power, low memory space, and limited processing capabilities referred to as sensor nodes. The nodes in WSNs are capable of sensing, recording, and monitoring environmental conditions. Nowadays, a variety of WSNs applications can be found in many areas such as in healthcare, agriculture, industries, military, homes, offices, hospitals, smart transportation, and smart buildings. Though WSNs offer many useful applications, they suffer from many deployment issues. The security issue is one of them. The security of WSNs is considerable because of the use of unguided medium and their deployment in harsh, physically unprotected, and unattended environments. This chapter aims to discuss various security objectives and security attacks on WSNs and summarizes the discussed attacks according to their categories. The chapter also discusses different security protocols presented to prevent, detect, and recover the WSNs from various security attacks.