Many localization techniques for wireless sensor networks have been proposed to estimate sensor positions even when there is malicious location information which distorts the estimate. Some of those solutions efficiently estimate sensor positions using the Minimum Mean Square Estimation methods and the Degree-Of-Consistency (DOC). Although such solutions can filter out most of malicious information, if an attacker knows the position of the target sensor, the attacker can significantly alter its estimated position. In this paper, we introduce two attacks based on the knowledge of target sensor positions. The first attack, called Aligned-Beacon-Position (ABP) attack, exploits beacon nodes that are aligned in a line. The second attack, called inside-attack, disables the DOC filtering algorithm by placing malicious location references inside benign location references. To protect against those two known sensor position attacks, we introduce two defense schemes. First, we propose a novel beacon placement strategy to protect against ABP attacks. Second, we present a filtering technique that can filter out malicious location references introduced by inside-attacks. Finally, we propose a localization algorithm which has enhanced accuracy and efficiency compared with previous algorithms. We assess the impact of those attacks and the performance of our defense schemes by simulation and test-bed experiments.