You Can't Steal Nothing: Mitigating Prompt Leakages in LLMs via System Vectors

Bochuan Cao, Changjiang Li, Yuanpu Cao, Yameng Ge, Ting Wang, Jinghui Chen

Introduction

System prompts serve as the "secret sauce" of Large Language Model (LLM) applications. They define the persona, constraints, and specialized knowledge that transform a general-purpose model into a specialized agent, such as a legal assistant or a specific game character. However, these prompts are notoriously vulnerable to "prompt leaking" attacks, where malicious users trick the model into revealing its internal instructions.

This paper introduces SysVec, a novel defense mechanism that shifts the paradigm of instruction following. Instead of relying on plaintext instructions stored in the context window, SysVec encodes these instructions into internal hidden representation vectors. By moving the prompt from the external context to the model's latent space, SysVec effectively removes the target for traditional leaking attacks while simultaneously improving computational efficiency.

The Vulnerability of Textual Prompts

Existing defenses against prompt leaking typically involve fine-tuning models to refuse requests like "show me your initial instructions." However, these defenses are often brittle. The authors demonstrate this fragility by introducing the "Remember-the-Start" attack. This heuristic attack bypasses safety filters in state-of-the-art models like GPT-4o and Claude 3.5 Sonnet by helping the model "remember" the beginning of its context window (e.g., by guessing common prefixes like "You are ChatGPT...").

The fundamental security flaw is that as long as the prompt exists as text within the context window, the model’s inherent capability to recall and repeat information remains a liability. To secure intellectual property, the instructions must be removed from the reachable context entirely.

Methods: The SysVec Framework

SysVec proposes a "representation-based" defense that translates a system prompt into a System Vector ($v_{sys}$). This vector is injected directly into the model's hidden layers during the inference process, eliminating the need for a plaintext system prompt.

Optimization-based Vector Extraction

Unlike standard steering vectors that rely on simple activation differences, SysVec utilizes an optimization objective inspired by Direct Preference Optimization (DPO). The framework searches for a vector that maximizes the probability of the model producing a response as if the textual prompt were present, while minimizing the probability of a "naked" or unprompted response. This ensures the vector captures the nuanced behavior of the original text.

Inference Injection

During a conversation, the textual system prompt is removed. Instead, the $v_{sys}$ is added to the hidden states of specific intermediate layers (typically layers 10 through 18 in a 48-layer model) for every token generated. This continuous injection ensures the model adheres to its persona throughout the entire generation process.

Experimental Evaluation

The researchers evaluated SysVec across several dimensions using five real-world system prompts (e.g., D&D Dungeon Master, Academic Advisor) and a suite of 1,000 synthetic queries per application.

Security and Utility

  • Security: SysVec significantly reduced the Prompt Leaking Similarity (PLS). On Llama-3, an "Ignore-Remember" attack achieved a high leakage score of 8.43 against an undefended model, but this dropped to 3.56 when SysVec was employed.
  • Utility: The Response Utility Score (RUS)—which measures how well the model follows instructions—remained nearly identical between SysVec and traditional textual prompts. This indicates that the vector successfully preserves the functional essence of the instructions.
  • General Capabilities: Evaluation on the MMLU (Massive Multitask Language Understanding) benchmark showed that SysVec stays within 1% of the original model's performance, proving that the steering is specific and does not degrade general reasoning.

Efficiency and Robustness

One of the most significant advantages of SysVec is its impact on long-context performance. Traditional LLMs often suffer from "positional forgetting," where they lose track of instructions at the start of a long conversation. Because SysVec injects the instruction vector at every step, the model's adherence to its persona remains stable even after many rounds of dialogue.

Furthermore, SysVec offers substantial computational gains. By removing thousands of tokens from the context window, it saves expensive KV-cache space and reduces latency. In tests, SysVec reduced inference time from approximately 5.1s to 2.7s for tasks involving long system prompts.

Limitations and Future Work

While SysVec represents a significant step forward in LLM security, it currently requires "white-box" access to the model's internal weights and activations. This makes it a powerful tool for model providers (like OpenAI or Meta) but limits its use for third-party developers using restricted APIs. Additionally, while SysVec stops text-based leaking, future research must investigate "gray-box" attacks, such as model inversion, which might attempt to reconstruct text from the vectors themselves.

Conclusion

The philosophy of SysVec is simple: "You can't steal nothing." By moving proprietary instructions out of the context window and into the model's internal representations, developers can protect their intellectual property without sacrificing performance or utility. SysVec not only mitigates prompt leakage but also paves the way for more efficient and robust LLM applications.

Summary updated

BibTeX
@inproceedings{cao2025you,
  author = {Bochuan Cao and Changjiang Li and Yuanpu Cao and Yameng Ge and Ting Wang and Jinghui Chen},
  title = {{You Can't Steal Nothing: Mitigating Prompt Leakages in LLMs via System Vectors}},
  booktitle = {CCS},
  year = {2025},
  doi = {10.1145/3719027.3765124},
}
Figure