NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Hand-Off Substitution: When the Client in Hybrid Encrypted Inference Can Rewrite the Network's Activations

Hybrid private inference systems split a neural network between a server that owns the model and a client that owns the data and the decryption key. The server runs the linear layers on encrypted inputs using homomorphic encryption, a type of encryption that allows additions and multiplications on ciphertexts without decrypting them. It then sends the encrypted intermediate values to the client, which decrypts them, applies the nonlinearity such as ReLU in plaintext, re-encrypts, and sends them back. This hand-off avoids the cost and accuracy loss of evaluating nonlinearities under encryption, and it is the main reason recent systems are fast. Every such system assumes the client applies the nonlinearity honestly. Nothing enforces this. The returned ciphertext is fully malleable: the client can substitute any vector it likes, and the server will feed it into the next layer and send the client that layer's output. A deviating client therefore gets a chosen-input query on each hidden layer separately.

This note proposes measuring how much of the server's model this "hand-off substitution" gives away. It also proposes a cheap defense that limits what the client may do at the hand-off to the one allowed function, coordinate-wise ReLU, in the spirit of targeted malleability. The defense hides "canary" neurons among the real ones. Their plaintext the server knows, so it can compute the correct ReLU output for them in advance. The server then folds any deviation on a canary into the next layer under a secret random matrix, so that tampering turns the client's own observations into noise. The work is built as a modular test harness. Hand-off defenses and client attacks plug in as interchangeable components, so the trade-off between security, accuracy and latency can be compared fairly across systems.

Core Claim

The claim has two parts. First, in current client-aided pipelines, an active client that substitutes hand-off values can recover a functionally equivalent copy of the server's network with a number of queries roughly linear in layer width. Neuron shuffling, the main deployed defense, offers little protection. The reason is simple: permuting the neurons of a hidden layer is a symmetry of the network, so a copy recovered "up to permutation" computes exactly the same function. Second, canary entanglement makes deviation self-defeating at small cost to honest accuracy and latency. It binds the returned ciphertext to the authorized transformation probabilistically, without zero-knowledge proofs.

The second claim is the new mechanism. The first is the motivating measurement, and it is itself absent from the literature. The research file contains no reported result on active-client extraction against any hybrid inference system.

Where This Sits

Four systems in the file use the client hand-off, and all assume a passive client. Privacy-Preserving Gaussian Process Regression - A Modular Approach to the Application of Homomorphic Encryption has the client decrypt encrypted distances, compute the kernel in plaintext and re-encrypt. Its defenses for what the client learns are informal: noise, shuffling and dummy points. THE-X uses the same client round trip for ReLU in a BERT-tiny model. Cheetah accelerates the server-side homomorphic work and offloads nonlinear layers to interactive protocols with semi-honest participants. SAFHIRE adds a secret random permutation of output neurons before the hand-off and proves a differential-privacy guarantee for model weights against naive inversion.

These papers motivate the proposal: they establish the hand-off as the dominant design and leave active deviation unanalyzed. Our dummy-point idea differs from the GP paper's informal suggestion in one essential way. In our design the decoys are wired back into the computation, so tampering is punished rather than merely confused.

Two lines of work constrain the design. The cryptanalyses Analysis of Gong et al.'s CCA2-Secure Homomorphic Encryption, Insecurity of the Public Key Encryption with Filtered Equality Test Proposed by Huang et al and On the CCA (in)security of MTProto show a common pattern. Whenever a component lets an attacker transform a ciphertext and then observe a related decryption, plaintext recovery follows with certainty. These papers frame hand-off substitution as the same failure in a new place: the malleable object is the returned activation, and the "oracle" is the next layer.

An Attack to Break Permutation-Based Private Third-Party Inference Schemes for LLMs inverts permutation-based hiding of hidden states, reaching 100% token decoding on Gemma-2-2B-IT and over 99% on Llama-3.1-8B-Instruct. That attack is passive and targets the client's prompt, not the server's weights. It still warns against expecting permutation alone to hide structure. We reuse its matching ideas, comparing sorted distance statistics across queries, to align neurons across fresh permutations.

Targeted Malleability supplies the target notion: allow only transformations in an authorized family and reject everything else. It enforces this with double encryption and succinct non-interactive arguments (SNARGs, short proofs that a computation was done correctly). Its security is limited to chosen-plaintext and non-adaptive chosen-ciphertext attacks, it relies on non-falsifiable assumptions, and its public keys are large. It was never implemented for ML.

Our canary scheme is deliberately weaker. It gives a probabilistic, game-based guarantee rather than a simulation proof, and it does not claim adaptive chosen-ciphertext security. Its payoff is that it costs a few extra ciphertext slots and one extra matrix product per layer.

The Mechanism

Take a hidden layer whose pre-activation vector $s$ the server sends to the client, already scaled and permuted. The scaling is safe because ReLU satisfies $\mathrm{ReLU}(a x) = a\,\mathrm{ReLU}(x)$ for $a > 0$, so the server can undo it after the client applies ReLU. Before encrypting, the server inserts $m$ canary coordinates with values $c$. These values are drawn to match the empirical distribution of real pre-activations. The server encrypts them under the client's public key, so it knows their plaintext.

The client returns a vector $\tilde h$. Let $\tilde h_C$ denote its canary entries, and let $\tilde h_{\bar C}$ denote its real entries after the server unscales and unpermutes them. The server forms the next pre-activation homomorphically as

$$u = W \tilde h_{\bar C} + b + R\,(\tilde h_C - \mathrm{ReLU}(c)),$$

where $W$ and $b$ are the layer's weights and bias and $R$ is a fresh secret random matrix with large entries. For an honest client the last term is zero. A client that alters any canary sees $u$ swamped by an unknown random vector.

A probing client must alter some coordinates. It cannot tell which ones are canaries, because the canaries are distributionally matched and a fresh permutation is drawn per query. So each altered coordinate trips a canary with probability about $m/(n+m)$, where $n$ is the number of real neurons. A probe that alters $k$ coordinates survives with probability about $(n/(n+m))^k$. That figure is the hypergeometric "no canary hit" probability, approximated for $k \ll n$.

Under exact integer encryption schemes such as BFV or BGV, an honest client produces an exactly zero penalty term. Under approximate schemes such as CKKS, encryption noise gets multiplied by $R$. The scale of $R$ therefore trades off honest accuracy against detection strength, and we measure this trade-off directly rather than assume it away.

Research Program

The work has three components.

The first is a modular harness in the style of DeepDIVA and the uniform estimator interface of the Universal Causal Evaluation Engine. It defines three abstract components. A hand-off defense transforms pre-activations before sending them and checks or combines the returned values. A client policy maps decrypted values to returned values; an honest policy simply applies ReLU. An extraction routine turns a transcript of queries into a surrogate model. Seeds, data splits and the encryption backend are fixed by the harness, so the defense is the only variable that changes between runs. DeepDIVA reports that GPU nondeterminism can break exact replication, so all reported attack numbers will come from repeated seeds with confidence intervals.

The second component is the attack suite against current defenses: plain hand-off, SAFHIRE-style per-query shuffling, and shuffling plus its weight-noise mechanism. The suite runs layer-by-layer linear probing, alignment of neurons across fresh permutations using sorted-statistic matching adapted from the permutation-inversion attack, and stitching of the recovered layers into a surrogate.

The third component is canary entanglement, together with adaptive attacks written specifically against it. One adaptive attack tries to spot canaries by their statistics. Another alters only a handful of coordinates per query and keeps the probes that survive. A third tries to detect when a response has been corrupted and discard it. The security statement is a game in which the client wins if its surrogate matches the server's model above a set agreement threshold within $Q$ queries. We report the winning probability against the strongest adaptive attacker we can build. This is an empirical bound, not a reduction, and the note says so.

Baselines

The naive reference point is the undefended hand-off as in THE-X and the GP pipeline. It establishes how cheaply an active client extracts the model when nothing stops it, and it sets the cost floor of zero overhead. Every defense is run on the same trained model, the same test inputs and the same query budget.

The strongest existing defense is SAFHIRE's randomized neuron shuffling with its differential-privacy weight protection SAFHIRE. It is the only deployed hand-off defense in the file aimed at model privacy, and it is the incumbent our claim must displace. Its reported utility and cost are accuracy within 2.1% of ORION on CIFAR-10 and 13.65 seconds end-to-end latency for one ResNet-20 inference on an A100 GPU. For extraction resistance under an active client, no reported result was found on Lacuna for SAFHIRE. We will run it with its published permutation-per-query behavior on the same ResNet-20 and CIFAR-10 setup, under the same network bandwidth (1.25 MB/s, as in SAFHIRE's latency evaluation).

Canary entanglement beats SAFHIRE if two things hold together. First, it holds surrogate agreement near what an attacker gets from black-box input-output queries alone. Second, its honest accuracy loss and latency overhead stay within a few percent of SAFHIRE's own figures. Black-box agreement is the unavoidable leakage of any inference service, so it is the right target.

Two ablations isolate the key ingredient. The first, canaries without entanglement, sets $R=0$. The canaries then act as SAFHIRE-style dummy points that are never checked, which tells us whether wiring them back into the computation is what matters. The second, entanglement without per-query re-permutation, tests whether canary positions leak across queries. A proof-based reference implements the targeted-malleability idea directly, with the client proving each ReLU was computed correctly. We estimate its cost but do not optimize it, as a ceiling on what cryptographic enforcement costs.

Why not just…?

Why not just wrap the hand-off in authenticated encryption such as AES-GCM or Encrypt-then-MAC? Authenticated encryption proves who sent a message and that it was not altered in transit. That is exactly the fix On the CCA (in)security of MTProto recommends for transit tampering. Here, though, the attacker is the legitimate key holder producing a fresh message, so a MAC under its own key authenticates the forgery. Authenticated encryption also forbids the homomorphic layers the server must run, which is the conflict Targeted Malleability was written to address. This alternative does not address the threat.

Why not just shuffle and add noise, as SAFHIRE does? This is the serious competitor. Our argument that it is weak is structural: a layer recovered up to a neuron permutation is functionally exact. If our alignment attack fails against fresh per-query permutations combined with SAFHIRE's noise, SAFHIRE may already suffice, and canaries would add only marginal value. The head-to-head attack experiment decides this. We will report a negative result plainly if shuffling holds.

Why not just rate-limit queries or rely on black-box extraction being the only leak? Rate limits cap total information but not its kind. A hand-off probe yields one hidden layer's linear map directly, while black-box queries yield only final outputs. We measure surrogate agreement as a function of query count for both channels. If hand-off extraction needs about as many queries as black-box extraction, rate-limiting is enough, and the threat is less severe than claimed.

Why not just run everything under encryption on the server and remove the hand-off? That removes the attack, but the file's evidence shows it is costly. In the GP setting, the non-modular Taylor-approximation baseline had errors exceeding 500,000%, against 0.00004% to 1.75% for the modular pipeline Privacy-Preserving Gaussian Process Regression. SAFHIRE reports 1.5× to 10.5× lower latency than the bootstrapped approach. We include a fully encrypted run only as an accuracy and latency reference.

Proposed Experiments

The main testbed is ResNet-20 on CIFAR-10, matching SAFHIRE, with ResNet-18 on Tiny ImageNet for scale. A second testbed is BERT-tiny on GLUE (SST-2, MNLI, QNLI, RTE, STS-B), matching THE-X, whose reported average degradation is within 1.48% of the plaintext model. The GP pipeline on the Medicines for Malaria Venture data serves as a third testbed and checks that the defense interface generalizes to a non-ReLU hand-off, where the authorized function is the kernel.

Metrics are reported per defense, on the same model and queries. On the attack side we measure surrogate agreement with the victim on held-out test inputs and the accuracy of the surrogate itself. On the honest-use side we measure honest accuracy change, latency and bytes communicated. For canary defenses we also measure detection rate and the attacker's winning probability as functions of canary fraction $m/(n+m)$ and the scale of $R$.

Three checks decide the proposal. The first is whether hand-off substitution against SAFHIRE-style shuffling reaches high surrogate agreement with substantially fewer queries than black-box extraction. If not, the motivating threat is weak. The second is whether canary entanglement drives the strongest adaptive attacker down to black-box-level agreement, while honest accuracy stays within one point of the undefended pipeline and latency rises by less than the canary fraction plus one matrix product per layer. The third is whether the $R=0$ ablation loses most of that protection. That result would show it is the entanglement, not the decoys, that restricts the client to the authorized transformation.