Manuscript Offprint
arXiv:2608.25681Adversarial Training of Linear Models under Stealthy Attacks
Lovisa Eriksson, Dave Zachariah, and André M. H. Teixeira
Abstract—Predictive models are widely used in many fields, but are vulnerable to false data injection attacks. To address this, detection schemes and adversarial training have been proposed, but such approaches lack guarantees against stealthy attacks. We therefore propose a detector-based switched model, in which optimal attack strategies are stealthy. For linear prediction models, we derive a convex formulation of the resulting adversarial risk. The model incorporates protected features and introduces a hyperparameter modelling attack probability, enabling an explicit performance trade-off between clean and attacked data regimes. Numerical simulations on real and synthetic data show improved performance on partially attacked data, even for misspecified attack probabilities.
Index Terms—Adversarial machine learning, False data injection attacks, Detection, Robust estimation
I. INTRODUCTION
A basic idea for most modern machine learning algorithms is that a predictive model can be optimized on a set of past data such that it performs well on new data. However, in reality, the new data may not be drawn from the same distribution as the past data, due to natural variations [1], or false data injection attacks [2]. Applying a model to data subject to attacks presents a particular challenge since the new data is intentionally crafted to deteriorate the model performance [3].
False data injection attacks have been extensively studied, both in machine learning [3], [4], [5] and adjacent fields such as control theory [2]. To make the problem feasible, different assumptions are put on the attacker. Existing work either imposes a limit on the size of attack perturbations [3], [5] or imposes stealthiness [6], [7]. Classical robust statistics studies estimators under bounded contamination and worst-case deviations from nominal assumptions [1], but without analytically characterizing the resulting performance trade-off's across regimes. Common defence mechanisms include adversarial training and detection schemes. Adversarial training [5], [8] improves robustness through the generation of static perturbed examples, thus limiting the defence against unforeseen and adapting attacks. Detection schemes against adversarial examples has been shown infective against stronger, tailored attacks [4].
To address these gaps simultaneously, we consider the use of a predictive model that switches mode depending on whether an attack detector triggers an alarm or not. Importantly, the attack can be stealthy and we consider the possibility that some features of the new data can be protected. Formal results are derived for linear models. Our main contributions are (i) a method that makes explicit trade-offs between accuracy on clean and attacked data, (ii) deriving adversarial stealthiness as a consequence of the proposed prediction model, and (iii) providing explicit convex formulations for adversarial training of linear models under stealthy attacks. Numerical experiments illustrating the performance use both synthetic and real data.
Notation: Throughout the paper we use to denote the euclidean norm, to denote expectation of and is the covariance between and , with . The natural logarithm is denoted log and the transpose of a vector is denoted . We use to denote the probability density function of , and to denote the probability of event .
The code is available at GitHub:
LovisaLuna/code_Adversarial-Training-of-Linear-Models-under-Stealthy-Attacks
(ii) binary classification using logistic regression with logistic loss
During training, we observe samples drawn independently from . At test time, however, we observe the features which could be manipulated by an attack, indicated by an unobserved variable that occurs with probability . We assume that features are partitioned into protected and unprotected components, which we express as:
Definition 1. An attack event is adversarial if the observation follows
where . That is, the unprotected features in are designed to maximize the loss of a given model .
The authors are with Department of Information Technology, Uppsala University, Uppsala, Sweden. This work is supported by the Swedish Research Council under grants 2023-05234, 2021-05022 and 2024-03903; by the Swedish Foundation for Strategic Research; and by the Knut and Alice Wallenberg Foundation.

Under this attack, we can express the process that generates the observation using an acyclic graph, illustrated to the left. The process induces a (marginal) distribution at test time.
Definition 2. A (deterministic) anomaly detector is a function and has a false alarm rate . For notational brevity, the detector output will be written as whenever it is unambiguous.
The detector splits the feature space into two parts depending on whether or . Therefore, we propose a switched model approach that uses a nominal model and a recovery model , depending on . We can express the above approach using the switched model
The loss of the switched model can then be expressed as
such that its expected loss, or risk, is
It should be noted that minimizing the risk of the switched model can be no worse than using only one of the models and , i.e.,
However, this does not guarantee that attacked data is handled by the recovery model. If an attacker has complete knowledge of the detector function , an attack event can be designed to evade detection, i.e. to be stealthy. Assuming full model knowledge of the adversary is a standard assumption in security to make sure the security of proposed methods rely only on theoretical principles, rather than lack of equipment or knowledge of the adversary [9].
Definition 3. An adversarial attack event is stealthy w.r.t. detector if the latter misses the attack with probability . This occurs when the set of feasible attacks is further restricted to exploit the detector, by setting
The goal of the paper is to learn a risk-minimizing switched model , using clean training data, that is robust against adversarial and stealthy attacks at test time, given a detector with false alarm rate no greater than .
III. THEORETICAL RESULTS
We now show that under certain conditions on the recovery model , the attack (4) will be essentially equivalent to an stealthy adversarial attack. We formalise the required conditions as being secure.
Definition 4. The recovery model is said to be secure w.r.t and if there exists an imputation function such that, for all ,
Thus the secure imputes and reverts to the prediction of , rather than taking the unprotected features at face value. With a secure model, an attack event can never cause more harm when detected.
Proposition 1. Let be a model (5) such that is secure w.r.t and . Then, any adversarial attack event against this model yields the same risk as a stealthy adversarial attack. That is, letting ,
Proof. Note that using the constraint ,
It is then sufficient to prove that
Let . When , (13) holds trivially. Now assume . Then, by security of as per Definition 4, there exists a mapping such that and
(14)
Since we will use a secure model, we can from here on assume that all adversarial attacks are stealthy.
For the rest of this section, as well as for the numerical experiments, we consider the imputation function to be
where is the optimal linear predictor [10], and use the energy detector
where from (15), a desired upper bound on the false alarm rate, and
is the error covariance of in (15).
The threshold can be chosen to guarantee a set false alarm rate in different ways: (i) For a general distribution, guarantees a false alarm bounded by , through the Chebychev inequality [11]; (ii) for a Gaussian distribution, the detector corresponds to a chi-test and the exact false alarm rate of a given can thus be determined.
Using this detector together with linear or logistic regression in (5), we show that there is a choice of that guarantees to be secure w.r.t. and .
Lemma 1. Consider the switched model (5), with anomaly detector (16). Then, letting
ensures that is secure w.r.t. and .
Proof. Using in (15) with a linear regression model, we have
and , thus satisfying the conditions in Definition 4. A corresponding argument can be made for a logistic model.
Now, we show that the risk (7) under attack is convex, guaranteeing that the global optima can be found by numerical optimization. For notational convenience, let .
Proposition 2. Consider the linear regression model (1) with anomaly detector (16). The risk (7) under stealthy adversarial attacks, with attack probability , is
The risk is a convex function of the model parameters and .
Proof. The expectation (7) can be divided into two cases depending on the attack event a, so that
By (6), the second term becomes
Now, we can focus on the first term. Since the adversary is stealthy,
and plugging in the squared error loss this becomes
where , and we can rewrite
Now, letting , we get
By collecting the constant terms in , the expression can be rewritten as
Define . We can choose in the direction of the main singular vector of , such that
and , which gives us the maximum as
The expression can be compactly written as
This formulation is convex in since it is a monotonically increasing function of a weighted sum of convex functions. Finally, the full risk (21) thus is another weighted sum of convex functions in and .
Similarly, the risk under attack for logistic regression can be shown to be convex.
Proposition 3. Consider the logistic regression model (2) with anomaly detector (16). The risk (7) under stealthy adversarial attacks with attack probability , is
(32)
This risk is convex in the model parameters .
Proof. The proof uses the same main ideas as the one for Proposition 2 First, the risk is divided into cases depending on whether an attack is present, and the second term follows directly from plugging in the logistic loss. Now, consider the first term, where an attack is present. Note that by monotonicity of the logarithm and exponential, maximizing the logistic loss is equivalent to maximizing
Letting , we get
By choosing in the proper direction, we obtain the maximum loss
and the desired formulation is obtained. The convexity follows straight-forward from the convexity of the logistic loss and norms.
It can be noted that as in (21) and (32), the risk minimizing sets , as this minimizes and the rank of allows to be treated as a free variable.
IV. METHOD
The adversarial training is achieved by minimizing the empirical expectation in (21) or (32), with constraint (18), using the clean training data. We use stochastic gradient descent with momentum and decreasing step size. The method requires specifying an upper bound on false alarm , and on the attack probability, denoted .
V. NUMERICAL RESULTS
For comparison, we use two different baselines. First, a fully secure model denoted , with the restriction , so that the unprotected features are discarded and the model is secure w.r.t. any detector and itself by Definition 4. Second, a standard switched model denoted with , i.e. trained to minimize the risk on clean data, with constraint (18), which we denote .
All models are evaluated with respect to their (empirical) risk under data that is under stealthy adversarial attacks with probability . The data is split 50-50 into a train and a test set, and we evaluate the method on both synthetic and real world data.
A. Synthetic data
We evaluate our methodology for linear regression where and the label is given by . The distribution is a zero mean Gaussian with for all and (remaining covariances are zero). We use training samples.
Fig. 1 illustrate the results. First, stealthy attacks are clearly detrimental to the standard model since no attacks are detected! Second, when , the proposed switched model has the same performance but converges to that of the fully secure model as increases. Between these points it shows an improved performance. Third, even as the assumed upper bound is incorrect, , there is still a range in which the risk is lower than the secure model and is consistently lower than the standard model.
Simulations for other parameters of the Gaussian, and for logistic regression, show the same overall behaviour with variation only in convergence rate, and plots for these are therefore excluded from this paper.
B. Real world data
We further evaluate our training scheme on a real word Credit Card Fraud Detection data set [12] with samples. The feature ‘amount’ is treated as protected and 21 features are treated as unprotected (7 features removed due to high correlation with other features). The results are shown in Fig. 2, where we see that the method also works for complex real word data with a more significant number of features.

(a)

(b)
Fig. 1: (a) Risk versus attack probability , including misspecified . (b) Risk versus , where red dots mark when the model is correctly specified and the dotted line is the correctly specified model from (a). Both (a) and (b) also show the standard switched model , and the fully secure model . Both cases set yielding an actual false alarm rate of 1.3%.

(a)

(b)
Fig. 2: (a) Risk versus attack probability . (b) Same as (a) but also includes the standard switched model. In this case we set the bound yielding an actual false alarm rate of 0.01%.
VI. Conclusion
We have shown that using an attack detector and aligning the recovery model with the nominal model, adversarial attacks are forced to be stealthy. A convex risk for this setup is derived for linear and logistic regression, and numerical results support the optimality of the resulting model. Future work includes extension to more complex models and detectors, extension to neural networks, and further investigating the relation between our method, adversarial training, and regularisation.
REFERENCES
[1] P. J. Huber, “Robust Estimation of a Location Parameter,” The Annals of Mathematical Statistics, vol. 35, no. 1, pp. 73 – 101, 1964.
[2] G. Liang, J. Zhao, F. Luo, S. R. Weller, and Z. Y. Dong, “A review of false data injection attacks against modern power systems,” IEEE Transactions on Smart Grid, vol. 8, no. 4, pp. 1630–1638, 2017.
[3] A. H. Ribeiro and T. B. Schön, “Overparameterized linear regression under adversarial attacks,” Trans. Sig. Proc., vol. 71, p. 601–614, jan 2023.
[4] N. Carlini and D. Wagner, “Adversarial examples are not easily detected: Bypassing ten detection methods,” in Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security, ser. AISec '17. New York, NY, USA: Association for Computing Machinery, 2017, p. 3–14.
[5] I. J. Goodfellow, J. Shlens, and C. Szegedy, “Explaining and harnessing adversarial examples,” in Conference Track Proceedings of the 3rd International Conference on Learning Representations, ICLR 2015, 2015.
[6] D. I. Urbina, J. A. Giraldo, A. A. Cardenas, N. O. Tippenhauer, J. Valente, M. Faisal, J. Ruths, R. Candell, and H. Sandberg, “Limiting the impact of stealthy attacks on industrial control systems.” New York, NY, USA: Association for Computing Machinery, 2016.
[7] Y. Mao, H. Jafarnejadsani, P. Zhao, E. Akyol, and N. Hovakimyan, "Novel stealthy attack and defense strategies for networked control systems," IEEE Transactions on Automatic Control, vol. 65, no. 9, pp. 3847–3862, 2020.
[8] W. Zhao, S. Alwidian, and Q. H. Mahmoud, “Adversarial training methods for deep learning: A systematic review,” Algorithms, vol. 15, no. 8, 2022.
[9] C. E. Shannon, “Communication theory of secrecy systems,” The Bell System Technical Journal, vol. 28, no. 4, pp. 656–715, 1949.
[10] T. Kailath, A. H. Sayed, and B. Hassibi, Linear Estimation. New Jersey, Prentice Hall, 2000.
[11] X. Liu, D. Zachariah, and P. Stoica, “Robust prediction when features are missing,” IEEE Signal Processing Letters, vol. 27, pp. 720–724, 2020.
[12] N. Elgiriyewithana, “Credit card fraud detection dataset 2023,” 2023. [Online]. Available: https://www.kaggle.com/dsv/6492730