Manuscript Offprint

arXiv:2608.28843

Curvature Cryptanalysis of Smooth Transformer Feed-Forward Networks

Munawar Hasan, Apostol Vassilev

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We show that smooth two-layer feed-forward networks (FFNs) expose an additional structural model-extraction channel under a chosen-input raw-output oracle at the FFN branch. We consider transformer FFN branches with GELU or SiLU activations under chosen-input raw-output access, without access to parameters, gradients, or internal activations. We characterize and exploit a second-order leakage channel in which projected input Hessians form different mixtures of the same hidden symmetric rank-one factors induced by the FFN input weights. Centered finite-difference queries expose these mixtures, and joint factorization recovers the hidden FFN direction dictionary up to sign and permutation. We formalize the resulting Hessian collection as a partially symmetric decomposition and establish conditions for local identifiability and stability. We exploit vector-output stencil reuse to reduce the structural query cost by a factor of 16.

On independently trained CIFAR-10 vision transformers, only 16 projected Hessians, corresponding to only 8193 black-box queries, recover the hidden FFN directions with average absolute cosine alignment above 0.94, with 95.1 % of GELU and 91.9 % of SiLU directions exceeding 0.90 alignment. Recovery remains high across independently trained models, repeated extraction runs, and all transformer blocks, and finite-difference queries closely match the structural recovery obtained with exact Hessians. The recovered structure also supports functional extraction. Keeping the recovered directions fixed and fitting only the remaining FFN parameters yields high-fidelity substitutes with more than 93 % top-1 agreement, while their test accuracy remains within 0.90 and 0.62 percentage points of the GELU and SiLU targets, respectively. Finally, output rounding and Gaussian noise substantially reduce recovery under a fixed attack configuration, but adapting the finite-difference step restores average alignment to 0.9603 and 0.9398, respectively. These results establish an end-to-end path from black-box second-order observations to hidden FFN-structure recovery and functional replacement. Under the stated oracle model, smooth FFN curvature exposes internal parameter geometry that behavioral fidelity alone cannot reveal. Code is available on Github¹

Keywords: Model extraction · Transformer security & privacy · Curvature cryptanalysis · Structural extraction · Functional extraction

1 Introduction

Modern neural networks are increasingly exposed through interfaces that return rich numerical outputs rather than only discrete predictions. This access has made model extraction a practical concern: by repeatedly querying a target model, an adversary may construct a substitute that closely reproduces its observable behavior [1, 2]. Prior mathematical identification work shows that smooth-network derivatives reveal weights [3, 4, 5]. Most extraction attacks, however, are evaluated behaviorally. They ask whether the substitute matches the target's predictions, probabilities, or logits. Such agreement can reveal that a function has been approximated, but it does not necessarily reveal whether the target model's hidden parameter structure has been recovered. Two networks can behave similarly on a query distribution while possessing

¹https://github.com/mhasan08/curvature-cryptanalysis very different internal representations and weights. This distinction becomes particularly important for transformers. Their feed-forward networks (FFNs) contain a large fraction of the model parameters and repeatedly transform the hidden representation at every block. If black-box access exposes not only the behavior of an FFN but also information about the geometry of its hidden weight vectors, then model extraction becomes a substantially more concerning problem: the interface leaks internal structure rather than merely supporting behavioral fidelity. This raises a natural question:

Can black-box access reveal how a transformer FFN is internally parameterized—and can the leaked structure be turned into a high-fidelity functional extraction?

We adopt the threat model in [6], along with the assumptions on the oracle (black-box access to the target model) and the attacker's knowledge. Based on this, we demonstrate that smooth two-layer transformer FFN branches expose a practical structural extraction channel under a chosen-input raw-output oracle. Although the first-layer weight directions are never exposed directly, projected input Hessians contain them through a shared collection of symmetric rank-one factors. By varying the output projection and, if necessary, the probe point, the adversary obtains different mixtures of the same hidden geometry, enabling recovery of the normalized first-layer directions. Crucially, this structural recovery is not only descriptive: once the directions are extracted, they can be held fixed while the remaining FFN parameters are fitted from additional black-box queries, yielding a high-fidelity functional replacement. We study an overcomplete vector-output setting, quantify query requirements, and connect structural recovery to downstream replacement.

This observation suggests a cryptanalytic view of model extraction. Rather than treating each query only as an input-output example for training a surrogate, we treat oracle responses as measurements from which hidden structure can be inferred. The resulting problem resembles recovery of a shared latent dictionary: estimate multiple projected Hessians, identify the rank-one factors common to them, and recover the corresponding first-layer directions up to the unavoidable sign and permutation ambiguities. Importantly, the structural question is distinct from functional imitation. A surrogate may achieve high agreement without identifying these directions, while a successful structural attack must recover them directly. Turning this observation into a practical black-box attack is not immediate. The adversary does not observe derivatives and must estimate second-order information using only oracle responses. The resulting Hessian collection is highly undercomplete relative to the number of hidden units, its factorization is nonconvex, finite-difference measurements amplify output perturbations at small step sizes, and low reconstruction error alone does not guarantee that the correct hidden factors have been identified. These issues require both a formal understanding of when the shared curvature representation is locally identifiable and an extraction procedure that can recover its factors from finite-difference measurements.

We address these challenges by developing a curvature-based structural extraction framework for smooth transformer FFNs with GELU [7] and SiLU [8, 9] activations. We characterize the projected Hessians as a partially symmetric decomposition with shared rank-one atoms, derive conditions for local identifiability and stability, and instantiate the resulting attack using chosen-input finite differences followed by joint dictionary recovery. We then separately evaluate whether the extracted directions can support functional extraction when the remaining FFN parameters are fitted.

Our experiments on independently trained vision transformers show that the leakage reveals internal structure rather than merely approximating behavior. Using only 16 projected Hessians, the attack recovers the hidden FFN directions with average absolute cosine alignment 0.9644 for GELU and 0.9476 for SiLU, with more than 91% of directions exceeding 0.90 alignment. Recovery remains high across independently trained models, repeated extraction runs, and transformer blocks. The recovered structure also supports functional extraction: fixing the recovered directions and fitting only the remaining FFN parameters produces substitutes with more than 93% top-1 agreement with the target classifiers. Finite-difference queries closely match the structural recovery obtained with exact Hessians, while output perturbations that appear protective at one measurement scale can be substantially weakened by adapting that scale. These results expose a qualitatively different form of model leakage. Black-box outputs can encode enough second-order information to reveal hidden FFN geometry and reuse that structure in a high-fidelity substitute. In this setting, the model interface leaks more than behavior: it leaks part of the parameterization itself.

Contributions. This work makes the following contributions:

  • We formalize black-box structural extraction of smooth transformer FFN branches under a chosen-input raw-output oracle. The adversary observes only gθ(x)=W2ϕ(W1x+b1)+b2g_\theta(x) = W_2\phi(W_1x + b_1) + b_2 and receives no parameters, gradients, or internal activations. We distinguish recovery of the hidden FFN direction structure from the subsequent task of functional extraction.

  • We characterize and exploit second-order structural leakage in smooth transformer FFNs. Building on the known connection between smooth-network derivatives and hidden weights, we show how projected FFN Hessians expose a shared rank-one direction dictionary under a black-box security oracle.

  • We develop a theory explaining when the leaked curvature is sufficient for structural recovery. We formulate the Hessian collection as a partially symmetric decomposition, establish local identifiability of the hidden directions up to sign and permutation, derive a necessary measurement-count condition, and prove local stability under perturbed observations.

  • We construct a practical black-box curvature-extraction attack. Projected Hessians are estimated using centered finite differences, requiring exactly 2d2+12d^2 + 1 oracle queries per distinct probe stencil, where dd is the FFN input dimension. The shared direction dictionary is then recovered through random multi-restart joint optimization, with the final solution selected solely by the observed Hessian reconstruction loss. We optimize the attack to increase its power by taking into account that the same finite-difference stencil at one probe point gives the Hessian of every output coordinate simultaneously, thus allowing a substantial reduction of the number of queries to the oracle.

  • We demonstrate that the leakage is reproducible, nontrivial, and operationally useful. Using only 16 projected Hessians, the attack recovers the hidden FFN directions with average absolute cosine alignment 0.9644 for GELU and 0.9476 for SiLU, remaining stable across independently trained target models, extraction runs, and transformer blocks. The recovered structure also supports functional extraction: fixing the recovered directions and fitting only the remaining FFN parameters yields substitutes with more than 93% top-1 agreement and accuracy drops of only 0.90 and 0.62 percentage points for GELU and SiLU, respectively. Finally, we show that output rounding and Gaussian noise can be substantially weakened by adapting the finite-difference step, indicating that fixed-step evaluations can overestimate extraction resistance.

Paper organization. Section 2 reviews related work. Section 3 defines the target FFN, the chosen-input raw-output oracle, and the structural and functional extraction objectives. Section 4 develops the curvature leakage mechanism: it shows how projected FFN Hessians share hidden rank-one factors, reformulates these measurements as a partially symmetric decomposition, and establishes conditions for local identifiability and stability. It also clarifies the boundary of the analysis for residual connections, normalization, and piecewise-affine activations. Section 5 turns this structure into a practical black-box attack by estimating projected Hessians with finite differences, jointly recovering the shared first-layer direction dictionary, and optionally completing the remaining FFN parameters for full-model replacement. Section 6 then evaluates structural recovery, functional replacement, query complexity, and robustness to perturbed oracle responses. Finally, section 7 presents conclusion.

References (24)