In peer-to-peer networks, it is very difficult to route query successfully, since nodes in the routing path do not always behave according to pre-established routing protocols. To address this issue, we propose a secure protocol which consists of two phases: detecting malicious nodes and bypassing them. We present a novel efficient routing strategy called tracer routing to control routing progress, accompanied by a node-ID based signature scheme. Combining these two, the source of each query can verify each step and malicious nodes can be identified. We also present a scheme to create a secure path to bypass malicious nodes. With high probability, each query can successfully reach the destination even if there are a large number of malicious nodes in the system. Simulation results show the superiority of our protocol in comparison with previous protocols.