betaFeedback

WorksComputer Science

Preventing Model Extraction in Contextual Linear Optimization

Abstract

Consider a contextual linear optimization problem, where a predict-then-optimize (PTO) system returns optimal decisions without revealing the cost vectors used in its downstream linear program. Our focus is on how to prevent attackers, who can submit context queries, from extracting the underlying prediction model. Although the cost-to-decision map is many-to-one, observations across contexts can reveal the underlying prediction model. For linear models, we provide sufficient conditions where the attacker can learn the model up to positive scaling by only observing the decision. These conditions motivate an adaptive attack that alternates inverse optimization with boundary sampling, i.e., using context queries leading to decision boundaries of the current attacker model. To prevent extraction, we propose a mechanism that perturbs decisions only when the predicted cost vector is near a decision boundary. We establish a regret bound in terms of the perturbation radius. For the attackers that fit the defended responses as optimal decisions under the evaluation distribution, we also prove a lower bound on expected extraction error. Experiments on synthetic instances and real data quantify the security-performance trade-off of the defense mechanism and illustrate that our defense can increase the extraction error.

Introduction

Many decision-making problems can be formulated as optimization problems whose parameters are unknown and must be inferred from contexts. For example, a recommendation system uses user features to predict click probabilities before optimizing which items to display. In portfolio optimization, asset returns must be estimated before making allocation decisions. This class of problems is referred to as contextual optimization [28]. A widely adopted approach to contextual optimization is the predict-then-optimize (PTO) framework [10]. In the linear optimization setting studied here, PTO proceeds in two stages: (i) a machine learning (ML) model predicts the unknown objective cost vector from a given context and (ii) the predicted cost vector is used to solve the downstream linear optimization problem and produce a decision. Due to its modularity and empirical effectiveness, PTO has been successfully applied across a broad range of application domains, including recommendation systems, e-commerce, logistics, and resource allocation.

This setting raises a model-security question: can an attacker recover the hidden prediction model by interacting only with the optimization system’s decision outputs? Such a threat is known as a model extraction attack: the attacker repeatedly queries the deployed system with contexts (perhaps through an API) and uses the returned decisions to build a substitute prediction model. Successful extraction can allow the attacker to replicate the service while bypassing access costs or usage restrictions, and moreover, can provide a stepping stone for user privacy or inference attacks [21, 24, 31, 29, 16] and information leakage [34, 39]. At first glance, the optimization layer appears to make extraction difficult. The attacker does not observe predicted costs directly, and the map from costs to optimal decisions is many-to-one in linear optimization. This intuition is incomplete: the same polyhedral geometry that hides costs in the interior of normal cones creates boundary contexts where small changes in predicted costs change the returned decision. This leads to two central questions: (i) when do decision-level observations identify the underlying prediction model, and (ii) how can we mitigate extraction while preserving decision quality?

Existing approaches do not answer these questions directly. Prior work on privacy in contextual decision-making has studied differential privacy (DP) [18], which protects training data but does not directly defend the deployed predictive model against extraction. A second related line is inverse optimization [5], which infers unknown parameters of an optimization problem from observed optimal decisions. While inverse optimization includes both fixed-parameter and contextual formulations, our focus is on whether decision-level observations identify the deployed predictor. More importantly, because the decision map is many-to-one, decision consistency does not in general imply prediction recovery.

In this paper, we focus on model extraction in contextual linear optimization. First, we study vulnerability through a loss calibration condition that links global inverse feasibility consistency to prediction recovery. Motivated by this condition, we then develop an adaptive attack that combines inverse optimization with boundary sampling to reconstruct the hidden predictor using only decision-level observations. This insight motivates a defense that perturbs the returned decision only when the deployed predictor’s cost vector is near a decision boundary. Our theory establishes a regret bound for linear predictors and a lower bound on expected prediction error under a response-matching condition. Our experiments on synthetic instances and real data examine the security-performance trade-off.

Contributions. We formalize model extraction in contextual linear optimization under the predict-then-optimize paradigm and study when the decision-level observations identify the predictor and how to mitigate extraction while limiting the loss in decision quality. Our contributions are summarized as follows:

  • We identify loss calibration as a vulnerability criterion: if it holds, global inverse feasibility consistency is sufficient for prediction recovery up to positive scaling. For linear predictors and unrestricted contextual queries, we use boundary contexts to establish this identification result under sufficient geometric and regularity conditions. This motivates an adaptive attack that alternates inverse optimization with boundary sampling, which targets contexts near decision boundaries of the current attacker model.

  • We propose a decision perturbation defense that randomizes only near decision boundaries and prove a regret upper bound that is linear in the boundary radius. For attackers that fit the defended responses as optimal decisions under the evaluation distribution, we also prove a lower bound on expected prediction error. This lower bound is nondecreasing in the boundary radius.

  • We evaluate the attack and defense on synthetic instances and a short video recommendation task.

In the tested settings, boundary sampling achieves lower prediction error than the non-adaptive inverse-optimization baseline, while the proposed defense can increase the prediction error of the evaluated attacks at modest regret.

Related work. Privacy in contextual optimization has been studied through differential privacy, including personalized pricing and revenue management [7, 8, 18, 20, 33, 9, 30] (Fu et al. 2026). These works are complementary to ours: DP protects data privacy, whereas we study model extraction attacks that target the deployed predictor itself. In model extraction attacks, the goal is to recover a substitute model via query access to a target system [38, 26, 22, 19, 6, 23, 37, 15, 11, 17, 14]. Our work is also related to adaptive query attacks [36, 40]. In our setting, the attacker observes downstream decisions but not predicted cost vectors. Since the prediction-to-decision map is generally many-to-one, we examine how the geometry of the downstream feasible set affects predictor recovery.

Another related line concerns inverse optimization, which infers unknown problem parameters from observed decisions [4, 1, 2, 32, 3, 5, 25]. We use inverse optimization to study when decision consistency identifies the underlying predictor.

Notation. We write x⊥yx \perp y for parallel vectors and ∠(x,y)\angle(x,y) for the angle between two nonzero vectors. The polyhedral cone generated by a1,…,aka_1,\ldots,a_k is denoted by polycone⁡{a1,…,ak}\operatorname{polycone}\{a_1,\ldots,a_k\}. For a polytope S⊆RnS \subseteq\mathbb{R}^n, we let VV denote its vertex set. For a vertex w∈Vw \in V, we denote cone⁡(w)\operatorname{cone}(w) as its normal cone: the set of cost vectors c∈Rnc \in\mathbb{R}^n satisfying cT(u−w)≥0c^\mathsf{T}(u-w) \ge0 for all u∈Su \in S. We also denote by NV(w)={v∈V:dim⁡(cone⁡(v)∩cone⁡(w))=n−1}N_V(w) = \{v \in V : \dim(\operatorname{cone}(v) \cap\operatorname{cone}(w)) = n - 1\} the set of vertices whose normal cones share a facet with cone⁡(w)\operatorname{cone}(w). For c≠0c \ne0, its angular distance to cone⁡(w)\operatorname{cone}(w) is ∠(c,cone⁡(w))=inf⁡u∈cone⁡(w)∖{0}∠(c,u)\angle(c,\operatorname{cone}(w)) = \inf_{u \in\operatorname{cone}(w)\setminus\{0\}} \angle(c,u).

Model Formulation

We study model extraction in contextual linear optimization. This setting involves three roles: a decision-maker, an attacker, and some users. For each user, the decision-maker maps contexts to an action through a predict-then-optimize (PTO) pipeline. Given a cost vector c∈Rnc \in\mathbb{R}^n, the downstream decision is obtained by solving a linear program in the form of

z⋆(c)=min⁡w∈Sc⊤w,(1)z^\star(c) = \min_{w \in S} c^\top w, \tag*{(1)}

where S={w∈Rn:Aw≤b}S = \{w \in\mathbb{R}^n : Aw \le b\} is a compact, full-dimensional polytope. We assume that each inequality in Aw≤bAw \le b defines a distinct facet of SS, and denote the nonzero rows of AA by a1⊤,…,am⊤a_1^\top,\ldots,a_m^\top. We denote the optimal solution set by W⋆(c)=argmin⁡w∈Sc⊤wW^\star(c) = \operatorname*{argmin}_{w \in S} c^\top w and let w⋆(c)∈W⋆(c)∩Vw^\star(c) \in W^\star(c) \cap V be an optimal vertex selected by a fixed tie-breaking rule. Compactness ensures existence of an optimizer, while full dimensionality allows us to study cost directions in the ambient space.1

In the PTO pipeline, the user’s true cost vector is not observed. The decision-maker instead learns a prediction model c^=p(x)\hat{c} = p(x) from contexts x∈Rdx \in\mathbb{R}^d and exposes the induced decision rule w~(x)=w⋆(p(x))∈W⋆(p(x))\widetilde{w}(x) = w^\star(p(x)) \in W^\star(p(x)) (perhaps through an API).2 A user submits a context xx and receives the decision w~(x)\widetilde{w}(x). We focus on the linear prediction model3 in the form of p(x)=PDMxp(x) = P^{DM}x, where PDM∈Rn×dP^{DM} \in\mathbb{R}^{n \times d} is the decision-maker’s prediction matrix. The attacker knows the linear structure but not PDMP^{DM} and learns a model pa(x)=Paxp^a(x) = P^a x with Pa∈Rn×dP^a \in\mathbb{R}^{n \times d}. We consider d>n≥2d > n \ge2, assume rank⁡(PDM)=n\operatorname{rank}(P^{DM}) = n, and exclude the zero attacker matrix Pa=0P^a = 0.

Attackers. A key step is to define the attacker’s prediction loss. Since positive scaling of the cost vector does not change the optimal solution set of a linear program, the attacker succeeds whenever it recovers a prediction model Pa=γPDMP^a = \gamma P^{DM} for some γ>0\gamma> 0. We then measure prediction error by angular distance. Since d>nd > n, prediction matrices have nontrivial kernels. We extend the angular loss by setting ∠(0,0)=0\angle(0,0) = 0 and ∠(u,v)=π2\angle(u,v) = \frac{\pi}{2} when exactly one of uu and vv is zero.

Definition 2.1 (Prediction Loss). Given a context xx and prediction matrices PaP^a and PDMP^{DM}, the prediction loss is Lpred(Pa,PDM,x)=∠(Pax,PDMx)L_{\mathrm{pred}}(P^a,P^{DM},x) = \angle(P^a x,P^{DM}x). For D={(xi,wi)}i=1ND = \{(x_i,w_i)\}_{i=1}^N, the empirical prediction loss is Lpred(Pa,PDM;D)=1N∑i=1N∠(Paxi,PDMxi)L_{\mathrm{pred}}(P^a,P^{DM};D) = \frac{1}{N}\sum_{i=1}^N \angle(P^a x_i,P^{DM}x_i).

We assume that the attacker can make NN queries xi∈Rdx_i \in\mathbb{R}^d, each chosen using the preceding query-response pairs. Without defense, query xix_i returns wi=w⋆(p(xi))w_i = w^\star(p(x_i)). After observing Da={(xi,wi)}i=1ND^a = \{(x_i,w_i)\}_{i=1}^N, the attacker returns a prediction matrix Pa=A(Da)P^a = \mathcal{A}(D^a), where A\mathcal{A} is his algorithm. Fixing a test distribution QQ, we evaluate E[Lpred(Pa,PDM,x)]\mathbb{E}[L_{\mathrm{pred}}(P^a,P^{DM},x)], where the expectation is taken over an independent evaluation context x∼Qx \sim Q and any attack or defense randomness. The attacker aims to reduce this prediction loss using only information available through the query interface. The following proposition shows that traditional model extraction on classification model fits into the predict-then-optimize model.

Proposition 2.2. For the simplex S={w∈Rn:∑j=1nwj=1}S = \{w \in\mathbb{R}^n : \sum_{j=1}^n w_j = 1\}, we define p(x)p(x) as the negative class utility vector of an nn-class classifier. With matched tie-breaking rules, returning the optimal vertex w⋆(p(x))=eiw^\star(p(x)) = e_i is equivalent to returning label ii for a nn-classification problem with prediction model p(x)p(x).

Defense. To defend against extraction, the decision-maker may strategically modify the query interface to restrict the information revealed to adversarial users. Instead of returning the exact optimizer w⋆(p(x))w^\star(p(x)), the decision-maker (API) outputs a perturbed decision w~(x)\widetilde{w}(x), so that an attacker querying xix_i observes wi=w~(xi)w_i = \widetilde{w}(x_i). The decision-maker aims to prevent reconstruction of the prediction model while maintaining near-optimal decision quality.

This interaction admits a Stackelberg interpretation: the decision-maker commits to a response mechanism before the attacker chooses its queries and learning procedure. For a specified attack, the security-performance trade-off is measured by

Security: E[Lpred(Pa,PDM,x)]\mathbb{E}[L_{\mathrm{pred}}(P^a,P^{DM},x)],

Performance: E[p(x)⊤(w~(x)−w⋆(p(x)))]\mathbb{E}[p(x)^\top(\widetilde{w}(x)-w^\star(p(x)))].

The expectations are taken over an independent x∼Qx \sim Q and any attack or defense randomness. The first criterion favors larger attacker prediction error, whereas the second favors smaller regret under the deployed predicted costs. We consider the expected regret when Ex∼Q∥p(x)∥2<+∞\mathbb{E}_{x\sim Q}\lVert p(x)\rVert_2 < +\infty.

Model Extraction

We characterize how decision-level query responses can reveal the underlying prediction model. Throughout this section, we assume that no defensive mechanism is deployed, so the decision-maker returns the true optimal decision w~(x)=w⋆(PDMx)\widetilde{w}(x) = w^\star(P^{DM}x).

Vulnerability identification

The attacker first assesses whether the decision-maker is vulnerable to model extraction, where vulnerability means that the prediction model can be recovered using decision-level queries. Since PDMxP^{DM}x is never observed, the attacker cannot directly evaluate Lpred(⋅,PDM,x)L_{\mathrm{pred}}(\cdot,P^{DM},x). Instead, the attacker optimizes a surrogate loss that depends on PDMP^{DM} only through the observed decision w⋆(PDMx)w^\star(P^{DM}x). A class of surrogate loss functions comes from inverse optimization [5]. Given a query-response dataset D={(xi,wi)}i=1ND=\{(x_i,w_i)\}_{i=1}^N, we define the inverse feasible set as follows:

References

  1. [1]A. Aswani, Z-J. Shen, and A. Siddiq. Inverse optimization with noisy data. Operations Research, 66(3): 870–892, 2018.arxiv.org/abs/1507.03266
  2. [2]A. Babier, T. C. Y. Chan, T. Lee, R. Mahmood, and D. Terekhov. An ensemble learning framework for model fitting and evaluation in inverse linear optimization. INFORMS Journal on Optimization, 3(2): 119–138, 2021.arxiv.org/abs/1804.04576
  3. [3]O. Besbes, Y. Fonseca, and I. Lobel. Contextual inverse optimization: Offline and online learning. Operations Research, 73(1):424–443, 2025.
  4. [4]T. C. Y. Chan, T. Craig, T. Lee, and M. B. Sharpe. Generalized inverse multiobjective optimization with application to cancer therapy. Operations Research, 62(3):680–695, 2014.DOI
  5. [5]T. C. Y. Chan, R. Mahmood, and I. Y. Zhu. Inverse optimization: Theory and applications. Operations Research, 73(2):1046–1074, 2025.
  6. [6]V. Chandrasekaran, K. Chaudhuri, I. Giacomelli, S. Jha, and S. Yan. Exploring connections between active learning and model extraction. In USENIX Security Symposium, pages 1309–1326, 2020.
  7. [7]X. Chen, D. Simchi-Levi, and Y. Wang. Privacy-preserving dynamic personalized pricing with demand learning. Management Science, 68(7):4878–4898, 2022.
  8. [8]X. Chen, S. Miao, and Y. Wang. Differential privacy in personalized pricing with nonparametric demand models. Operations Research, 71(2):581–602, 2023.arxiv.org/abs/2109.04615
  9. [9]S. R. Chowdhury and X. Zhou. Differentially private reward estimation from preference based feedback. In ICML Workshop on The Many Facets of Preference-Based Learning, 2023.arxiv.org/abs/2310.19733
  10. [10]A. N. Elmachtoub and P. Grigas. Smart “predict, then optimize”. Management Science, 68(1):9–26, 2022.arxiv.org/abs/1710.08005
  11. [11]J. Ferry, R. Fukasawa, T. Pascal, and T. Vidal. Trained random forests completely reveal your dataset. In ICML, pages 13545–13569. PMLR, 2024.arxiv.org/abs/2402.19232
  12. [13]C. Gao, S. Li, Y. Zhang, J. Chen, B. Li, W. Lei, P. Jiang, and X. He. KuaiRand: An unbiased sequential recommendation dataset with randomly exposed videos. In CIKM, pages 3953–3957, 2022.DOI
  13. [14]A. Gorgé, J. Ferry, S. Gambs, and T. Vidal. Training set reconstruction from differentially private forests: How effective is DP? In SaTML, pages 1136–1171. IEEE, 2026.arxiv.org/abs/2502.05307
  14. [15]H. Huang, Y. Li, B. Jiang, B. Jiang, L. Liu, Z. Liu, R. Sun, and S. Liang. Enhancing the resilience of LLMs against grey-box extractions. In ICML Workshop on Next Generation of AI Safety, 2024.
  15. [16]M. Juuti, S. Szyller, S. Marchal, and N. Asokan. PRADA: Protecting against DNN model stealing attacks. In IEEE European Symposium on Security and Privacy, pages 512–527. IEEE, 2019.arxiv.org/abs/1805.02628
  16. [17]A. Khouna, J. Ferry, and T. Vidal. From counterfactuals to trees: Competitive analysis of model extraction attacks. In NeurIPS, pages 2721–2756, 2025.arxiv.org/abs/2502.05325
  17. [18]Y. Lei, S. Miao, and R. Momot. Privacy-preserving personalized revenue management. Management Science, 70(7):4875–4892, 2024.
  18. [19]S. Milli, L. Schmidt, A. D. Dragan, and M. Hardt. Model reconstruction from model explanations. In FAccT, pages 1–9. ACM, 2019.arxiv.org/abs/1807.05185
  19. [20]R. Mochaourab, S. Sinha, S. Greenstein, and P. Papetrou. Robust counterfactual explanations for privacy-preserving SVM. In ICML Workshop on Socially Responsible Machine Learning, 2021.
  20. [21]A. Narayanan and V. Shmatikov. Robust de-anonymization of large sparse datasets. In IEEE Symposium on Security and Privacy, pages 111–125. IEEE, 2008.DOI
  21. [22]T. Orekondy, B. Schiele, and M. Fritz. Knockoff nets: Stealing functionality of black-box models. In CVPR, pages 4954–4963, 2019.arxiv.org/abs/1812.02766
  22. [23]S. Pal, Y. Gupta, A. Shukla, A. Kanade, S. Shevade, and V. Ganapathy. Activethief: Model extraction using active learning and unannotated public data. In AAAI, pages 865–872, 2020.DOI
  23. [24]N. Papernot, P. McDaniel, I. Goodfellow, S. Jha, Z. B. Celik, and A. Swami. Practical black-box attacks against machine learning. In Asia Conference on Computer and Communications Security, pages 506–519. ACM, 2017.arxiv.org/abs/1602.02697
  24. [25]S. Patel and S. Vempala. Tight bounds for learning polyhedra with a margin. ArXiv Preprint: 2604.14614, 2026.
  25. [26]R. N. Reith, T. Schneider, and O. Tkachenko. Efficiently stealing your machine learning models. In ACM Workshop on Privacy in the Electronic Society, pages 198–210, 2019.DOI
  26. [27]R. T. Rockafellar. Convex Analysis, volume 28. Princeton University Press, 1970.
  27. [28]U. Sadana, A. Chenreddy, E. Delage, A. Forel, E. Frejinger, and T. Vidal. A survey of contextual optimization methods for decision-making under uncertainty. European Journal of Operational Research, 320(2):271–289, 2025.
  28. [29]A. Salem, Y. Zhang, M. Humbert, P. Berrang, M. Fritz, and M. Backes. ML-Leaks: Model and data independent membership inference attacks and defenses on machine learning models. In Network and Distributed System Security Symposium. The Internet Society, 2019.arxiv.org/abs/1806.01246
  29. [30]A. Selvi, H. Liu, and W. Wiesenmann. Differential privacy via distributionally robust optimization. Operations Research, 74(1):356–376, 2026.arxiv.org/abs/2304.12681
  30. [31]R. Shokri, M. Stronati, C. Song, and V. Shmatikov. Membership inference attacks against machine learning models. In IEEE Symposium on Security and Privacy, pages 3–18. IEEE, 2017.arxiv.org/abs/1610.05820
  31. [32]C. Sun, S. Liu, and X. Li. Maximum optimality margin: A unified approach for contextual linear programming and inverse linear programming. In ICML, pages 32886–32912. PMLR, 2023.arxiv.org/abs/2301.11260
  32. [33]L. Sun, K. Cong, J. Q. Chooi, and R. Li. DP-AdamW: Investigating decoupled weight decay and bias correction in private deep learning. In ICML Workshop on Reliable and Responsible Foundation Models, 2025.arxiv.org/abs/2511.07843
  33. [34]K. H. Tan, W. P. Wong, and L. Chung. Information and knowledge leakage in supply chain. Information Systems Frontiers, 18(3):621–638, 2016.DOI
  34. [35]B. Tang and E. B. Khalil. Cave: A cone-aligned approach for fast predict-then-optimize with binary linear programs. In CPAIOR, pages 193–210. Springer, 2024.arxiv.org/abs/2312.07718
  35. [36]F. Tramèr, F. Zhang, A. Juels, M. K. Reiter, and T. Ristenpart. Stealing machine learning models via prediction APIs. In USENIX Security Symposium, pages 601–618, 2016.arxiv.org/abs/1609.02943
  36. [37]J-B. Truong, P. Maini, R. J. Walls, and N. Papernot. Data-free model extraction. In CVPR, pages 4771–4780, 2021.arxiv.org/abs/2011.14779
  37. [38]B. Wang and N. Z. Gong. Stealing hyperparameters in machine learning. In IEEE Symposium on Security and Privacy, pages 36–52. IEEE, 2018.arxiv.org/abs/1802.05351
  38. [39]C. Zhang, B. Liu, G. G. Cai, and T. Huang. When ignorance is bliss: The retailer’s intelligence hazard under information sharing and exchanging. Transportation Research Part E: Logistics and Transportation Review, 180:103356, 2023.DOI
  39. [40]K. Zhao, L. Li, K. Ding, N. Z. Gong, Y. Zhao, and Y. Dong. A systematic survey of model extraction attacks and defenses: State-of-the-art and perspectives. ArXiv Preprint: 2508.15031, 2025.arxiv.org/abs/2508.15031

Paper details

vlnc:W_nb23g5na
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents