Previous research on security of network coding focused on the protection of data dissemination procedures and the detection of malicious activities such as pollution attacks. The capabilities of network coding to detect other attacks have not been fully explored. In this paper, we propose a new mechanism based on physical layer network coding to detect wormhole attacks. When two signal sequences collide at the receiver, the starting point of the collision is determined by the distances between the receiver and the senders. Therefore, by comparing the starting points of the collisions at two receivers, we can estimate the distance between them and detect fake neighbor connections via wormholes. While the basic idea is clear, we have proposed several schemes at both physical and network layers to transform the idea into a practical approach. Simulations using BPSK modulation at the physical layer show that the wireless nodes can effectively detect fake neighbor connections without the adoption of special hardware or time synchronization.