Adversarial Attacks on Online Handwriting using Salience-based Temporal Editing


Abstract

Deep learning models for online handwriting recognition have been shown effective and are increasingly deployed in practical applications. However, their vulnerability to adversarial attacks is still a challenge. Existing adversarial methods are predominantly designed for image-based inputs and typically rely on additive spatial perturbations. When applied to online handwriting, which is inherently represented as a time series of pen trajectories, such perturbations often introduce high-frequency jitter and visibly unnatural stroke artifacts. In this work, we propose a novel adversarial attack framework for online handwriting recognition based on salience-guided temporal editing. Instead of adding noise, the proposed method generates adversarial examples by inserting and deleting points at time steps selected according to temporal salience, preserving the shape and smoothness of the original handwriting. Temporal salience is estimated using gradient-based activation mapping, which guides edits toward time steps that strongly support the original class prediction. We evaluate the proposed approach on the Unipen and CASIA-OLHWDB datasets under both white-box and one-shot black-box attack settings. Experimental results demonstrate that while conventional image-based attacks achieve strong white-box performance, they exhibit poor transferability across models. In contrast, the proposed temporal editing attack achieves stronger one-shot black-box transferability while preserving the visual structure of the handwriting. These results indicate that temporal editing is a relevant threat model for online handwriting recognition, particularly in one-shot black-box transfer settings.

1 Introduction↩︎

Online handwriting recognition differs from offline handwriting recognition in that the input is a sequence of pen-tip coordinates rather than a raster image. Modern online handwriting recognizers build on sequence models such as Recurrent Neural Networks (RNN) [1], Temporal Convolutional Neural Networks (CNN) [2], and Transformers [3], and have achieved high accuracy on this input modality [4][8]. However, adversarial robustness for online handwriting remains less explored than for image-based recognition models.

As these systems are deployed in real-world applications, concerns about their reliability and security have become more pronounced. In particular, adversarial attacks are a widely known weakness of neural networks [9], [10]. Adversarial attacks work by adding small perturbations to the input with the aim of causing misrecognition by the models.

However, most adversarial attacks were originally developed for image-based classifiers with perturbations constrained by pixel-wise \(L_p\) norms. For example, various gradient-based attack methods have been proposed, such as Fast Gradient Sign Method (FGSM) [11], Projected Gradient Descent (PGD) [12], and the Carlini-Wagner (CW) attack [13]. These methods are designed to degrade recognition performance while remaining imperceptible in the image domain. In comparison, attacks on time series are much less explored, and most adversarial attacks on time series are adapted from image-based methods [14], [15].

Figure 1: Comparison between adversarial noise via perturbations and the proposed temporal editing. Adversarial attacks such as BIM and CW use spatial perturbations to generate adversarial examples. The proposed method adds and removes time steps for more realistic characters.

The online handwriting data considered in this study is represented as a sequence of two-dimensional pen-tip coordinates, where each time step \(t\) contains a coordinate vector \(\mathbf{x}_t \in \mathbb{R}^2\). In the image domain, small perturbations can appear as inconspicuous noise due to the texture present in natural images. However, directly applying image domain adversarial noise to time series data frequently results in abrupt temporal fluctuations and high-frequency artifacts, which create unnatural deformations in online handwriting trajectories, as illustrated in Fig. 1. This indicates that even when perturbations satisfy small \(L_p\) norms, the resulting time series may violate the kinematic smoothness and structural regularities inherent to human handwriting. In other words, the implicit assumption in the image domain that “small noise is difficult for humans to perceive” is not necessarily valid for time series data. This discrepancy highlights a fundamental limitation in current adversarial attacks on time series.

Beyond naturalness issues, most gradient-based adversarial attacks operate under a white-box assumption, requiring full access to model parameters and gradients. In practice, however, deployed handwriting recognition systems are often accessible only through prediction interfaces, making black-box adversarial attacks a more realistic threat model. Commercial handwriting recognition and authentication services typically expose only final recognition outputs, rendering white-box assumptions impractical in many real-world scenarios. Therefore, evaluating robustness under black-box conditions is essential for understanding the true vulnerability of online handwriting recognition systems.

To address these challenges, we propose Adversarial Iterative Temporal Editing (AITE), a novel adversarial attack method that generates adversarial examples through discrete editing operations in the time dimension rather than additive noise in the spatial dimensions. Specifically, AITE iteratively performs element-wise insertion and deletion on the input sequence based on the discriminative importance, or salience, of individual time steps. Salience is estimated using Gradient-weighted Class Activation Maps (Grad-CAM) [16], allowing the attack to target temporally critical regions while preserving the overall geometric structure and kinematic smoothness characteristic of natural handwriting trajectories.

The contributions of this study are summarized as follows:

  • We highlight the inadequacy of spatial perturbation-based adversarial noise for online handwriting.

  • We propose a novel adversarial attack framework based on salience-guided temporal editing.

  • The proposed method is evaluated under both white-box and one-shot black-box attack settings on the Unipen [17] and CASIA-OLHWDB [18] online handwritten character datasets. Experimental results demonstrate that temporal editing achieves stronger visual similarity than conventional spatial perturbation-based noise attacks.

  • The black-box attack settings demonstrate that the salience-based editing is effective at attacking unseen models.

Furthermore, for reproducibility, we will release the source code at GitHub1.

2 Related Work↩︎

2.1 Adversarial Attacks↩︎

Adversarial attacks were first extensively studied in the context of image classification, where small, carefully crafted perturbations can induce misclassification while remaining visually imperceptible [10]. The vulnerability of deep neural networks to adversarial perturbations was first systematically demonstrated by Szegedy et al. [19], who formulated adversarial example generation as an optimization problem that searches for minimal input perturbations capable of changing a model’s prediction. To reduce the computational cost of this approach, Goodfellow et al. [11] proposed FGSM, which approximates the optimization by applying a single gradient step in the direction of the loss. Since then, many methods, such as Basic Iterative Method (BIM) [20], PGD [12], and the CW attack [13], have improved upon gradient-based adversarial attacks through iterative updates and regularized perturbation objectives. A separate line of work targets the black-box transferability of adversarial examples between models. MI-FGSM [21] accumulates a momentum term over the iterative input gradients to stabilize the update direction, while NI-FGSM [22] extends MI-FGSM with Nesterov accelerated gradients by evaluating the gradient at a look-ahead point. TI-FGSM [23] convolves the input gradient with a smoothing kernel before each update so that perturbations become approximately translation-invariant and transfer better across architectures. While these methods form the foundation of adversarial attack research, they were all originally developed for image-based classifiers and rely on additive, pixel-wise perturbations.

2.2 Adversarial Attacks on Time Series↩︎

Compared to image recognition, research on adversarial attacks against time series data is an emerging area. Carlini et al. [24] demonstrated that hidden commands can be embedded into automatic speech recognition systems. Fawaz et al. [15] evaluated FGSM and BIM on time series classification datasets and reported the vulnerability of deep learning–based time series classifiers. Karim et al. [14] proposed an Adversarial Transformation Network (ATN) using a distilled model to act as a surrogate to mimic the behavior of classical time series classification models. In addition, there have been black-box models that have been proposed for time series classification [25][27]. However, these methods still apply perturbations which may not be appropriate for all time series. Furthermore, many of these methods require feedback from the attacked model [28]. Developing attack methods that take into account structures specific to time series data (e.g., temporal dependency and sequence smoothness) remains an important research challenge [29].

2.3 Adversarial Attacks on Handwriting Recognition↩︎

Adversarial attacks on handwriting recognition have mainly been studied in the context of offline handwriting recognition, where adversarial attacks on offline handwriting have been shown to be effective on offline signature verification [30][32] and character recognition in various languages [33][35].

In contrast, research on adversarial attacks against online handwriting recognition is very limited. Yamashita et al. [36] showed that spatial perturbation-based attacks work on online handwriting and proposed a defense based on time series transformations. Lopresti and Raim [37] showed that a generative attack on online handwriting is possible.

3 Adversarial Attacks↩︎

Figure 2: Example of transferability of adversarial attacks. In the white-box setting (left), the adversarial attack has full knowledge of the target model. In the black-box setting (right), the adversarial sample is generated against one model and is used to attack an unseen target model.

3.1 Threat Model↩︎

We consider adversarial attacks against online handwriting recognition systems whose inputs are pen-tip trajectories of handwritten characters. In this study, each character is represented as a time series \(\mathbf{X}\) with ground-truth label \(y\): \[\mathbf{X} = (\mathbf{x}_1, \dots, \mathbf{x}_t, \dots, \mathbf{x}_T),\] where \(T\) is the sequence length and \(\mathbf{x}_t \in \mathbb{R}^d\) denotes the pen-tip coordinate vector at time step \(t\). In our experiments, we use two-dimensional coordinate sequences, i.e., \(d=2\). A recognition model \(f_\theta\) with trained parameters \(\theta\) maps \(\mathbf{X}\) to class logits \(f_\theta(\mathbf{X}) \in \mathbb{R}^{C}\). The predicted class label is \[\hat{y} = \arg\max_{c} f_\theta(\mathbf{X})_c .\] The goal of an adversarial attack is to find an adversarial example \(\mathbf{X}_{\mathrm{adv}}\) such that \[\hat{y}_{\mathrm{adv}} = \arg\max_{c} f_\theta(\mathbf{X}_{\mathrm{adv}})_c, \quad \hat{y}_{\mathrm{adv}} \neq y,\] while the resulting handwriting remains visually plausible.

Adversarial attacks can be broadly categorized into white-box and black-box attacks, and we evaluate the proposed method under both settings. In the white-box setting, the attacker has full access to the model architecture and parameters \(\theta\) and the gradients of \(f_\theta(\mathbf{X})\). This allows the attacker to design \(\mathbf{X}_\mathrm{adv}\) so that it directly exploits the model’s decision boundary. In the black-box setting, the attacker has no access to the model’s parameters or gradients. This setting reflects realistic deployment conditions, as malicious attackers would not have access to the model directly.

Furthermore, as illustrated in Fig. 2, we consider one-shot transferable black-box attacks. In this setting, the adversarial attack method is permitted only a single attempt and receives no feedback from the target model. Transferability is particularly important for real-world scenarios, as deployed handwriting recognition systems typically expose only final predictions, preventing iterative probing or gradient access by an adversary [38]. Our black-box evaluation is therefore transfer-based and one-shot: adversarial samples are generated using a surrogate model and then submitted once to unseen target models. We do not consider query-based black-box attacks, where the adversary adaptively updates the input using repeated feedback from the target model.

3.2 Spatial Perturbation-based Adversarial Attacks↩︎

Spatial perturbation-based adversarial attacks typically generate adversarial examples by adding small-magnitude noise to input representations. As a representative example, FGSM [11] creates an adversarial example \(\mathbf{x}_{\mathrm{fgsm}}\) by: \[\mathbf{X}_{\mathrm{fgsm}} = \mathbf{X} + \epsilon \cdot \mathrm{sign}\!\left(\nabla_\mathbf{X} L(f_\theta(\mathbf{X}), y)\right), \label{eq:fgsm}\tag{1}\] where \(L(f_\theta(\mathbf{X}), y)\) is the loss function between the model prediction for input \(\mathbf{X}\) and the label \(y\), \(\nabla_\mathbf{X} L(f_\theta(\mathbf{X}), y)\) is the gradient of the loss with respect to the input, \(\mathrm{sign}(\cdot)\) is the element-wise sign function, and \(\epsilon\) is a hyperparameter controlling the perturbation magnitude. Iterative methods, such as BIM [20] and PGD [12], repeat this process given constraints.

4 Proposed Method↩︎

We propose a temporal editing attack that generates adversarial examples by modifying the time series in the time dimension rather than adding spatial noise. The key idea is to induce misclassification through insertion and deletion of time steps while preserving the overall shape and smoothness of the handwriting. As shown in Fig. 1, this design directly addresses the limitation of image-based adversarial perturbations, which often produce unnatural artifacts when applied to time series, including online handwriting.

4.1 Temporal Editing↩︎

In order to modify the time series in the time dimension, we define two basic editing operations, temporal insertion and temporal deletion.

4.1.1 Temporal Insertion↩︎

Given input time series \(\mathbf{X}\) with \(\mathbf{x}_t\in\mathbb{R}^d\), temporal insertion adds a new point between two adjacent points \((\mathbf{x}_i,\mathbf{x}_{i+1})\) with \(i\in\{1,\ldots,T-1\}\). Interpolation is used to preserve local continuity and the new sequence becomes: \[\label{eq:insertion} \mathbf{X}_\mathrm{ins}=(\mathbf{x}_1,\dots,\mathbf{x}_{i},\frac{\mathbf{x}_i + \mathbf{x}_{i+1}}{2},\mathbf{x}_{i+1}\dots,\mathbf{x}_T),\tag{2}\] increasing the number of time steps by one.

4.1.2 Temporal Deletion↩︎

Temporal deletion removes one time step from the sequence. Since removing an endpoint may severely distort the overall shape, we exclude endpoints from deletion candidates. Given a selected time index \(j\), deletion removes the \(j\)-th element from \(\mathbf{X}\) to form: \[\label{eq:deletion} \mathbf{X}_\mathrm{del}=(\mathbf{x}_1,\dots,\mathbf{x}_{j-1}, \mathbf{x}_{j+1},\dots,\mathbf{x}_T).\tag{3}\] The resulting \(\mathbf{X}_\mathrm{del}\) has one fewer time step than the original \(\mathbf{X}\).

4.2 Adversarial Iterative Temporal Editing (AITE)↩︎

To create adversarial examples, an iterative approach is taken. In one step of AITE, we select an insertion position \(i\) and a deletion position \(j\), and apply the edit to the current sequence to generate a new sequence. By applying insertion and deletion in equal numbers, the sequence length is always kept at \(T\) while locally modifying only the trajectory shape. This editing step is repeated until the predicted label no longer matches the true label \(y\) (attack success), or until the maximum number of iterations \(K\) is reached.

The following constraints are imposed to ensure stable editing:

  • In each iteration, we perform one insertion and one deletion so that the sequence length remains \(T\). This allows the generated adversarial examples to be used for any model without interpolation or similar adjustments.

  • The element inserted in the same iteration is not allowed to be deleted. This constraint prevents iterations without changes.

  • Endpoints are excluded from deletion to prevent excessive distortion of the trajectory.

4.3 Salience Estimation for Temporal Editing↩︎

In order to select the locations of the inserted and deleted elements, we estimate temporal salience using Grad-CAM [16]. Grad-CAM is a post-hoc explainability method that highlights regions of an input that are most influential for a model’s prediction by leveraging gradient information from intermediate feature representations. Originally proposed for images, in this work, we adapt Grad-CAM to be used for time series by estimating the element-wise salience instead of pixel-wise salience.

Let \(\mathbf{A}\in\mathbb{R}^{M\times T'}\) denote an intermediate temporal feature map, where \(M\) is the number of channels and \(T'\) is the temporal length of the feature map. We write \(A^k\in\mathbb{R}^{T'}\) for the \(k\)-th channel of \(\mathbf{A}\). Because temporal pooling layers in the CNN can change the temporal resolution, \(T'\) may differ from the input length \(T\). Let \(z_c=f_\theta(\mathbf{X})_c\) denote the pre-softmax logit for class \(c\). In Grad-CAM, channel weights are defined as: \[\label{eq:Grad-CAM-alpha} \alpha_k^{(c)} = \frac{1}{T'}\sum_{\tau=1}^{T'}\frac{\partial z_c}{\partial A_\tau^k}.\tag{4}\]

The feature-level temporal contribution is then obtained as: \[\tilde{s}_\tau^{(c)}=\sum_{k=1}^{M}\alpha_k^{(c)} A_\tau^k,\quad\tau=1,\ldots,T'.\] Unlike the original Grad-CAM formulation, AITE does not apply the ReLU non-linearity to \(\tilde{s}_\tau^{(c)}\), so that both positive and negative contributions to the original class are preserved for temporal edit selection.

Since \(\tilde{\mathbf{s}}^{(c)}\) has the temporal resolution of the intermediate feature map, we resize it to the input length before selecting edit positions. Specifically, we linearly interpolate \[\tilde{\mathbf{s}}^{(c)}=(\tilde{s}_1^{(c)},\ldots,\tilde{s}_{T'}^{(c)}),\] to length \(T\), yielding the input-level salience sequence \(\mathbf{S}^{(c)}=(s_1^{(c)},\ldots,s_T^{(c)}).\)

When \(T'=T\), this interpolation is the identity operation. The input-level salience sequence \(\mathbf{S}^{(c)}\) assigns a score to each original input time step and is used to rank temporal locations for editing.

4.3.1 Temporal Insertion with Grad-CAM↩︎

For temporal insertion, we choose the interval between two adjacent input time steps that has the lowest average salience: \[\label{eq:insertion95grad} i^\ast=\arg\min_{i\in\{1,\ldots,T-1\}}\frac{s_i^{(y)}+s_{i+1}^{(y)}}{2},\tag{5}\] where \(y\) is the original class. We insert the midpoint of the selected interval \((\mathbf{x}_i,\mathbf{x}_{i+1})\) and update the sequence according to Eq. 2 .

4.3.2 Temporal Deletion with Grad-CAM↩︎

For temporal deletion, after excluding endpoints, the deletion index is selected as: \[\label{eq:deletion95grad} j^\ast = \arg\max_{t\in\{2,\ldots,T-1\}} s_t^{(y)}.\tag{6}\]

5 Experimental Results↩︎

5.1 Datasets↩︎

To evaluate the proposed method, we used two publicly available online handwriting datasets. The first is Unipen [17], for which we used three subsets: numerical digits (Unipen 1A), uppercase letters (Unipen 1B), and lowercase letters (Unipen 1C). Each sample is represented as a sequence of 2D coordinates, and the sequence length was normalized to \(T=50\) time steps. Unipen 1A has \(11{,}650\) training and \(1{,}300\) test samples, while Unipen 1B and Unipen 1C have \(11{,}063\) training and \(1{,}235\) test samples.

The second is CASIA-OLHWDB 1.1 [18], an online handwritten Chinese character dataset with \(3{,}755\) classes from \(300\) writers. For CASIA, we remove stroke-end and character-end sentinel coordinates, concatenate the strokes into a single 2D point sequence, and normalize the coordinates to \([-1,1]\) per sample and axis. Unlike Unipen, CASIA samples are kept at their original variable lengths. The test split contains \(224{,}559\) samples.

5.2 Architecture and Settings↩︎

For the experiments, four classifiers are used.

  • 1D CNN-3: A CNN with three convolutional blocks. Each block consists of a 1D convolution, BatchNorm [39], a Rectified Linear Unit (ReLU), and max pooling. The first block uses 64 filters with kernel size 3 and stride 1, while the subsequent two blocks use 128 filters. The network is followed by two fully connected layers: one hidden layer with 512 units and dropout with probability 0.5, and one output layer.

  • 1D CNN-4: This network has the same architecture as 1D CNN-3, except that it contains four convolutional blocks instead of three.

  • BLSTM-2: To test transferability to a different network structure, we use a Bidirectional LSTM (BLSTM) [40]. Specifically, we use a two-layer BLSTM with 100 units per layer, following the recommendation of [41].

  • Transformer: To test transferability to an attention-based architecture, we use an encoder-only Transformer [3]. The model consists of a linear input projection, positional encoding, and six Transformer encoder blocks with four attention heads each. The encoder output is averaged over time and passed through a small MLP head to produce the class logits.

For CASIA-OLHWDB, we use analogous classifiers adapted to variable-length inputs and 3,755 classes: a 1D CNN with masked global average pooling in place of 1D CNN-3, together with BLSTM-2 and Transformer counterparts. For CASIA-OLHWDB, we additionally train a second 1D CNN as a black-box target (channels 64→128→128→128, kernel size 3 throughout, 80 epochs, clean test accuracy 94.8%), providing a within-CNN-family transfer target with a different filter configuration from the surrogate (64→128→256→256).

In both white-box and black-box settings, adversarial samples are generated using the gradients or salience of a 1D CNN surrogate model: 1D CNN-3 for Unipen and the analogous 1D CNN for CASIA-OLHWDB. In the white-box setting, the generated adversarial samples are used to attack the same surrogate model. In the black-box setting, they are transferred to different target models: 1D CNN-4, BLSTM-2, and Transformer for both datasets. We only consider one-shot black-box attacks, where the attacker receives no feedback from the target classifiers.

All models are trained using the Adam optimizer [42] with an initial learning rate of \(10^{-3}\) and 10,000 training iterations.

5.3 Comparison Methods↩︎

To evaluate the proposed method, we compare to seven well-established adversarial attacks: four classical attacks (FGSM, BIM, PGD, CW) and three transfer-oriented variants (MI-FGSM, NI-FGSM, 1D-TI-MI-FGSM). The hyperparameters for each attack are as follows:

  • FGSM [11]: \(\epsilon=0.1\) under the \(L_\infty\) constraint.

  • BIM [20]: \(\epsilon=0.1\), \(L_\infty\), step size \(\epsilon_{\mathrm{iter}}=0.001\), and \(I=600\) iterations.

  • PGD [12]: same as BIM.

  • CW [13]: \(L_2\) constraint, \(I=600\) iterations, learning rate \(5\times10^{-3}\), 7 binary search steps, initial constant \(5\times10^{-3}\), confidence \(0\), and early stopping.

  • MI-FGSM [21]: BIM with an accumulated momentum term over the input gradients to stabilize the update direction. Decay factor \(\mu=1.0\); remaining settings as BIM.

  • NI-FGSM [22]: MI-FGSM with the gradient evaluated at a Nesterov look-ahead point before each momentum update. Settings as MI-FGSM.

  • 1D-TI-MI-FGSM [23]: MI-FGSM in which the per-step gradient is convolved with a 1D Gaussian kernel (size \(7\), \(\sigma=3.0\)) along the time axis. Remaining settings as MI-FGSM.

Since inputs are normalized to \([-1,1]\), adversarial examples are also clipped to \([-1,1]\). For CASIA-OLHWDB, \(\epsilon=0.03\) and \(I=400\) are used to account for the larger number of classes; the CW binary search steps are reduced to \(3\).

5.4 Results↩︎

Table 1: Comparative evaluation of adversarial attacks and transferability. Accuracies (%, \(\downarrow\)) on the surrogate (white-box) and on three one-shot black-box targets. Best per column, excluding “No Attack”, is in bold; “–” indicates the target is not used.
White-Box One-Shot Black-Box
3-3 (lr)4-6 Dataset Attack 1D CNN-3 1D CNN-4 BLSTM-2 Transformer
Unipen 1A No Attack 98.9 98.8 98.8 98.2
FGSM 73.8 82.8 95.6 92.9
BIM 10.9 72.9 93.9 91.3
PGD 12.4 74.2 95.1 92.0
CW 0.69 93.9 98.2 97.1
MI-FGSM 10.9 70.8 93.2 91.0
NI-FGSM 9.1 70.5 93.7 91.0
1D-TI-MI-FGSM 67.5 71.2 80.6 83.3
AITE (Ours) 25.5 58.2 70.2 68.8
Unipen 1B No Attack 98.1 97.5 97.7 95.5
FGSM 68.7 71.5 92.6 88.3
BIM 11.2 75.4 91.1 85.8
PGD 13.7 75.8 92.5 86.2
CW 4.08 95.6 97.1 93.4
MI-FGSM 11.2 71.3 91.1 84.5
NI-FGSM 9.0 73.4 91.6 85.0
1D-TI-MI-FGSM 67.7 73.5 78.8 75.9
AITE (Ours) 15.0 61.8 60.3 65.0
Unipen 1C No Attack 97.1 97.7 96.5 94.8
FGSM 64.5 79.4 90.8 85.2
BIM 20.2 80.1 89.6 85.7
PGD 30.4 85.8 93.6 89.1
CW 5.96 96.9 96.1 93.8
MI-FGSM 7.5 74.2 88.9 84.1
NI-FGSM 6.2 75.6 88.7 85.3
1D-TI-MI-FGSM 55.6 68.9 76.7 73.4
AITE (Ours) 18.4 70.5 59.7 62.0
CASIA No Attack 95.0 94.8 96.5 96.3
FGSM 65.2 78.5 90.1 90.7
BIM 53.5 75.3 89.6 90.4
PGD 53.8 75.2 89.7 90.4
CW 0.71 74.4 90.5 93.0
MI-FGSM 54.3 75.4 89.6 90.4
NI-FGSM 53.6 75.2 89.6 90.4
1D-TI-MI-FGSM 85.3 89.9 94.2 93.5
AITE (Ours) 29.2 52.5 53.6 47.9

2.5pt

Table 1 reports recognition accuracy under adversarial attacks for both white-box and one-shot black-box settings across the three Unipen subsets and CASIA-OLHWDB. In the white-box scenario, gradient-based attacks, specifically BIM, PGD, and CW, drastically reduce classification accuracy on the surrogate, with CW achieving the lowest accuracy on every dataset (0.69–5.96% on Unipen and 0.71% on CASIA). MI-FGSM and NI-FGSM behave similarly to BIM in this setting, while 1D-TI-MI-FGSM is comparatively weaker on the surrogate because the smoothing of the input gradient sacrifices in-model optimality in exchange for transferability.

However, strong performance in the white-box setting does not necessarily carry over to the black-box scenario. Although CW is highly effective when applied directly to the surrogate, it transfers poorly to unseen targets: its impact on the 1D CNN-4, BLSTM-2, and Transformer columns is consistently the smallest among all attacks (e.g., the recognition accuracy on the Transformer target stays above 93% on every dataset). This is because gradient-based attacks rely on perturbations optimized with respect to the surrogate model’s gradients, which may not align with the decision boundaries of an unseen target, and the emphasis of CW on minimizing the perturbation magnitude further limits its transferability. MI-FGSM and NI-FGSM, which were designed for improved black-box transferability, do improve over plain BIM/PGD in some cases (e.g., Unipen 1A and 1B on 1D CNN-4), but they still leave the BLSTM-2 and Transformer targets largely intact, with accuracies above 84% on every Unipen subset and CASIA target. 1D-TI-MI-FGSM is the strongest baseline overall and even slightly outperforms AITE on Unipen 1C against 1D CNN-4 (68.9 vs.). However, it remains substantially weaker than AITE on the BLSTM-2 and Transformer targets across all datasets.

In contrast, the proposed AITE achieves the lowest recognition accuracy in almost every one-shot black-box column, including transfer to the attention-based Transformer target that was never used during attack generation. On CASIA-OLHWDB, AITE reduces the 1D CNN-4, BLSTM-2, and Transformer accuracies to 52.5%, 53.6%, and 47.9%, respectively. Notably, AITE transfers more effectively to the within-CNN-family target (CNN-4) than across architectures, consistent with the intuition that CNN-to-CNN perturbations share more decision-boundary structure. The strongest additive baseline (1D-TI-MI-FGSM) only reduces the three black-box targets to 90.0%, 94.2%, and 93.5%, respectively. Because AITE selects insertion and deletion positions from salience rather than from raw input gradients, the resulting temporal edits target class-discriminative structure that tends to be shared across architectures, including CNN-to-BLSTM and CNN-to-Transformer transfers.

5.5 Visual Similarity↩︎

Attack success is usually quantified by the change in the model’s prediction. However, for handwriting recognition, misclassification alone does not characterize the practical relevance of an attack: handwritten inputs are interpreted by humans, and visibly distorted adversarial samples are unlikely to represent plausible handwriting. We therefore also assess the visual similarity between original and adversarial samples.

Table 2: Visual similarity between adversarial and original samples. The best value for each metric and dataset is in bold.
Dataset Metric FGSM BIM PGD CW MI-FGSM NI-FGSM 1D-TI-MI-FGSM AITE
Unipen 1A \(L_2\) \(\downarrow\) 22.0 20.9 21.0 13.8 21.8 21.4 22.8 14.3
SSIM \(\uparrow\) 0.550 0.577 0.574 0.760 0.554 0.563 0.518 0.746
Unipen 1B \(L_2\) \(\downarrow\) 23.5 22.4 22.5 15.0 23.2 22.9 24.3 11.7
SSIM \(\uparrow\) 0.497 0.525 0.524 0.725 0.502 0.512 0.466 0.808
Unipen 1C \(L_2\) \(\downarrow\) 22.1 19.2 19.4 13.1 21.7 21.4 22.7 11.7
SSIM \(\uparrow\) 0.551 0.627 0.624 0.775 0.558 0.567 0.527 0.809
CASIA \(L_2\) \(\downarrow\) 17.8 17.6 17.6 11.1 17.6 17.6 18.3 15.9
SSIM \(\uparrow\) 0.585 0.593 0.594 0.812 0.592 0.593 0.564 0.618

3pt

To this end, we compare the visual similarity of the rendered characters. Table 2 reports quantitative results across all attacks. In this table, the online handwritten digits and characters are rendered into \(64\times64\) grayscale images with black strokes and no points. For the visual similarity measures, we use the pixel-space \(L_2\) distance and the Structural Similarity Index Measure (SSIM) between the original samples and the adversarial samples. \(L_2\) measures the strict pixel-wise differences between the images, whereas SSIM emphasizes structural consistency, which better reflects human visual perception.

FGSM, BIM, PGD, MI-FGSM, NI-FGSM, and 1D-TI-MI-FGSM consistently produce large \(L_2\) distortions and low SSIM scores across all datasets. As shown in Fig. 3, this reflects the large amount of jittering in the generated strokes of the characters. In the rendered examples, these attacks introduce visible jitter and local stroke irregularities. The transfer-oriented variants (MI-FGSM, NI-FGSM, and 1D-TI-MI-FGSM) do not qualitatively change this behavior: they share the additive \(L_\infty\) formulation of BIM/PGD, so the rendered trajectories exhibit similar jittering and remain easily detectable. In contrast, the perturbations in CW are minimal, but as discussed above, this adversely affects black-box transferability because the minimal perturbations only exploit surrogate-specific decision boundaries.

Figure 3: Qualitative comparison of adversarial handwriting trajectories on Unipen (1A/1B/1C) for representative attacks. Rows show the original sample and adversarial samples generated by PGD, CW, and the proposed AITE. Ground-truth labels (GT) and model predictions (Pred) are shown below each example.

In contrast, AITE preserves the overall structure of the handwriting while still being effective under black-box transfer. Although online handwriting is represented as a time series, temporal-domain edits such as point insertion or deletion alter the temporal structure of the sequence while leaving the rendered spatial trace largely unchanged, and are typically less perceptible than the spatial jitter introduced by additive perturbations.

5.6 Gradient Versus Salience for Temporal Edit Selection↩︎

As a baseline ablation, we replace the Grad-CAM salience with gradient-based importance: \(s^{grad}_t = \lVert\nabla_{\mathbf{x}_t}\mathcal{L}(f_\theta(\mathbf{X}), y)\rVert_2\), where larger values indicate higher sensitivity of the loss to time step \(t\).

Table 3: Comparative evaluation of AITE selection strategies and transferability. For the white-box experiment, the adversarial samples are generated and tested on 1D CNN-3. For the black-box experiments, the adversarial examples are generated from 1D CNN-3 and tested on 1D CNN-4 and BLSTM-2 models. The best of each dataset is in bold.
Visual White-Box One-Shot Black-Box
Similarity 1D CNN-3 1D CNN-4 BLSTM-2
Dataset Selection \(L_2\) \(\downarrow\) SSIM \(\uparrow\) Acc (%) \(\downarrow\) Acc (%) \(\downarrow\) Acc (%) \(\downarrow\)
Unipen 1A Gradient 9.92 0.849 64.6 76.8 88.8
Salience 14.3 0.746 25.5 58.2 70.2
Unipen 1B Gradient 9.81 0.846 50.1 64.8 72.8
Salience 11.7 0.808 15.0 61.8 60.3
Unipen 1C Gradient 9.46 0.855 53.9 82.1 81.6
Salience 11.7 0.809 18.4 70.5 59.7

A comparison of the results is shown in Table 3. In the results, the gradient-based selection creates more similar adversarial samples but has a smaller effect on the accuracy. The reason for this is because the edited time steps tend to be adjacent to each other in salient regions. Conversely, time steps selected by gradient magnitudes tend to be distributed more equally over the character, allowing for less disruptive edits. However, both the white-box and black-box attacks with gradient-based selection are not as effective as salience-based selection. This suggests salience is more suitable than gradients for temporal editing.

6 Examination of the Temporal Edits↩︎

6.1 Single-Iteration Adversarial Samples↩︎

An interesting observation from our experiments is that some handwriting samples can be misclassified after only a single iteration of temporal editing. In other words, the class of a character is able to be changed with the removal of a single time step and the addition of a single time step. As demonstrated in Fig. 4, these cases are nearly identical to the original samples. These cases are of interest because they show samples whose correct classification relies on a single time step.

Figure 4: Example of adversarial samples that only required a single iteration of AITE to change the class. The temporal insertion and deletion are indicated with arrows.

6.2 Class Sensitivity to Temporal Edits↩︎

a
b
c

Figure 5: Comparison of the confusion matrices on Unipen 1A under different attacks. Darker cells indicate larger counts.. a — AITE (Ours), b — PGD, c — CW

Fig. 5 compares the confusion matrices on Unipen 1A under AITE, PGD, and CW. PGD and CW, being gradient-based, produce similar confusion patterns, whereas AITE differs substantially: for instance, “2”\(\to\)“4” under AITE versus “2”\(\to\)“7” under the gradient methods, suggesting that “2”s are temporally closer to “4”s but spatially closer to “7”s. “9”s also tend to transition to “1”s or “7”s under AITE, while a few classes behave similarly across methods (e.g., “0”\(\to\)“8” and “8”\(\to\)“5”).

The matrices also reveal class-wise susceptibility: “1” and “5” are the hardest digits to attack with AITE because their single-stroke shapes leave little room for class change without spatial distortion, while the more complex “6”, “8”, and “9” are the easiest. This is consistent with the stronger attack effectiveness on the more complex Unipen 1B and 1C subsets in Table 1.

7 Conclusion↩︎

This paper examined adversarial attacks on online handwriting recognition from a temporal perspective. By formulating adversarial example generation as a sequence editing problem, the proposed approach modifies handwriting trajectories through point insertion and deletion guided by temporal salience, rather than through additive spatial perturbations. Experimental evaluations under both white-box and one-shot black-box settings demonstrated that temporal editing produces adversarial examples that preserve the structure and smoothness of natural handwritten characters while remaining effective across different model architectures. Future work will extend this preliminary study to word- and sentence-level online handwriting recognition. Human evaluation should also be conducted to assess the perceived naturalness of adversarial handwriting, and defenses against temporal editing attacks should be investigated.

Acknowledgements↩︎

This research was partially funded by JSPS Grant Number 25K22845 and JST CRONOS-JPMJCS24K4.

References↩︎

[1]
D. E. Rumelhart, G. E. Hinton, and R. J. Williams, Learning internal representations by error propagation,” in Neurocomput.: Found. Res., J. A. Anderson and E. Rosenfeld, Eds. MIT Press, 1988, pp. 673–695.
[2]
K. J. Lang, A. H. Waibel, and G. E. Hinton, “A time-delay neural network architecture for isolated word recognition,” Neural Netw., vol. 3, no. 1, pp. 23–43, 1990.
[3]
A. Vaswani et al., “Attention is all you need,” in Adv. Neural inf. Process. Syst. (NeurIPS), 2017, vol. 30.
[4]
A. Graves, M. Liwicki, S. Fernández, R. Bertolami, H. Bunke, and J. Schmidhuber, “A novel connectionist system for unconstrained handwriting recognition,” IEEE Trans. Pattern Anal. Mach. Intell. (TPAMI), vol. 31, no. 5, pp. 855–868, 2009.
[5]
B. K. Iwana and S. Uchida, “Time series classification using local distance-based features in multi-modal fusion networks,” Pattern Recognit., vol. 97, p. 107024, 2020.
[6]
T. Ghosh, S. Sen, S. M. Obaidullah, K. Santosh, K. Roy, and U. Pal, “Advances in online handwritten recognition in the last decades,” Comput. Sci. Rev., vol. 46, 2022.
[7]
C. Liu et al., “Col-OLHTR: A novel framework for multimodal online handwritten text recognition,” in IEEE int. Conf. Acoust. Speech signal process., 2025, pp. 1–5.
[8]
X. Qu and Z. Wu, “End-to-end multi-scale attention convolutional recurrent network for online handwritten chinese text recognition,” Expert Syst. Appl., p. 127626, 2025.
[9]
H. Xu et al., “Adversarial attacks and defenses in images, graphs and text: A review,” Int. J. Autom. Comput., vol. 17, no. 2, pp. 151–178, 2020.
[10]
J. C. Costa, T. Roxo, H. Proença, and P. R. M. Inacio, “How deep learning sees the world: A survey on adversarial attacks & defenses,” IEEE Access, vol. 12, pp. 61113–61136, 2024.
[11]
I. J. Goodfellow, J. Shlens, and C. Szegedy, “Explaining and harnessing adversarial examples,” in Int. Conf. Learn. Represent. (ICLR), 2015.
[12]
A. Madry, A. Makelov, L. Schmidt, D. Tsipras, and A. Vladu, “Towards deep learning models resistant to adversarial attacks,” in Int. Conf. Learn. Represent. (ICLR), 2018.
[13]
N. Carlini and D. Wagner, “Towards evaluating the robustness of neural networks,” in SP, 2017, pp. 39–57.
[14]
F. Karim, S. Majumdar, and H. Darabi, “Adversarial attacks on time series,” IEEE Trans. Pattern Anal. Mach. Intell. (TPAMI), vol. 43, no. 10, pp. 3309–3320, 2021.
[15]
H. I. Fawaz, G. Forestier, J. Weber, L. Idoumghar, and P.-A. Muller, “Adversarial attacks on deep neural networks for time series classification,” in Int. Joint conf. Neural netw. (IJCNN), 2019.
[16]
R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh, and D. Batra, “Grad-CAM: Visual explanations from deep networks via gradient-based localization,” in Int. Conf. Comput. Vis. (ICCV), 2017, pp. 618–626.
[17]
I. M. Guyon, L. Schomaker, R. Plamondon, M. Liberman, and S. Janet, “UNIPEN project of on-line data exchange and recognizer benchmarks,” in Int. Conf. Pattern recognit. (ICPR), 1994, vol. 2, pp. 29–33.
[18]
C.-L. Liu, F. Yin, D.-H. Wang, and Q.-F. Wang, CASIA online and offline Chinese handwriting databases,” in Int. Conf. Doc. Anal. Recognit. (ICDAR), 2011.
[19]
C. Szegedy et al., “Intriguing properties of neural networks,” arXiv preprint arXiv:1312.6199, 2013.
[20]
A. Kurakin, I. Goodfellow, and S. Bengio, “Adversarial examples in the physical world,” in Workshop int. Conf. Learn. Represent. (ICLR), 2017.
[21]
Y. Dong et al., “Boosting adversarial attacks with momentum,” in IEEE/CVF conf. Comput. Vis. Pattern recognit. (CVPR), 2018.
[22]
J. Lin, C. Song, K. He, L. Wang, and J. E. Hopcroft, “Nesterov accelerated gradient and scale invariance for adversarial attacks,” in Int. Conf. Learn. Represent. (ICLR), 2020.
[23]
Y. Dong, T. Pang, H. Su, and J. Zhu, “Evading defenses to transferable adversarial examples by translation-invariant attacks,” in IEEE/CVF conf. Comput. Vis. Pattern recognit. (CVPR), 2019.
[24]
N. Carlini et al., “Hidden voice commands,” in USENIX, 2016.
[25]
P. Rathore, A. Basak, S. H. Nistala, and V. Runkana, “Untargeted, targeted and universal adversarial attacks and defenses on time series,” in Int. Joint conf. Neural netw. (IJCNN), 2020, pp. 1–8.
[26]
W. Yang, J. Yuan, X. Wang, and P. Zhao, “TSadv: Black-box adversarial attack on time series with local perturbations,” Eng. Appl. Artif. Intell., vol. 114, p. 105218, 2022.
[27]
D. Ding, M. Zhang, F. Feng, Y. Huang, E. Jiang, and M. Yang, “Black-box adversarial attack on time series classification,” in AAAI conf. Artif. Intell. (AAAI), 2023, vol. 37, pp. 7358–7368.
[28]
M. Zheng, X. Yan, Z. Zhu, H. Chen, and B. Wu, “Blackboxbench: A comprehensive benchmark of black-box adversarial attacks,” IEEE Trans. Pattern Anal. Mach. Intell. (TPAMI), vol. 47, no. 9, pp. 7867--7885, 2025.
[29]
G. Pialla et al., “Smooth perturbations for time series adversarial attacks,” in Pac.-asia conf. Knowl. Discovery data min. (PAKDD), 2022, pp. 485–496.
[30]
L. G. Hafemann, R. Sabourin, and L. S. Oliveira, “Characterizing and evaluating adversarial examples for offline handwritten signature verification,” IEEE Trans. Inf. Forensics Secur., vol. 14, no. 8, pp. 2153–2166, 2019.
[31]
H. Li, H. Li, H. Zhang, and W. Yuan, “Black-box attack against handwritten signature verification with region-restricted adversarial perturbations,” Pattern Recognit., vol. 111, p. 107689, 2021.
[32]
Z. Guo, W. Li, Y. Qian, O. Arandjelovic, and L. Fang, “A white-box false positive adversarial attack method on contrastive loss based offline handwritten signature verification models,” in Int. Conf. Artif. Intell. Stat. (AISTATS), 2024, pp. 901–909.
[33]
G. Jiang, Z. Qian, Q.-F. Wang, Y. Wei, and K. Huang, “Adversarial attack and defence on handwritten chinese character recognition,” in J. Phys. Conf. ser., 2022, vol. 2278, p. 012023.
[34]
L. Shi, H. Wu, X. Ding, H. Xu, and S. Pan, “A generative adversarial network-based client-level handwriting forgery attack in federated learning scenario,” Expert Sys., vol. 42, no. 2, p. e13676, 2025.
[35]
T. B. Huynh, Q. M. Phan, V.-H. Duong, and N. H. Luong, “Adversarial robustness evaluation of a vietnamese handwriting OCR system,” in Int. Conf. Multimedia anal. Pattern recognit. (MAPR), 2025, pp. 1–6.
[36]
Y. Yamashita and B. K. Iwana, “Test time augmentation as a defense against adversarial attacks on online handwriting,” in Int. Conf. Doc. Anal. Recognit. (ICDAR), 2024, pp. 156–172.
[37]
D. P. Lopresti and J. D. Raim, “The effectiveness of generative attacks on an online handwriting biometric,” in Int. Conf. Audio video-based biometric person authent. (AVBPA), 2005, pp. 1090–1099.
[38]
N. Papernot, P. McDaniel, and I. Goodfellow, “Transferability in machine learning: From phenomena to black-box attacks using adversarial samples,” arXiv preprint arXiv:1605.07277, 2016.
[39]
S. Ioffe and C. Szegedy, “Batch normalization: Accelerating deep network training by reducing internal covariate shift,” in Int. Conf. Mach. learn., 2015, pp. 448–456.
[40]
M. Schuster and K. K. Paliwal, “Bidirectional recurrent neural networks,” IEEE Trans. Signal Process., vol. 45, no. 11, pp. 2673–2681, 1997.
[41]
N. Reimers and I. Gurevych, “Optimal hyperparameters for deep lstm-networks for sequence labeling tasks,” arXiv preprint arXiv:1707.06799, 2017.
[42]
D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” in Int. Conf. Learn. Represent. (ICLR), 2015.

  1. https://github.com/yataro0117/AITE↩︎