Intelligent Detection of Cyber Attacks in Battery Energy Storage Systems

The secure and reliable operation of modern power grids and electric vehicles is critically dependent on advanced Battery Energy Storage Systems (BESS). At the heart of a BESS lies the battery management system (BMS), responsible for accurately estimating key states such as the State of Charge (SOC). Traditionally, BMS operated in isolated environments. However, the integration of IoT and cloud computing technologies has transformed BESS into complex Cyber-Physical Systems (CPS), enabling enhanced functionality through remote monitoring and control. This connectivity, while beneficial, introduces significant vulnerabilities to malicious cyber-attacks. Among these threats, False Data Injection Attacks (FDIAs) pose a severe risk by stealthily manipulating sensor measurements, such as current and voltage, which are fed into the BMS. These manipulations can cause significant errors in the estimated SOC, leading to dangerous operational states like over-charging or over-discharging of the energy storage cell, accelerated degradation, and even catastrophic thermal runaway. Therefore, developing robust and intelligent methods to detect such covert attacks is paramount for ensuring the safety, reliability, and longevity of battery energy storage infrastructure.

The core challenge in SOC estimation stems from the intrinsic non-linear electro-chemical dynamics of the energy storage cell. Accurate modeling is essential. A common and effective approach is to use an equivalent circuit model. An n-th order RC model is often employed, balancing accuracy with computational complexity. For this study, a second-order RC model is adopted, which provides a sufficient fidelity representation for analysis. The continuous-time dynamics of a single energy storage cell can be represented, and then discretized for digital implementation. The state-space representation is given by:

The state transition equations are:
$$x_{k+1} = f(x_k, u_k) + w_k$$
where the state vector \(x_k = [SOC_k, V_{1,k}, V_{2,k}]^T\) includes the SOC and the voltages across the two RC pairs. The input \(u_k = I_k\) is the measured current. The nonlinear function \(f(\cdot)\) is derived from the discretized circuit equations:
$$
\begin{aligned}
SOC_{k+1} &= SOC_k – \frac{\Delta t}{C_N} I_k \\
V_{1,k+1} &= e^{-\Delta t / (R_1 C_1)} V_{1,k} + R_1 (1 – e^{-\Delta t / (R_1 C_1)}) I_k \\
V_{2,k+1} &= e^{-\Delta t / (R_2 C_2)} V_{2,k} + R_2 (1 – e^{-\Delta t / (R_2 C_2)}) I_k
\end{aligned}
$$
Here, \(C_N\) is the nominal capacity, \(R_1, C_1\) and \(R_2, C_2\) are the polarization resistances and capacitances, and \(\Delta t\) is the sampling interval. The process noise is denoted by \(w_k\).

The output equation (measurement equation) is:
$$y_k = g(x_k, u_k) + v_k$$
where \(y_k = V_k\) is the measured terminal voltage. The function \(g(\cdot)\) is:
$$V_k = V_{OCV}(SOC_k) – V_{1,k} – V_{2,k} – R_0 I_k$$
The term \(V_{OCV}(SOC_k)\) is the nonlinear open-circuit voltage (OCV), typically represented by a polynomial function of SOC, for instance:
$$V_{OCV}(SOC) = p_0 + p_1 \cdot SOC + p_2 \cdot SOC^2 + p_3 \cdot SOC^3$$
The measurement noise is represented by \(v_k\). The parameters \(R_0, R_1, R_2, C_1, C_2, p_i\) are characteristics of the specific energy storage cell chemistry and are typically identified experimentally. \(w_k\) and \(v_k\) are assumed to be zero-mean Gaussian white noise processes with covariance matrices \(Q\) and \(R\), respectively.

A modern rack of lithium-ion energy storage cells in a cabinet, representing a battery energy storage system.

To estimate the SOC from the noisy current and voltage measurements, model-based filters are essential. The Extended Kalman Filter (EKF) is a widely adopted solution due to its ability to handle the nonlinearities in the system. The EKF linearizes the nonlinear functions \(f\) and \(g\) around the current state estimate using a first-order Taylor expansion. The linearized state transition matrix \(A_k\) and observation matrix \(C_k\) are given by the Jacobians:
$$
A_k = \left.\frac{\partial f}{\partial x}\right|_{\hat{x}_{k|k}, u_k}, \quad C_k = \left.\frac{\partial g}{\partial x}\right|_{\hat{x}_{k|k-1}, u_k}
$$
The standard Kalman filter recursion then proceeds with these linearized matrices:
$$
\begin{aligned}
\text{Prediction:} & \quad \hat{x}_{k+1|k} = f(\hat{x}_{k|k}, u_k) \\
& \quad P_{k+1|k} = A_k P_{k|k} A_k^T + Q \\
\text{Update:} & \quad K_{k+1} = P_{k+1|k} C_{k+1}^T (C_{k+1} P_{k+1|k} C_{k+1}^T + R)^{-1} \\
& \quad \hat{x}_{k+1|k+1} = \hat{x}_{k+1|k} + K_{k+1}(y_{k+1} – g(\hat{x}_{k+1|k}, u_{k+1})) \\
& \quad P_{k+1|k+1} = (I – K_{k+1} C_{k+1}) P_{k+1|k}
\end{aligned}
$$
This algorithm provides an optimal (in the minimum mean-square error sense for linearized models) estimate of the SOC and other states, assuming the noise characteristics are known. The accuracy of this SOC estimate is critical for all BESS control and protection functions.

The FDIA threat model assumes an adversary with the capability to intercept and modify data transmitted from the sensors to the BMS, or to directly compromise the sensor readings. The attack does not require physical tampering with the energy storage cell itself. The adversary injects a malicious bias vector \(a_k\) into the true measurement vector \(z_k = [I_k, V_k]^T\), resulting in the corrupted measurement \(\tilde{z}_k\) received by the BMS:
$$\tilde{z}_k = z_k + a_k$$
For instance, an attack could involve alternately adding small negative biases to the voltage measurement and positive biases to the current measurement over a sustained period. While each individual bias might be small enough to fall within expected sensor noise bounds, their coordinated, sequential application can cause the EKF to produce a significantly erroneous SOC estimate. The effect is a slow divergence where the BMS “thinks” the energy storage cell is at a different SOC than it actually is. A negative bias on estimated SOC could lead to over-discharge, while a positive bias could cause overcharge, both severely damaging the energy storage cell. The stealthiness of such attacks makes them particularly dangerous, as they can evade traditional bad-data detection methods that look for large, abrupt anomalies.

Model-based detection methods, such as residual-based chi-square detectors or Cumulative Sum (CUSUM) algorithms, have been proposed. They monitor the difference (residual) between the predicted output and the actual measurement:
$$r_k = y_k – g(\hat{x}_{k|k-1}, u_k)$$
Under normal conditions, this residual sequence is zero-mean with a known covariance. An attack perturbs this sequence. However, these methods have significant limitations. Their performance is highly sensitive to the accuracy of the underlying battery model. Factors like energy storage cell aging, temperature variations, and capacity fading cause model parameters to drift, making it difficult to maintain an accurate reference model and choose a fixed detection threshold. Furthermore, they struggle to detect coordinated, low-magnitude attacks that are carefully designed to keep the residual within statistical bounds.

Data-driven methods, particularly deep learning, offer a promising alternative by learning the normal temporal patterns and correlations in the BESS operational data directly, without relying on a precise physical model. Recurrent Neural Networks (RNNs), like Long Short-Term Memory (LSTM) networks, are natural candidates for sequential data. An LSTM-based auto-encoder can be trained to reconstruct normal operational sequences (current, voltage, estimated SOC). During detection, a high reconstruction error indicates a potential anomaly or attack. However, LSTMs can suffer from vanishing gradients and may struggle with very long-term dependencies in the data stream from the energy storage cell.

The Transformer architecture, renowned for its success in natural language processing, has shown great potential in time-series analysis due to its self-attention mechanism. This mechanism allows the model to weigh the importance of all time steps in a sequence when encoding any single time step, effectively capturing both short- and long-range dependencies. The standard Transformer uses a positional encoding (PE) to inject information about the order of the sequence, typically using sinusoidal functions:
$$PE(pos, 2i) = \sin(pos / 10000^{2i/d_{model}})$$
$$PE(pos, 2i+1) = \cos(pos / 10000^{2i/d_{model}})$$
where \(pos\) is the position and \(i\) is the dimension. While effective for many tasks, this fixed encoding scheme may not optimally capture the complex, continuous, and often periodic temporal dynamics inherent in energy storage cell data, such as charge-discharge cycles.

To address this, we propose the T2V-Transformer, an intelligent detection framework that enhances the standard Transformer for FDIAs in BESS. The key innovation is the replacement of the standard positional encoding with a learnable temporal embedding layer called Time2Vector (T2V). For a scalar time index \(\tau\), the T2V encoding is a vector \(t2v(\tau)\) defined as:
$$
t2v(\tau)[i] =
\begin{cases}
\omega_i \tau + \phi_i, & \text{if } i = 0 \\
\sin(\omega_i \tau + \phi_i), & \text{if } 1 \le i \le k
\end{cases}
$$
where \(k\) is the dimension of the periodic part of the embedding. The learnable parameters \(\omega_i\) and \(\phi_i\) allow the model to adaptively discover the most relevant frequencies and phase shifts for the data. The linear term (\(i=0\)) captures non-periodic, monotonic trends in the energy storage cell data (e.g., gradual capacity fade), while the periodic sine terms capture recurring patterns like daily charge cycles. This rich, learnable temporal representation is then added to the input feature embeddings (current, voltage, etc.) before being passed to the Transformer encoder.

The overall architecture of the proposed T2V-Transformer detection model is as follows:

  1. Input & Preprocessing: Sequential data windows containing measured current, voltage, and the BMS’s own estimated SOC and voltage are normalized.
  2. Temporal Embedding (T2V Layer): Each time step in the window is processed by the T2V layer, generating a temporal feature vector that is concatenated with the normalized sensor data features.
  3. Feature Extraction (Transformer Encoder): The combined features are processed by a stack of Transformer encoder layers. Each layer consists of a multi-head self-attention mechanism and a position-wise feed-forward network, with layer normalization and dropout applied for stability and regularization. This allows the model to learn complex interdependencies between different time steps and features of the energy storage cell operation.
  4. Classification Head: The output sequence from the encoder is aggregated via global average pooling. This pooled representation is then fed through fully connected layers and a final softmax layer to produce a binary classification: ‘Normal’ or ‘Under FDIAs’.

The model is trained in a supervised manner using historical data labeled as normal or attacked. The loss function is typically binary cross-entropy:
$$
L = -\frac{1}{N} \sum_{i=1}^{N} [y_i \log(p_i) + (1-y_i) \log(1-p_i)]
$$
where \(y_i\) is the true label and \(p_i\) is the predicted probability of an attack for the \(i\)-th sample.

To validate the proposed method, a simulation environment was created. A second-order RC model with parameters for a typical lithium-ion energy storage cell was implemented. The EKF was used for state estimation under a dynamic load profile simulating real grid-connected BESS operation with frequent charge-discharge transitions. FDIAs were simulated by injecting biases of varying magnitudes (e.g., 50mV, 100mV for voltage; 0.5A, 1A for current) into the measurement stream after an initial period of normal operation. The simulation generated a comprehensive dataset of multivariate time series, each labeled as normal or attacked. The dataset was split into training and testing sets. The performance of the T2V-Transformer was compared against benchmark models including an LSTM Auto-encoder and a standard Transformer (with sinusoidal PE). The following table summarizes key parameters for the models and training:

Component / Parameter Value / Description
Battery Model 2nd-order RC (R0, R1, R2, C1, C2)
Input Features [Current (I), Voltage (V), Estimated SOC, Estimated Voltage]
Sequence Window 5 time steps
T2V-Transformer Encoder Layers 4
Attention Heads per Layer 4
T2V Output Dimension (periodic) 20
Optimizer Adam (lr=0.0003)
Loss Function Binary Cross-Entropy

The detection performance was evaluated using standard metrics: Accuracy, Precision, Recall, F1-Score, and Cross-Entropy Loss. The results clearly demonstrate the effectiveness of the proposed approach. The T2V-Transformer consistently achieved superior performance across different attack magnitudes. The integration of the learnable Time2Vector layer provided a clear advantage over the fixed positional encoding of the standard Transformer, especially in capturing the subtle temporal anomalies introduced by stealthy FDIAs. The following table presents a comparative performance analysis for a specific attack scenario (100mV voltage bias):

Detection Model Accuracy (%) Precision (%) F1-Score (%) Loss
LSTM Auto-encoder 94.5 93.2 92.8 0.174
Standard Transformer 95.2 94.3 94.1 0.142
T2V-Transformer (Proposed) 96.4 95.5 94.9 0.129

The results show that the T2V-Transformer not only achieves the highest accuracy but also maintains a better balance between precision and recall (as reflected in the higher F1-score) and converges to a lower loss. This indicates a more robust and reliable detection capability. Importantly, the method proved effective even for low-magnitude attacks (e.g., 50mV, 0.5A), which are more challenging to detect. The model successfully learned the inherent temporal patterns of the healthy energy storage cell operation and identified deviations caused by the injected false data, without the need for manually tuning detection thresholds or maintaining an exact physical model of the aging energy storage cell.

In conclusion, the cybersecurity of Battery Energy Storage Systems is a critical concern for modern energy infrastructure. This work addresses the stealthy threat of False Data Injection Attacks against the core State-of-Charge estimation function. By proposing the T2V-Transformer, an intelligent, data-driven detection model, we offer a significant advancement over traditional model-based and simpler deep learning methods. The key innovation lies in the integration of a learnable Time2Vector temporal embedding with the powerful self-attention mechanism of the Transformer. This combination allows the model to autonomously discover and leverage both periodic and non-periodic temporal features in the operational data of the energy storage cell, leading to highly accurate and robust detection of low-magnitude, coordinated FDIAs. The experimental validation confirms the superior performance of the proposed method. Future work will focus on testing the model with real-world BESS data under varying aging conditions and extending the framework to detect a wider range of cyber-physical attacks, further solidifying the resilience of our critical energy storage assets.

Scroll to Top