The flexibility and openness of mobile ad hoc networks (MANETs) make them attractive for various types of applications such as military communication, emergency search and rescue operations, disaster recovery, battlefields, communication between moving vehicles (VANET etc. However, MANETs are highly susceptible to various security threats due to their inherent characteristics that can adversely affect their performance. In order to provide secure communication in mobile ad hoc networks, it is required to understand various possible attacks at different layers of the communication protocol stack. The intent of this paper is to provide structured and comprehensive study of prominent security attacks reported in the literature for mobile ad hoc networks. In addition, we also discuss various well-known reactive and proactive security solutions proposed in literature to prevent those attacks in MANETs. Finally, the paper is concluded with a brief discussion on future direction of research in MANETs.