The paper presents a cooperative bait detection scheme (CBDS) for enhancing security in mobile ad hoc networks (MANETs) against malicious nodes that may conduct collaborative attacks, specifically grayhole and collaborative blackhole attacks. CBDS integrates proactive and reactive defense strategies by using a dynamic source routing technique and a reverse tracing mechanism to identify and mitigate malicious nodes effectively. Simulation results indicate that the CBDS outperform existing protocols in terms of packet delivery ratio and routing overhead, making it a promising approach for secure communication in MANETs.