Device to Device (D2D) communications is a candidate technology for the fifth-generation (5G) and beyond mobile networks and certainly that results in high throughput, less energy consumption, reduce delay, and data traffic offload. Proximity services are the key enablers of D2D communications. A D2D technology boosts the performance and capacity of a conventional cellular system through the proximity services. To initiate the proximity services, Device Discovery (DD) is one of the the primary tasks. A DD makes the decision for effective D2D communications in terms of accuracy, speed, and minimum energy consumption. To discover the neighbor devices, the discovery signal is transmitted directly or through some access points. The discovery signal is affected by invaders during transmission which causes inaccuracy, energy consumption, and latency. Therefore, security and privacy issues must be addressed, especially in discovery signal transmission. In this paper, security and privacy issues in DD are highlighted. It is comprehensive and proves that in-band is much better than out-band with practical and technological reasons. To enhance the scope of the research, network level, and system level Security and Privacy (S&P) issues in the distributed and centralized systems environment with or without central management are surveyed. Along with an extensive survey is provided for the most recent work on DD concerning security and privacy issues, and comparison among in-band and out-band DD is performed. In the end, open issues are identified as future work on DD security and privacy in D2D communications. It is a novel survey in terms of security and privacy aspects of DD with possible suggested solutions for readers' motivation.