Protecting K-Nearest Neighbor Queries from Location Inference Attacks Zhiyu Sun1∗ , Jie Fu2∗ , Xinpeng Ling3 , Huifa Li4 , and Zhili Chen1 (
)
East China Normal University, China [email protected] 2 Stevens Institute of Technology, USA 3 Tongji University, China 4 Mohamed bin Zayed University of Artificial Intelligence, UAE
arXiv:2606.05648v1 [cs.CR] 4 Jun 2026
1
Abstract. The k-nearest neighbor query (kNNQ) is a core component of modern location-based services (LBS) and has been widely adopted in popular features such as “people nearby”. However, its potential privacy risks have long been overlooked. In this work, we present the first two attacks against kNNQ, namely the geometric intersection location inference attack (GI-LIA) and the zero-order optimization location inference attack (ZO-LIA), revealing the inherent location privacy risks posed by kNNQ. To mitigate these privacy risks, we further propose DPRS, a differential privacy framework for kNNQ protection. The core idea of DPRS is to incorporate a rejection sampling mechanism within a constrained perturbation interval, thereby mitigating the distance distortion caused by excessive noise injection. In addition, we design a private interval construction algorithm to construct the perturbation interval, enabling the rejection sampling mechanism to achieve a more favorable tradeoff between privacy protection and query utility in kNNQ. Extensive experiments on real-world spatial datasets demonstrate that DPRS outperforms existing methods in both privacy protection and query utility. Our code is available at https://github.com/reanatom/DPRS. Keywords: K-nearest neighbor query · Location inference attack · Differential privacy
1
Introduction
Location-Based Services (LBS) have become a fundamental component of modern mobile applications [14,15,16], but they also introduce significant privacy risks. Prior work has demonstrated that attackers can infer users’ true locations from obfuscated location information. Existing location inference attacks (LIAs) typically exploit distance information [6], spatial regions [23], or user trajectories [21,19] to recover sensitive location data. ∗
Both authors contributed equally to this work.
2
Zhiyu Sun, Jie Fu, Xinpeng Ling, Huifa Li, and Zhili Chen (
)
However, location privacy threats in k -nearest neighbor query (kNNQ) services (e.g., “nearby people” features) have been largely overlooked. To the best of our knowledge, location inference attacks specifically targeting kNNQ services have not been systematically studied. In such systems, attackers may exploit the ranked neighbor list returned by the API to infer the precise location of a target user. Given the widespread use of kNNQ in social and recommendation applications (such as Tinder [6]), this work systematically investigates location privacy risks in kNNQ services and proposes an effective defense mechanism to mitigate such threats. Attack design and evaluation. We propose two location inference attacks against kNNQ services: the Geometric Intersection-based LIA (GI-LIA) and the Zero-order Optimization-based LIA (ZO-LIA). GI-LIA leverages distance relationships between the attacker at multiple query locations and the target, and solves the target’s coordinates using geometric intersection. In contrast, ZOLIA estimates a pseudo-gradient from the target’s ranking information in query results and iteratively approximates the target’s true location. Experimental results demonstrate that both attacks are highly effective, achieving inference success rates above 95%. These findings indicate that current kNNQ services face severe privacy risks even when users’ exact coordinates are not explicitly disclosed. Design of defense method. To mitigate location privacy risks in kNNQ, we propose DPRS, a privacy-preserving perturbation framework. DPRS perturbs original location data within a carefully constructed privacy region, thereby reducing distance distortion among nearest neighbors. To achieve this goal, we design a rejection-sampling-based location perturbation mechanism that repeatedly proposes and tests candidate locations within a specified interval to ensure the resulting samples follow the target distribution. This mechanism also constrains perturbed samples within the interval, preventing excessive deviation. Applying rejection sampling to DP-kNNQ poses two key challenges: guaranteeing differential privacy under the altered noise distribution and selecting an appropriate perturbation interval to preserve query utility. To address them, we characterize the post-rejection noise using Rényi divergence and design a private interval construction algorithm that adaptively determines the perturbation interval. Evaluation. We conduct extensive experiments on two real-world datasets and two synthetic datasets to evaluate the performance of DPRS. The results show that DPRS effectively protects location privacy and significantly reduces privacy leakage. In particular, under a low privacy budget, DPRS reduces the success rates of both GI-LIA and ZO-LIA attacks to below 3%, demonstrating the robustness of the proposed defense. Moreover, under the same privacy budget, DPRS consistently outperforms three state-of-the-art location differential privacy methods [1,7,18] across multiple utility metrics. The main contributions of this paper are summarized as follows: – We present the first location inference attacks against kNNQ services, exposing serious privacy risks in existing kNN-based location services.
Protecting K-Nearest Neighbor Queries from Location Inference Attacks
3
– We propose DPRS, a privacy-preserving framework for kNNQ that achieves a better privacy–utility trade-off through constrained perturbation. – We establish an RDP-based privacy guarantee for the rejection sampling mechanism and derive its utility bound under the default interval. – Experiments on two real-world and two synthetic datasets show that DPRS consistently outperforms existing methods in both privacy protection and query utility.
2
Background and Related Work
Existing location inference attacks (LIAs) deduce true locations from obfuscated data using probabilistic models and contextual information [1,21,19,3], but fundamentally rely on access to coordinate data or trajectory. This work explores a more stringent scenario: the LBS only returns an anonymous, ranked list of k-nearest neighbors (kNN) [13]. This operation, known as a k-nearest neighbor query (kNNQ), is a fundamental block in numerous modern applications and is defined as follows: Definition 1. (K-nearest neighbor query [13]) For a query object q ∈ O and a query parameter k, the k-nearest neighbor query returns the smallest set N Nq (k) ⊆ D that contains (at least) k objects from the database, satisfying: N Nq (k) = {o ∈ D | d(o, q) ≤ d(ok , q)},
(1)
where ok is the k-th closest object to q in the database D. Although kNNQ seemingly protects privacy by concealing coordinates, its ranked list forms a potent side-channel highly susceptible to location inference. Differential privacy (DP) [5] is currently the gold standard for geolocation protection. Definition 2. (Differential Privacy [5]). The algorithm A provides (ϵ, δ)Differential Privacy, if for any two neighboring datasets D and D′ that differ in only a single entry, ∀S ⊆ Range(A), the following holds: Pr(A(D) ∈ S) ≤ eϵ × Pr(A(D′ ) ∈ S) + δ.
(2)
DP, foundationalized by geo-indistinguishability [1], is widely applied in LBS [20,12]. However, existing DP-kNNQ methods suffer from severe flaws: L-SRR [18] can only perform kNNQ by perturbing users to a finite, predefined set of points of interest (POIs). This approach severely distorts the data’s underlying spatial distribution, rendering the dataset unusable for other aggregation analyses. Meanwhile, other methods, such as ReuseKNN [11], provide uneven protection; they only apply perturbation to a small subset of users deemed vulnerable, leaving the broader user population with weaker privacy guarantees. Schemes like FedKNN [22], on the other hand, only perturb each participant’s contribution weight, rendering their security entirely dependent on hardware isolation and
4
Zhiyu Sun, Jie Fu, Xinpeng Ling, Huifa Li, and Zhili Chen ( Coordinate
Locations
Other Users Colluder
Target User
)
Adversary
Attack k-NN Training LBS Platform
Fig. 1: Threat model
creating a catastrophic “all-or-nothing” privacy risk. To overcome these limitations, we propose the DPRS mechanism. In this paper, we use a more powerful privacy framework: Rényi Differential Privacy (RDP) [10] for privacy loss analysis. Definition 3. (Rényi Divergence [17]) Given two probability distributions P and Q, the Rényi divergence of order α > 1 is: α 1 P (x) Dα (P ∥Q) = ln Ex∼Q , (3) α−1 Q(x) where P (x), Q(x) denotes the probability density of P , Q.
3
Problem Setup
We consider a location-based service (LBS) platform that maintains a set of users U = {u1 , u2 , ..., uN }, where each user ui is associated with a 2D geographic coordinate Li = (xi , yi ). The LBS server supports the kNNQ interface that allows a user to submit a query location Lq and obtain a ranked list of the k nearest users based on their distances to Lq . Formally, given a query location Lq , the server returns an ordered list: kNNQ(Lq ) = [u(1) , u(2) , ..., u(k) ].
(4)
To protect user privacy, the server does not reveal the exact distance values or the precise locations of users. Instead, it only returns the ranked order of users. 3.1
Threat Model
We consider the adversary who is a legitimate registered user of the LBS platform and has normal access to the kNNQ API. The adversary cannot compromise the server or access its internal data structures, and can only interact with the system through API queries. The adversary possesses the following capabilities:
Protecting K-Nearest Neighbor Queries from Location Inference Attacks
5
– API Access. The adversary can repeatedly issue kNN queries from arbitrary locations and observe the returned ranked list of anonymized user IDs. – Collusion. The adversary can collaborate with one or more colluding users whose precise locations are known to the adversary. These colluders act as mobile probes that can move to different locations and report their exact coordinates. – Adaptive Queries. The adversary can adaptively change the probe locations and repeatedly query the API to observe how the ranking of the target user changes with respect to other users. Figure 1 illustrates the threat model. Although the server does not reveal distance values, the ranking output implicitly encodes relative distance information. In particular, when a probe moves to a location where the rank of the target user changes relative to another user, this event indicates that the probe lies on a boundary where the distances to the two users become equal. Practicality of the Attack. This attack scenario naturally arises in many realworld location-based services. To protect user privacy, many LBS platforms avoid revealing exact locations or distances and instead return a ranked list of nearby users. For example, social applications such as Tinder [6] provide “nearby users” functionality that displays profiles ordered by proximity while hiding precise coordinates or distance values. Since such services are accessible through mobile interfaces or public APIs, an adversary can repeatedly issue queries from different locations—either by moving their own device or collaborating with colluding users, and observe how the target user’s rank changes. These observations enable the adversary to gradually infer the target user’s location. 3.2
Attack Formulation
Let the true location of the target user be Lt = (xt , yt ). The adversary interacts with the LBS server by issuing a sequence of kNN queries from different probe locations. Let Q = {q1 , q2 , ..., qn } denotes the set of query results obtained from the server, where each query result qi corresponds to the ranked list returned by the kNNQ interface at probe location Li . Meanwhile, the adversary also maintains a set of colluding probe locations C = {c1 , c2 , ..., cl }, where each cj represents the exact coordinate of a colluder used in the probing process. Through adaptive probing, the adversary observes the positions where the ranking of the target user changes relative to other users. Based on the collected query results and probe locations, the adversary aims to design a location inference algorithm.
A : (Q, C) → Linf , which outputs an estimated location of the target user: Linf = (xinf , yinf ).
(5)
6
3.3
Zhiyu Sun, Jie Fu, Xinpeng Ling, Huifa Li, and Zhili Chen (
)
Measurement of the Attack
To quantitatively evaluate the effectiveness and efficiency of the proposed attack, we adopt three metrics. Error Distance (Dist). We measure the average inference error between the estimated location and the true location of the target user. Given a set of N attack instances, the average error distance is defined as below: N
Dist =
1 X (i) (i) d Linf , Lt , N i=1 (i)
(6) (i)
where d(·) denotes the Euclidean distance, Linf is the inferred location, and Lt is the true location of the i-th target user. Attack Success Rate (Acc). We define a successful attack as one where the inferred location lies within a predefined distance threshold τ from the true location. The attack success rate is defined as follows: Acc =
N 1 X (i) (i) 1 d(Linf , Lt ) ≤ τ , N i=1
(7)
where 1[·] is the indicator function. In our experimental evaluation, we set τ = 100 meters by default, following the commonly adopted evaluation standard in location privacy research [1]. Attack Cost (Cost). To measure the efficiency of the attack, we compute the average time required to complete an attack instance: N
Cost =
1 X Ti , N i=1
(8)
where Ti denotes the time (seconds) to infer the location of the i-th target user. Among these metrics, Dist and Acc reflect the attack effectiveness, while Cost measures the attack efficiency.
4
Our Attack Methods
In this section, we present two attack methods against KNNQ. We first introduce a geometry-based attack and analyze its inherent limitations in terms of communication overhead. We then propose a more communication-efficient attack framework that leverages zeroth-order optimization to achieve a better trade-off between attack effectiveness and efficiency. 4.1
A Straw-man Approach: GI-LIA
The first approach to location inference is based on geometric triangulation. We refer to this baseline method as the Geometric Intersection Location Inference
Protecting K-Nearest Neighbor Queries from Location Inference Attacks
7
Attack (GI-LIA). The key idea is to infer the target’s location by determining the intersection points of two circular trajectories on which the target must reside. First, the attacker establishes an initial circular trajectory centered at an attack point A1 . Specifically, the attacker determines the radius R1 of the circle C(A1 , R1 ) through a binary search procedure assisted by a collaborator. The collaborator moves radially with respect to A1 , while the attacker repeatedly issues kNNQ queries. By adjusting the collaborator’s distance from A1 , the attacker identifies a distance R1 at which the collaborator’s rank in the query result becomes exactly k. Since the target also appears at rank k, the target must lie on the circumference of C(A1 , R1 ). Next, the attacker selects a second attack point A2 to obtain another geometric constraint. The attacker performs a search over candidate locations for A2 , ensuring that (i) A2 is sufficiently distant from A1 to provide geometric stability and (ii) the target remains within the kNNQ result set. Once such a point is found, the attacker repeats the binary search procedure to determine the second circular trajectory C(A2 , R2 ). The intersection of the two circles C(A1 , R1 ) and C(A2 , R2 ) yields two candidate locations {P1 , P2 }. The attacker then issues verification queries at these candidate points and selects the location that yields the lower rank for the target as the inferred target position. The total communication overhead of GI-LIA can be expressed as: R2 1 CostGI−LIA = CostR binary + Costsearch (A2 ) + Costbinary + 2,
(9)
where Costbinary denotes the query cost of a single binary search used to determine a circle radius, and Costsearch (A2 ) represents the cost of locating the second attack point A2 . The final term accounts for the two verification queries at candidate locations P1 and P2 . Because both the binary search procedures and the search for A2 require numerous queries, GI-LIA incurs substantial communication overhead, making it inefficient and impractical for real-time or stealthy attacks. 4.2
Improvement: ZO-LIA
To reduce the excessive communication overhead of GI-LIA, we propose an efficient zeroth-order optimization location inference attack (ZO-LIA). Unlike the GI-LIA, ZO-LIA avoids constructing a second geometric constraint. Instead, it performs a rank-guided local search within the feasible region defined by the first constraint circle and then projects the result onto the circle boundary. The overall process is illustrated in Figure 2. Phase ①: Radius Search. ZO-LIA first determines the initial constraint circle C(A1 , R1 ) using the same radius search procedure described in GI-LIA. By performing a binary search with the help of a collaborator, the attacker finds a distance R1 such that the collaborator appears at rank k in the kNNQ results. Since the target also appears at rank k, the target must lie on the circumference of C(A1 , R1 ). Phase ②: Probe Generation and Evaluation. Instead of constructing a second circle, ZO-LIA generates a set of probe points around the circle center A1 .
8
Zhiyu Sun, Jie Fu, Xinpeng Ling, Huifa Li, and Zhili Chen ( Radius Search
Constrained Projection
r Rank( ) = K
Final Estimation
)
Rank Optimization
𝑬𝒕 = 𝑬𝒕−𝟏 − 𝜼 ⋅ 𝒈𝒕
Rank( ) ≈ Rank( ) K-5
Probe Generation and Evaluation K+1
K-5
K K-2
K
𝒔𝒊 = −𝑹𝒂𝒏𝒌𝒊 ( ) 𝒎
K-2 K+1
𝒈𝒕 = − 𝒔𝒐𝒇𝒕𝒎𝒂𝒙 𝒔𝒊 ⋅ 𝒗𝒊 𝒊
Fig. 2: The framework of ZO-LIA
These probes are sampled along multiple directions in the local neighborhood. For each probe point, the attacker issues a kNNQ query and records the target’s rank. The rank serves as a score indicating how promising the corresponding direction is for approaching the target. Phase ③: Rank Optimization. This phase constitutes the core of ZO-LIA. We employ a zeroth-order optimization strategy that relies solely on rank feedback. Using the rank scores obtained from the probe evaluations, the attacker estimates a pseudo-gradient that approximates the direction in which the target’s rank decreases most rapidly. The attacker’s position is then iteratively updated along this estimated direction, gradually moving toward an internal point Popt that minimizes the observed rank of the target. Phase ④: Constrained Projection. Once the search converges to the internal point Popt , a final constrained projection step is applied. Because the target must lie on the circumference of C(A1 , R1 ), the attacker orthogonally projects Popt onto the circle boundary. This projection is a simple local computation with constant complexity and produces the final estimate of the target’s location. The total communication overhead of ZO-LIA is given by CostZO−LIA = Costbinary + Niter · Cost0−iter ,
(10)
where Costbinary denotes the query cost of the initial radius search, Niter is the number of optimization iterations, and Cost0−iter represents the number of probe queries per iteration. 4.3
Attack performance in real-world scenarios
We evaluate our attacks on two real-world and two synthetic datasets. The evaluation metrics include Dist, Acc, and Cost (see §3.3). We consider k = 10, k = 30,
Protecting K-Nearest Neighbor Queries from Location Inference Attacks
9
Table 1: The performance of ZO-LIA and GI-LIA methods across four datasets. Method Dataset
k=10
k=30
k=50
Dist Acc Cost Dist Acc Cost Dist Acc Cost brightkite 28.91 0.948 15.94 40.59 0.914 17.62 41.98 0.912 19.21 gowalla 39.20 0.960 16.05 56.03 0.906 17.86 56.83 0.926 18.92 ZO-LIA gaussian 24.35 0.956 22.14 42.17 0.910 23.21 43.56 0.893 24.08 beta 40.39 0.944 22.17 43.96 0.896 23.09 48.51 0.873 23.96 brightkite 26.93 0.972 31.86 32.67 0.984 33.07 25.74 0.996 35.12 gowalla 20.59 0.996 31.42 24.55 0.992 34.67 23.56 0.992 35.98 GI-LIA gaussian 26.31 0.940 44.42 18.34 0.968 45.97 29.98 0.964 48.13 beta 39.96 0.948 43.21 41.67 0.948 45.07 51.84 0.976 47.31
and k = 50. For each k, we perform 5 independent runs with 50 attack instances per run, and report the average results. The results are shown in Table 1. Other attack setups are provided in Appendix A.1. Attack effectiveness. The results demonstrate that both attacks achieve consistently high effectiveness across all datasets. In particular, both GI-LIA and ZO-LIA maintain success rates above 90% under most settings, indicating that kNNQ-based LBS systems are highly vulnerable to location inference attacks. Among the two methods, GI-LIA achieves the best attack performance. It consistently yields the lowest average distance error and the highest success rates across datasets and k-values. For example, on the Brightkite dataset with k = 10, GI-LIA achieves a success rate of 0.972 with an average distance error of only 26.93 meters. These results confirm that the geometric intersection strategy can accurately recover the target’s location. Attack efficiency. Although GI-LIA achieves the highest attack accuracy, it incurs significantly higher communication overhead. In contrast, ZO-LIA substantially reduces the attack cost while maintaining high success rates. As shown in Table 1, ZO-LIA consistently requires roughly half the execution time of GILIA across all datasets and k-values. For instance, on the Brightkite dataset with k = 30, the time overhead of ZO-LIA is 17.62 seconds, compared to 33.07 seconds for GI-LIA. This reduction implies fewer queries are needed, making ZO-LIA faster, stealthier, and more practical for real-world attacks.
5
Proposed Defense Method: DPRS
To protect location privacy under kNN queries, we propose the DPRS mechanism. DPRS perturbs the geographic locations in the dataset to produce a new location dataset that strictly satisfies differential privacy guarantees. As illustrated in Figure 3 and Algorithm 3, DPRS consists of two main components: (i) Private Interval Construction (PIC): Establishes a private, data-aware interval for the perturbation. (ii) Reject Sampling Mechanism (RSM): The
10
Zhiyu Sun, Jie Fu, Xinpeng Ling, Huifa Li, and Zhili Chen (
)
Algorithm 1: Private Interval Construction (PIC) Input: dataset D, sensitivity 2r + 1, number of clusters m, number of iterations Nc , noise parameter of Lap distribution λc , radius scaling γ. Output: m private centroids. 1 Initialize k centroids by initial centroid selection. 2 for iter ← − 1 to Nc do 3 Get m clusters through the standard k-means. 4 Recalculate the centroid of each cluster. 5 for j ← − 1 to m do 6 for i ← − 1 to d do 7 sum′ (Cj∗ )[i] = sum(Cj∗ )[i] + Lap(0, λc ). 8 num′ (Cj∗ ) = num(Cj∗ ) + Lap(0, λc ). 9
sum′ (C ∗ )
cj = num′ (Cj∗ ) . j
for j ← − 1 to m do 11 Find the nearest centroid cmin from all centroids excluding cj . 12 Rj = γ · distance(cj , cmin ). 13 Ij = (cj , Rj ). 14 return m private intervals {I1 , I2 , . . . , Im }. 10
core engine that efficiently perturbs data into the private interval constructed by the previous module. Private-Interval-Construction
Reject-Sampling-Mechanism
DP AVG
Original data
Private interval
Reject sampling
Private data
Fig. 3: Overall framework of DPRS
5.1
Private Interval Construction
The privacy interval is designed as a Euclidean ball, consisting of two components: a private center and a private radius. Ideally, to avoid introducing excessive noise offset, the private center should be as close as possible to the original sample. However, directly perturbing the original sample to serve as the interval center would introduce significant distance errors. To address this issue, the DPk-means algorithm is introduced to obtain more stable and differentially private centers by injecting noise during the aggregation stage. In addition, the private radius is determined by the distance between the two nearest private centers, thereby eliminating the need for additional privacy budget.
Protecting K-Nearest Neighbor Queries from Location Inference Attacks
11
Algorithm 2: Rejection Sampling Mechanism (RSM) Input : data x, norm n, interval I (center xc , radius R), sensitivity 2r, Lap distribution p(·|x, λp ), target function f (·) ∝ p(·|x, λp ). Output: perturbed data x′ . 1 if ∥x − xc ∥k ≤ R then 2 M ← 1. 3 else 4 B ← GetBoundary(xc , R). 5 z∗ ← minz∈B ∥z − x∥n . 6 M ← f (z∗ ). 7 while true do 8 u, u1 , u2 ← RandomUniform(0, 1). √ 9 R ← R u1 , θ ← 2πu2 . ′ 10 x ← xc + (R cos(θ), R sin(θ)). ′
11 12
) if u < f (x then M return x′ .
As shown in Algorithm 1, PIC is implemented as follows. In each iteration, after samples are assigned to their clusters, the sensitive centroid recomputation step is protected. Specifically, the coordinate sums and the member counts of each cluster are concatenated, and calibrated Laplace noise is injected. The combined operation has a total L1 sensitivity of 2r + 1. The private radius of each centroid is then set to half of the distance to its nearest neighboring centroid, which naturally defines the corresponding privacy interval. 5.2
Reject Sampling Mechanism
The rejection sampling mechanism efficiently perturbs private data into the privacy interval constructed by the PIC module. We begin by specifying a base noise distribution, typically p(·) = Lap(· | x, λ). By normalizing the 2D location data to the range [−r, r], the L1 sensitivity is bounded by 2r, which enables calibrated noise injection. To perturb data within the specified Euclidean sphere, we define f (·) ∝ p(·), thereby avoiding the computation of the normalization constant. Rejection sampling is then used to generate valid perturbed samples. This procedure requires an upper bound M of f (·) within the sphere in order to compute the acceptance probability. As shown in Algorithm 2 (Lines 1–6), a tight bound M is obtained under either the L1 norm (Laplace mechanism) or the L2 norm (Gaussian mechanism) by evaluating a set of candidate points on the boundary of the sphere via GetBoundary(xc , R) (Line 4). Furthermore, we also extend RSM to the Gaussian distribution in Appendix B. Given these components, the mechanism iteratively performs rejection sampling until a valid sample is accepted. Specifically, a candidate point x′ is first drawn uniformly from the sphere. The acceptance ratio f (x′ )/M is then computed, followed by drawing a random variable u ∼ U (0, 1). The candidate is
12
Zhiyu Sun, Jie Fu, Xinpeng Ling, Huifa Li, and Zhili Chen (
)
Algorithm 3: Overall algorithm of DPRS Input : dataset D, cluster number m, iteration Nc , noise parameter λp , λc . Output: perturbed dataset D′ . 1 {I1 , I2 , . . . , Ik } ← PIC(D, m, Nc , λc ). 2 Partition D into m clusters {C1 , C2 , . . . , Cm }. ′ 3 D ← ∅. 4 for j ← 1 to m do 5 for x ∈ Cj do 6 x′ ← RSM(x, Ij , λp ). 7 D′ ← D′ ∪ {x′ }. ′ 8 return D .
accepted if u ≤ f (x′ )/M ; otherwise, the sample is rejected and the process repeats. Additionally, Theorem 7 and Theorem 8 in the Appendix C.2 guarantee the distributional correctness of the rejection sampling mechanism and provide an upper bound on utility.
6
Privacy Analysis
We first analyze the privacy of the PIC (Algorithm 1) and RSM modules (Algorithm 2), then present the total privacy budget of DPRS (Algorithm 3). 6.1
Privacy Analysis of DPRS Components
ϵc Theorem 1. Algorithm 1 satisfies (α, α−1 )-RDP, where
ϵc =3Nc log
α exp 2α − 1
α−1 λc
α−1 exp + 2α − 1
−α λc
.
(11)
Proof. Let D be a dataset partitioned into k disjoint clusters, C1 , . . . , Ck . A neighboring dataset D′ is formed by removing a single point, such that D′ = D \ {x} for some x ∈ D, and the partition on D′ is composed of clusters C1′ , . . . , Ck′ . There exists an index J such that CJ′ = CJ \ {x} and Cj′ = Cj elsewhere. Therefore, each iteration can be regarded as the parallel composition of mechanisms querying function f (·) over k disjoint clusters, and differential privacy achievement is determined by the mechanism over cluster CJ (since mechanisms ′ ′ over other clusters Cj achieve 0-differential privacy for Cj = Cj ). Let p(·) and p′ (·) denote the probability density functions of the mechanism over cluster CJ . For any point v ∈ D2×N , its RDP characterization is formed by the composition of three single-dimension Laplace mechanisms, each with a sensitivity of 1, iterated Nc times. The first two mechanisms correspond to the position dimensions, and the last one corresponds to the counting dimension. According to Lemma 1 (§6.2), its privacy characterization is as follows:
Protecting K-Nearest Neighbor Queries from Location Inference Attacks
3Nc Dα (p(v)||p (v)) = log α−1 ′
α exp 2α − 1
α−1 λ
13
α α−1 . + exp − 2α − 1 λ (12)
Therefore, Theorem 1 is proved. ϵ
p Theorem 2. Algorithm 2 satisfies (α, α−1 )-RDP, where
ϵp =2 log
α exp 2α − 1
α−1 λp
+
α−1 exp 2α − 1
−α λp
.
(13)
Proof. let Dα (S) be RDP of Algrithm 2, according to Lemma 5 (Appendix C.2) we have: Dα (S) ≤ Dα (Lap(t|0, λ)||Lap(t|µ, λ)).
(14)
In fact, the Rényi divergence of the multidimensional Laplace distribution has no analytical expression. Therefore, we characterize the Rényi differential privacy of the multidimensional Laplace distribution as a combination of different dimensions. According to Lemma 1 (§6.2), we have: Dα (Lap(t|0, λ)||Lap(t|µ, λ)) = 2Dα (Λ(0, λ)||Λ(µ, λ)).
(15)
Therefore, we have: Dα (S) α 1−α Z ∞ 2 1 − |x−µ| 1 − |x| log e λ e λ dx α−1 2λ 2λ −∞ Z ∞ 1 α|x − µ| − (α − 1)|x| 2 log exp − dx = α−1 2λ −∞ λ !! Z 0 Z µ Z ∞ αµ−(2α−1)x x−αµ 2 1 − αµ−x − − λ = log e λ dx + e dx + e λ dx α−1 2λ −∞ 0 µ ! (a−1)µ 2 1 1 1 1 − aµ = log − e λ + + e λ α−1 2 2(2α − 1) 2 2(2α − 1) ! αµ 2 α (α − 1)µ α−1 = log exp + exp − . α−1 2α − 1 λ 2α − 1 λ ≤
(16) For single-dimension Laplace noise, it is normalized to the range of [−1, 1], so we set µ = 1. Therefore, Theorem 2 is proved.
14
Zhiyu Sun, Jie Fu, Xinpeng Ling, Huifa Li, and Zhili Chen (
)
Table 2: Statistics of the datasets
6.2
Type
Dataset
Locations Density Dispersion Index
Real-World
Brightkite [4] Gowalla [4]
18,409 17,738
11.76 11.33
0.26% 0.32%
Synthetic
Gaussian [8] Beta [9]
25,000 25,000
15.97 15.97
0.61% 0.70%
Overall Privacy Analysis of DPRS
To derive the total privacy loss, we compose the guarantees from Theorem 1 and 2. This relies on two standard lemmas from the RDP literature: Lemma 1. (Composition Theorem [10]). Let two queries f , g be (α, R1 ) and (α, R2 )-RDP respectively. Then their composition (f, g) is (α, R1 + R2 )-RDP. Lemma 2. (Conversion Theorem [2]). If f is an (α, R)-RDP query ,then it satisfies(R + ln((α − 1)/α) − (ln δ + ln α)/(α − 1), δ)-DP for any 0 < δ < 1. By applying Lemma 1 to the results of Theorem 1, 2, and then applying Lemma 2, we arrive at the final privacy guarantee for the DPRS framework: Theorem 3. Algorithm 3 satisfies (ϵT otal , δ)-DP, where ϵT otal =
7
ϵc + ϵ p α−1 log(δ) + log(α) + log( )− . α−1 α α−1
(17)
Evaluation
In this section, we mainly examine the trade-off between defense effectiveness and KNNQ utility achieved by DPRS and the baselines in the KNNQ task, and further analyze the impact of key parameters on DPRS. There are additional experiment results that can be found in Appendix D. 7.1
Setup
We evaluate DPRS and three baselines (SRR [18], Square [7] and Laplace [1]) on four datasets under various k-NN settings. There are two real-world datasets (Brighktite [4] and Gowalla [4]) and two synthetic datasets (Gaussian [8] and Beta [9]). We restrict the real-world datasets to the San Francisco region, with latitude in [37.5, 37.9] and longitude in [−122.6, −122.2]. The synthetic datasets are generated from Gaussian N (0, 1) and Beta B(2, 5) distributions. Dataset details are shown in Table 2. Detailed descriptions of evaluation metrics, baselines, and parameter settings are provided in Appendix A.2.
Protecting K-Nearest Neighbor Queries from Location Inference Attacks
15
Table 3: Performance comparison of different defense mechanisms in the 10-NN task. Recall and Ratio measure query utility, where higher values indicate better query performance. Acc and Dist characterize the attack performance of ZO-LIA, where lower Acc and higher Dist indicate stronger defense effectiveness. Dataset
Metric
ϵ = 0.5
ϵ=1
ϵ=3
ϵ=5
DPRS SRR Square Laplace DPRS SRR Square Laplace DPRS SRR Square Laplace DPRS SRR Square Laplace Brightkite
Gowalla
Gaussian
Beta
7.2
Recall(↑) 0.434 0.382 Ratio (↑) 0.852 0.814
0.389 0.811
0.353 0.745
0.464 0.423 0.881 0.832
0.414 0.823
0.398 0.766
0.472 0.436 0.885 0.851
0.440 0.844
0.416 0.699
0.489 0.447 0.889 0.861
0.448 0.856
0.423 0.782
Acc (↓) Dist (↑)
0.012 0.016 0.591 0.573
0.018 0.565
0.012 0.594
0.014 0.020 0.583 0.562
0.018 0.553
0.016 0.553
0.020 0.024 0.018 0.525 0.516 0.533
0.022 0.519
0.022 0.028 0.524 0.473
0.024 0.511
0.026 0.515
Recall(↑) 0.443 0.357 Ratio (↑) 0.827 0.773
0.382 0.779
0.331 0.705
0.461 0.430 0.872 0.830
0.418 0.815
0.393 0.737
0.471 0.453 0.879 0.844
0.442 0.840
0.417 0.749
0.482 0.459 0.886 0.853
0.454 0.848
0.446 0.797
Acc (↓) Dist (↑)
0.022 0.012 0.553 0.587
0.024 0.544
0.018 0.572
0.016 0.022 0.530 0.481
0.022 0.499
0.018 0.517
0.020 0.022 0.517 0.486
0.022 0.476
0.020 0.497
0.020 0.024 0.016 0.412 0.409 0.476
0.018 0.446
Recall(↑) 0.644 0.612 Ratio (↑) 0.902 0.864
0.587 0.848
0.541 0.792
0.655 0.637 0.927 0.886
0.624 0.874
0.607 0.837
0.664 0.643 0.929 0.888
0.630 0.879
0.611 0.851
0.672 0.649 0.933 0.900
0.645 0.897
0.629 0.863
Acc (↓) Dist (↑)
0.008 0.014 0.605 0.587
0.018 0.579
0.012 0.591
0.020 0.016 0.547 0.566
0.022 0.527
0.020 0.533
0.014 0.016 0.543 0.512
0.018 0.504
0.018 0.499
0.018 0.022 0.459 0.423
0.020 0.441
0.016 0.494
Recall(↑) 0.563 0.531 Ratio (↑) 0.827 0.751
0.524 0.734
0.482 0.678
0.593 0.567 0.861 0.782
0.553 0.768
0.523 0.714
0.601 0.582 0.873 0.807
0.576 0.796
0.545 0.749
0.623 0.602 0.886 0.822
0.592 0.815
0.594 0.782
Acc (↓) Dist (↑)
0.014 0.608
0.018 0.597
0.020 0.564
0.022 0.576
0.014 0.599
0.022 0.024 0.020 0.512 0.494 0.529
0.024 0.481
0.016 0.020 0.574 0.517
0.024 0.483
0.016 0.564
0.012 0.022 0.616 0.586
0.020 0.553
Tradeoff between Query Utility and Defense Effect
Query utility. As shown in Table 3, DPRS consistently achieves the best query utility across all datasets and privacy budgets. It ranks first in both Recall and Ratio in all 16 settings. Averaged over all settings, DPRS attains a Recall of 0.546 and a Ratio of 0.882, outperforming SRR (0.513/0.835), Square (0.507/0.827), and Laplace (0.482/0.765). Compared with the strongest baseline in each setting, DPRS improves Recall and Ratio by 6.04% and 5.33% on average, respectively. For example, on Brightkite with ϵ = 1, DPRS improves Recall from 0.423 to 0.464 and Ratio from 0.832 to 0.881. On Beta with ϵ = 1, DPRS achieves a Ratio of 0.861, exceeding the best baseline by 0.08. Defense effect. DPRS also provides strong defense effectiveness against ZOLIA 1 . Averaged over all settings, it achieves the lowest attack success rate (Acc = 0.017) and the largest distance error (Dist = 0.541), compared with 0.020/0.520 for SRR, 0.020/0.525 for Square, and 0.018/0.536 for Laplace. In several cases, DPRS improves both utility and defense simultaneously. For instance, on Brightkite with ϵ = 1, DPRS reduces Acc from 0.02 to 0.014 and increases Dist from 0.562 to 0.583 compared with SRR. On Gaussian with ϵ = 3, DPRS achieves both the lowest Acc (0.014) and the highest Dist (0.543). Although DPRS is not always the best on every single attack metric, it remains highly competitive while preserving substantially better query utility. Summary. Overall, DPRS achieves the best trade-off between query utility and defense effect. It consistently dominates all baselines in Recall and Ratio, while also achieving the best average defense performance. These results verify that DPRS can effectively protect against location inference attacks without sacrificing kNNQ utility. 1
As shown in Section 4.3, ZO-LIA achieves the strongest attack performance and is therefore used as the attack baseline.
16
Zhiyu Sun, Jie Fu, Xinpeng Ling, Huifa Li, and Zhili Chen (