From Counterfactuals to Trees: Competitive Analysis of Model Extraction Attacks

Awa Khouna, Julien Ferry, Thibaut Vidal · DOI

Abstract

As Machine Learning as a Service (MLaaS) platforms increasingly adopt explainability features to comply with transparency regulations, they inadvertently open new vectors for model extraction. This paper introduces the Tree Reconstruction Attack (TRA), a novel algorithm that achieves perfect functional equivalence in cloning tree-based models by exploiting counterfactual explanations. By framing model extraction as an "online discovery" problem, we provide the first rigorous theoretical bounds on query efficiency, demonstrating that explainable AI APIs can be exploited to steal proprietary models with significantly fewer queries than previously thought possible.

Introduction

Machine Learning as a Service (MLaaS) platforms allow users to query sophisticated models via APIs, protecting proprietary logic and training data. However, the push for transparency—driven by regulations like the EU AI Act—has led to the integration of explainability features. Among the most popular are "counterfactual explanations," which provide users with the minimal change required to an input to alter a model's prediction (e.g., "If your income were $5,000 higher, your loan would be approved").

While intended to build trust, these explanations leak critical information about the model's decision boundaries. Previous research has explored using this data to train "surrogate" models, but these attempts often lack mathematical guarantees or require unrealistic API access (such as internal leaf node IDs). This paper addresses these gaps by introducing the Tree Reconstruction Attack (TRA), a mathematically rigorous framework for the perfect extraction of tree-based models.

The Tree Reconstruction Attack (TRA)

The TRA is specifically designed to extract models with axis-parallel decision boundaries, such as Decision Trees and Random Forests. The attack treats the model's decision space as an unknown environment, similar to a robot mapping a room.

Divide-and-Conquer Extraction

TRA operates through a recursive divide-and-conquer strategy:

  1. Initial Query: The algorithm queries the center of a defined input region to obtain a prediction and a locally optimal counterfactual.
  2. Boundary Identification: Because tree models split data along strict feature axes (e.g., Age > 30), a locally optimal counterfactual reveals the exact coordinate of a decision boundary.
  3. Recursive Splitting: TRA splits the current region along this identified boundary and recursively repeats the process for the resulting sub-regions.
  4. Termination: The process continues until no further counterfactuals can be found, ensuring the entire functional space has been mapped.

Competitive Analysis

To evaluate the efficiency of TRA, the authors utilize "competitive analysis" from theoretical computer science. By comparing TRA’s query count against an omniscient "offline" algorithm that already knows the tree's structure, the authors establish strict worst-case bounds. This framework proves that TRA is not just a heuristic, but a theoretically grounded method for model theft.

Experimental Evaluation

The authors evaluated TRA on five standard tabular datasets: Adult Income, COMPAS (recidivism), Default of Credit Card Clients, German Credit, and Student Performance. The attack was tested against both individual decision trees and large random forest ensembles.

Key Findings

  • 100% Fidelity: TRA consistently achieves perfect functional equivalence, meaning the extracted clone behaves identically to the target model across the entire input space.
  • Superior Query Efficiency: TRA requires orders of magnitude fewer queries than existing functionally equivalent baselines like PathFinding. For instance, on the COMPAS dataset, a depth-9 tree was extracted in an average of 153 queries, far below the theoretical worst-case bound of 1,070.
  • Sub-linear Scaling for Forests: One of the most striking results is TRA's performance against Random Forests. Despite the structural complexity of ensembles, TRA maps the functional decision space. The number of queries scales sub-linearly with the total number of nodes in the forest (approximately $\Theta(\text{Nodes}^{0.38})$), allowing compact trees to represent the behavior of massive ensembles.
  • Anytime Performance: Even when restricted by a query budget, TRA provides highly accurate partial models that outperform traditional surrogate-training methods at every stage of the attack.

Discussion and Security Implications

The success of TRA highlights a fundamental tension between model transparency and security. Counterfactuals act as blueprints for the model's internal logic; a simple, lightweight heuristic that finds locally optimal counterfactuals is sufficient for a perfect reconstruction. This suggests that current MLaaS transparency features may be incompatible with the protection of proprietary model structures unless new defensive measures are implemented.

Limitations and Future Work

Currently, TRA is optimized for axis-parallel decision boundaries and does not directly apply to the non-linear boundaries found in deep neural networks. Furthermore, the attack assumes the API returns valid, locally optimal counterfactuals.

Future research directions include:

  1. Developing dynamic exploration strategies to avoid adversarial tree structures designed to maximize query counts.
  2. Investigating the impact of privacy-preserving counterfactual mechanisms, such as those that add noise or limit explanation precision, on the success of extraction attacks.
  3. Expanding the competitive analysis framework to non-axis-parallel models.

Summary updated

BibTeX
@inproceedings{khouna2025from,
  author = {Awa Khouna and Julien Ferry and Thibaut Vidal},
  title = {{From Counterfactuals to Trees: Competitive Analysis of Model Extraction Attacks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=6vcgsrK6pN},
}
Figure