Wormhole attacks can destabilize or disable wireless sensor networks. In a typical wormhole attack, the attacker receives packets at one point in the network, forwards them through a wired or wireless link with less latency than the network links, and relays them to another point in the network. This paper describes a distributed wormhole detection algorithm for wireless sensor networks, which detects wormholes based on the distortions they create in a network. Since wormhole attacks are passive in nature, the algorithm uses a hop counting technique as a probe procedure, reconstructs local maps in each node, and then uses a “diameter” feature to detect abnormalities caused by wormholes. The main advantage of the algorithm is that it can provide the approximate location of wormholes, which is useful in implementing countermeasures. Simulation results show that the algorithm has low false toleration and false detection rates.