Recourse From a Fixed Codebook: Capping What Counterfactual Explanations Leak

A counterfactual explanation tells a person what minimal change would flip a model's decision, for example "raise your income by $7,500 and the loan is approved." Regulators and users want these explanations. They are also a way to steal the model. The point returned sits almost exactly on the decision boundary, and prior work shows it is practically the same object as an adversarial example. Attackers who collect a few hundred such points can rebuild a lender's classifier. Defenses that add noise break the recourse, and they fall to attackers who average repeated queries. Defenses that trust one central server or auditor to police access create a single party whose compromise, or whose own dishonesty, voids every guarantee.

We propose to change what a counterfactual is allowed to be. The public recourse service does not return the minimal boundary-hugging change. It returns the nearest point from a small, fixed, publicly specified codebook of K candidate profiles that the committed model actually approves. The answer is deterministic and depends only on which codebook points the model approves. So everything the counterfactual channel can ever reveal is K bits, regardless of how many queries or fake accounts the attacker uses. Every recourse remains valid: acting on it provably flips the decision. Exact, boundary-level explanations are still needed for fairness audits. We keep those in a separate channel that opens only when a threshold of independent auditors jointly authorize a query, with every query posted to a public append-only log under a global budget. No single auditor, and not the model owner, can spend that leakage silently.

Core Claim

The leakage that makes counterfactual APIs dangerous comes from their minimality, not from counterfactuals as such. Exploring Counterfactual Explanations Through the Lens of Adversarial Examples shows that minimal counterfactual search coincides with boundary-finding adversarial attacks. Their rankings of which features to change correlate above 0.90, and the returned points fall within 0.02 of each other. The two strongest extraction attacks exploit exactly this boundary contact. The Tree Reconstruction Attack of From Counterfactuals to Trees reads split thresholds directly off counterfactual coordinates and recovers a depth-9 COMPAS tree in about 153 queries with perfect fidelity. Model extraction from counterfactual explanations reaches 90% fidelity on Adult Income with 250 queries, where a traditional attack needs over 8,000 queries to reach about 81%.

If the answer is instead a deterministic function of the query and of the model's labels on a public codebook $C=\{c_1,\dots,c_K\}$, a simple bound follows. Let $\theta$ be the model parameters, $T_{\text{CF}}$ the full transcript of counterfactual answers over any number of queries and accounts, and $T_{\text{label}}$ the transcript of plain decisions. Then

$$ I(\theta;\, T_{\text{label}}, T_{\text{CF}}) \;\le\; I(\theta;\, T_{\text{label}}) + K \text{ bits}. $$

The bound holds because the attacker can recompute every counterfactual answer from the public rule once it knows the K-bit vector of codebook labels $(f_\theta(c_1),\dots,f_\theta(c_K))$. The counterfactual channel is therefore worth at most K extra labeled points to a thief. It is immune to averaging and to Sybil attacks, which use many fake accounts. It also requires no randomness, so it is compatible with deterministic cryptographic verification. That last property is the point where noise-based defenses such as XRand break down.

The price is recourse cost: the suggested change is sufficient but not minimal. The central empirical question is whether some K makes that price small while leaving extraction near label-only difficulty.

Research Program

Public recourse tier. The first component is the codebook recourse service itself. The codebook is built from public or synthetic data, never from training records, so that it does not itself reveal who was in the training set. Candidates are selected by clustering and stratified by immutable attributes, so a returned profile never asks someone to change their age or race. The answer rule is published. For a query $x$ with immutable stratum $s$, return the approved codebook point in stratum $s$ that is closest under the actionability-weighted distance, with fixed tie-breaking. We will study how recourse cost scales with K and with codebook placement. We will also test whether a learned placement, optimized only on public data, can cut cost relative to clustering without breaking the rule's publicity.

Adaptive attacks on the public tier. The second component is an adaptive attack suite that knows everything about the defense. The attacker has the codebook, the rule, and unlimited accounts. It runs Aïvodji-style and TRA-style extraction on the combined channel. It also runs a codebook-aware attack that first recovers all K codebook labels and then trains a clone on those labels plus its label-only queries. A final strategy chooses label queries actively near the implied Voronoi cells, the regions of input space that map to each codebook point. The bound predicts that the combined attack should do no better than label-only extraction seeded with K labeled points. Testing whether that holds in practice is the main experiment.

Audit tier. The third component addresses the auditor problem that XAudit leaves open. Exact counterfactuals make sensitivity audits extremely cheap: one query for linear models, about 54 versus about 905 random queries on Credit Default, and about 2 queries on a 4,000-node CovType tree. The same authors note that the auditor can then steal the model. Instead of trusting one auditor, exact queries are released only under a t-of-n threshold signature held by independent auditors. Each authorized query and its answer hash are appended to a public bulletin board, modeled on the one used by Audit-or-Cast. A global budget B caps total exact-query spending. The design idea borrowed from multi-authority key issuance (Privacy-Improving Multi-Authority CP-ABE), where no single authority can issue keys out of band, is applied here to explanation access rather than decryption keys.

The research question is empirical, and the file's numbers suggest a gap worth testing. Audits need roughly 1 to 54 exact queries, while extraction attacks need roughly 150 to 1,000 queries for high fidelity. A budget B inside that gap would admit audits and deny theft. We must verify this on the same models, because the reported figures come from different papers and datasets.

Integrity against a dishonest owner. The fourth component addresses the "Volkswagen" failure described in Private, Verifiable, and Auditable AI Systems: the owner serves a fair model to auditors and a different model in production. The owner commits to a model hash and publishes codebook labels. For small models, the owner attaches proofs, built with that paper's ezkl toolkit, that each published label was computed under the committed weights. Because the codebook rule is deterministic, a label proof suffices to verify every public answer. Auditors can check that the nearest-approved rule was followed by recomputing it from the published labels.

South's work proves that a computation happened correctly. It does not limit what the verified output leaks. The codebook supplies that missing limit, and the proofs supply what the codebook alone lacks: evidence that the labels are real.

Baselines

The naive reference point is the unprotected minimal-counterfactual API. It follows the Wachter-style counterfactual (SCFE) and diverse-counterfactual (DiCE) generators used in Model extraction from counterfactual explanations, attacked by that paper's method on MLPs and by TRA from From Counterfactuals to Trees on decision trees and random forests. The reported numbers to reproduce are 90% fidelity at 250 queries on Adult Income, 93–98% fidelity by 1,000 queries across datasets, and 100% fidelity for a depth-9 COMPAS tree at about 153 queries. We re-run both attacks on our own trained models before comparing, so that the models, query budgets, and tuning effort are identical across arms.

The floor we aim to approach is a label-only API, which returns decisions with no explanations. The file reports over 8,000 queries for about 81% fidelity on Adult. We found no reported label-only result on Lacuna at 1,000 queries, so we will measure that curve ourselves.

The strongest existing defense is noise-based sanitization in the spirit of XRand, which reduced explanation-guided backdoor success on EMBER LightGBM from 77.8% to 10.2% at a privacy budget of 1.0. That result is for a different threat, backdoor poisoning, and a different explanation type, SHAP rankings. We adapt it to counterfactuals by perturbing the returned point with calibrated noise at matched privacy levels. The adaptive attacker is allowed to average repeated nearby queries, and we measure recourse validity alongside fidelity.

The ablation that isolates the key ingredient is a deterministic margin counterfactual. It pushes each minimal counterfactual a fixed distance past the boundary, giving recourse cost comparable to the codebook but a continuous, query-specific answer. If the margin baseline matches the codebook's protection, then determinism and non-minimality are doing the work, not the finite codebook. We also sweep K up to the size of the full public pool, and include "nearest approved real example" as the large-K extreme.

We count the proposal as beating the baselines if three conditions hold at 1,000 adaptive queries across Adult, COMPAS, German Credit, and Student Performance. Clone fidelity must fall within 3 points of the label-only curve plus K seeded labels, instead of the 93–98% reached against minimal counterfactuals. Recourse validity must remain 100%, while the noise baseline falls below 100% at matched protection. Median recourse cost must stay within a factor of 1.5 of the minimal counterfactual for some K.

Why not just…?

Why not just rate-limit accounts and flag boundary-probing traffic? Aïvodji et al. themselves argue that low query volumes make their attack look like normal use: 250 queries for 90% fidelity is a plausible customer session. TRA needs only about 153 queries on COMPAS. Per-account limits also fail against many cheap pseudonyms. The codebook bound is global and indifferent to accounts, and we will test it directly: an attacker splitting 10,000 queries across 100 accounts should gain nothing beyond the K codebook labels. Rate limiting stays useful as a complement on the label channel, and we will report its effect there.

Why not just add differential-privacy noise to the counterfactual? Noise has two faults the codebook avoids. First, a noised counterfactual may not flip the decision, which breaks the promise made to the applicant. Second, zero-mean noise shrinks when an adaptive attacker averages many nearby answers, the same kind of aggregation that query-based attacks such as Query-Based Adversarial Prompt Generation exploit when they pool noisy output signals. Noise also sits badly with deterministic proofs of correct execution. Our averaging-attack experiment against the noise baseline will show whether this concern is real at practical privacy levels. If the noise defense holds up against averaging with acceptable validity, the codebook's advantage reduces to verifiability, and we will say so.

Why not just return a counterfactual with a safety margin, or the nearest approved real example? This is the real threat to the proposal, and it is why the margin ablation and the K sweep exist. A deterministic margin defeats naive TRA, but its answers still move continuously with the query. A defense-aware attacker who knows the margin can plausibly subtract it and recover the boundary. Returning the nearest approved training example has two problems: it releases up to one label per training point, and it exposes real training records, which risks revealing who was in the training set. The codebook's claim rests on K being small, fixed, and public. If fidelity against the margin baseline matches the codebook's under the adaptive attack, we will drop the codebook in favor of the simpler method.

Why not just put the model and explainer in a single trusted enclave? For the public tier, the leakage bound needs no decentralization. It holds even under a fully trusted host, and we say so plainly. Decentralization matters only for the exact-explanation channel. There, a single enclave operator or single auditor can spend the extraction budget unobserved, or show auditors a different model from the one in production, which is the scenario South describes. A single enclave cannot give outside parties evidence of which queries were answered. The threshold-plus-public-log design exists to provide that evidence, and its measured costs (signing latency, log size, proof time) will show whether it earns its complexity.

Proposed Experiments

The first decisive check is the extraction curve. On Adult, COMPAS, German Credit, and Student Performance, we train decision trees, random forests, and MLPs. We plot clone fidelity against queries from 50 to 10,000 for five APIs: minimal counterfactual, label-only, noised counterfactual, margin counterfactual, and codebook counterfactual at K from 16 to 4,096. Each API faces the strongest attack we can build against it, including the codebook-aware attack. The theory predicts that codebook curves sit on the label-only curve seeded with K labels. Violating that prediction would mean either an implementation leak or a flaw in the determinism argument.

The second check is the recourse price. For each K, we report validity, median and 90th-percentile actionability-weighted recourse cost relative to the minimal counterfactual, and how often a returned profile is judged implausible under a density model fit on public data.

The third check is the audit–theft gap. On the same models, we run the XAudit counterfactual and decision-tree auditors for gender and sex sensitivity, recording the exact queries they need. At the same budgets B, we run TRA and Aïvodji-style extraction restricted to B exact queries plus unlimited codebook and label queries. A usable gap exists if audits complete at B while clone fidelity stays near the label-only curve.

The fourth check covers integrity and cost. We build ezkl proofs of the codebook labels for MLPs small enough to prove, and time proof generation and verification. The file reports that models up to a 250k-parameter nanoGPT are provable and gives a 20% hardware speedup, but reports no tabular-model proving times on Lacuna. We also measure threshold-signing and bulletin-board overhead per audit query. Finally, we simulate a coalition of $t-1$ colluding auditors and an owner who swaps models after commitment, and confirm that the design blocks the first and detects the second.