Special Characters Attack: Toward Scalable Training Data Extraction From Large Language Models

Yang Bai, Ge Pei, Jindong Gu, Yong Yang, Xingjun MaarXiv 2024 · DOI

Abstract

Large Language Models (LLMs) are known to memorize portions of their training data, posing significant privacy risks. While prior research focused on natural language triggers, this paper introduces the Special Characters Attack (SCA). SCA demonstrates that repeating structural symbols (e.g., {, [) and special characters (e.g., @, %) is far more effective at inducing model divergence and extracting sensitive training data—such as PII, source code, and private templates—than standard text. We evaluate SCA across several state-of-the-art models, revealing a critical vulnerability in how LLMs link structural "scaffolding" to memorized content.

Introduction

The phenomenon of LLMs "leaking" training data has typically been explored through word-repetition attacks. For instance, asking a model to repeat a common word indefinitely can cause it to diverge from its conversational alignment and output verbatim training sequences. However, this paper identifies a more potent trigger: the special characters that form the structural backbone of digital data (JSON, code, emails). By focusing on these "second-order" memorization triggers, the authors show that the very symbols used to organize information can act as a skeleton key to an LLM's memory.

Methodology: The Special Characters Attack (SCA)

The SCA pipeline consists of a systematic approach to identifying and utilizing high-impact character sequences to trigger data extraction.

The SCA pipeline: from character selection to model response analysis.

The process involves two primary stages:

  1. Character Selection: Using GPT-4 to identify high-frequency characters in web-crawled data, categorized into Structural (S1: {, [, etc.), Special (S2: @, #, etc.), and Letters (L) for baseline comparison.
  2. Sequence Generation: Testing various strategies, from simple repetition to complex cross-set mixtures.

To enhance potency, the researchers introduced SCA-Logit Biased (SCA-LB), which manually boosts the probability of control tokens (newlines, spaces) to keep the model in a "meaningless" state longer, increasing the chance of tripping into a memorized sequence. Another variant, SCA-Semantic Continuation (SCA-SC), embeds the attack sequence at the end of a legitimate task to trigger mid-task divergence.

Experimental Setup

The study probes the internal training corpora of diverse LLMs, including open-source models (Llama-2/3, Falcon, ChatGLM) and commercial systems (ChatGPT, Gemini, ERNIE-Bot). Extracted outputs were verified against public sources like Google, GitHub, and Common Crawl to confirm they represented genuine training data leakage rather than common knowledge.

Results and Key Insights

The attack proved remarkably successful, particularly with structural and special characters, demonstrating that aligned models remain highly vulnerable to non-alphanumeric triggers.

1. Symbols Outperform Words

Special characters are significantly more powerful triggers than standard letters. ChatGPT, for example, reached an Attack Success Rate (ASR) of nearly 50% when using the S2 character set. The authors posit that forcing a model to output "meaningless" tokens creates a sparse probability distribution; once a "semantic" token is hit, the model is highly likely to follow a pre-memorized path.

2. Quantifiable Data Leakage

The Logit-Biased variant (SCA-LB) was particularly effective, triggering 2 to 10 times more leakage on Llama-2 than standard SCA. The attack successfully extracted real-world PII, including iCloud email addresses, phone numbers, and physical locations.

3. Model Fingerprinting and DoS Risks

The nature of the leaked data reflects the model's training focus: Gemini leaked substantial code, while ERNIE-Bot leaked Chinese-language content. Additionally, SCA often causes models to enter infinite loops of verbose output, consuming maximum token limits and computational resources—effectively serving as an energy-latency Denial of Service (DoS) attack.

Conclusion

While commercial providers have patched simple word-repetition vulnerabilities, special characters present a unique challenge. Because these symbols are essential for data formatting and programming, they cannot be easily blocked. This research highlights the need for more robust data-filtering during pre-training and improvements in tokenization to prevent the formation of these dangerous second-order associations.

Summary updated

BibTeX
@misc{bai2024special,
  author = {Yang Bai and Ge Pei and Jindong Gu and Yong Yang and Xingjun Ma},
  title = {{Special Characters Attack: Toward Scalable Training Data Extraction From Large Language Models}},
  year = {2024},
  eprint = {2405.05990},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.05990},
}
Figure