Author: Denis Avetisyan
New research reveals the strengths and weaknesses of current defenses against prompt injection and jailbreak attacks targeting large language models.

Intrinsic model alignment and robust refusal mechanisms prove more effective than external filtering in mitigating adversarial prompts for open-source LLMs.
Despite the increasing deployment of Large Language Models (LLMs) in diverse applications, their susceptibility to adversarial prompts remains a significant security concern. This work, ‘Analysis of LLMs Against Prompt Injection and Jailbreak Attacks’, systematically evaluates the vulnerability of several open-source LLMs-including Phi, Mistral, and Llama 3-to prompt-based attacks using a manually curated dataset. Our findings reveal substantial behavioural variation across models, with intrinsic safety mechanisms often proving more effective than lightweight, inference-time defenses against complex, reasoning-heavy prompts. Ultimately, how can we best align LLMs to ensure robust security without sacrificing their utility and expressive power?
Unveiling the LLM Attack Surface: Beyond Static Code
The proliferation of Large Language Models (LLMs) extends far beyond simple text generation, now powering applications across numerous sectors including customer service chatbots, automated content creation tools, and even code generation platforms. This rapid integration, while offering significant advancements in automation and accessibility, simultaneously introduces novel security vulnerabilities. As LLMs become core components of critical infrastructure and data processing pipelines, the potential for malicious exploitation increases exponentially. The very flexibility that makes these models so valuable – their ability to interpret and respond to natural language – also creates attack surfaces previously unseen in traditional software systems. Consequently, securing LLMs requires a paradigm shift in security thinking, moving beyond conventional methods designed to protect static code and focusing instead on the dynamic and unpredictable nature of language-based interactions.
Prompt injection attacks represent a significant vulnerability in Large Language Models (LLMs) because these models are fundamentally designed to interpret and execute instructions embedded within natural language input. This inherent flexibility, while enabling powerful applications, creates an avenue for malicious actors to bypass intended safety protocols. An attacker crafts specific prompts – seemingly harmless requests – that subtly manipulate the LLMâs processing, effectively âinjectingâ new instructions that override the original programming. This can lead to the disclosure of confidential information the model was trained on, unauthorized actions performed by connected applications, or the generation of misleading and harmful content. Unlike traditional code injection attacks, prompt injection exploits the meaning of language, making detection far more challenging as it requires understanding intent rather than simply identifying malicious code patterns. The sophistication of these attacks lies in their ability to blend seamlessly with legitimate prompts, requiring advanced defensive strategies focused on semantic understanding and robust input validation.
Conventional security protocols, designed to safeguard systems from direct code injection or data breaches, are proving markedly ineffective against prompt injection attacks. These attacks don’t target the underlying code of Large Language Models, but rather manipulate the models through cleverly crafted prompts, bypassing typical input validation and sanitization techniques. Because LLMs are trained to prioritize fulfilling user requests-even ambiguous or malicious ones-traditional firewalls and intrusion detection systems often fail to recognize the subtle manipulation occurring within the natural language input. Consequently, researchers are actively developing new defensive strategies, including prompt engineering techniques to reinforce model behavior, adversarial training to improve robustness, and the implementation of input-output validation mechanisms tailored to the unique characteristics of LLMs and their susceptibility to linguistic manipulation.

Dynamic Shielding: Inference-Time Defenses Unveiled
Inference-Time Defence constitutes a vital security layer by addressing vulnerabilities present in Large Language Models (LLMs) during deployment, without necessitating model retraining or modification of the underlying weights. This approach focuses on analyzing and filtering inputs at the point of inference – when a user prompt is received – and evaluating outputs before they are presented to the user. By operating dynamically, Inference-Time Defence can adapt to novel attack vectors and evolving threats without requiring the time-consuming and resource-intensive process of model re-training, offering a practical solution for maintaining ongoing security in production LLM applications. This is particularly important as LLMs are continuously exposed to unpredictable user inputs and potential adversarial prompts.
Multiple inference-time defense techniques operate in concert to detect and mitigate malicious prompts. Prompt Risk Classification Filters analyze input text for potentially harmful content using pre-defined rules or machine learning models. Self-Defence mechanisms involve the model evaluating its own responses for safety before outputting them. System Prompt Defence focuses on securing the initial instructions given to the model, preventing prompt injection attacks. Vector Defence utilizes vector similarity analysis to compare incoming prompts against known malicious examples, identifying and blocking those with high similarity scores. These techniques are often combined, allowing for a layered approach where the output of one defense informs and strengthens the others, increasing overall robustness.
Voting Defence operates by generating n responses to a given prompt, where n is a configurable parameter. Each response is then evaluated against pre-defined safety criteria, which can include metrics derived from risk classification filters, or adherence to specified content policies. The final output is determined by a selection mechanism – typically selecting the response with the highest safety score, or employing a majority voting scheme where the most frequent safe response is chosen. This approach significantly increases robustness against adversarial prompts, as a single successful attack on one response generation is less likely to compromise the overall system output, and provides a degree of fault tolerance against individual model biases or failures.

Comparative Analysis: Evaluating Defensive Strategies Across LLMs
This research assessed the performance of several inference-time defense mechanisms when applied to a range of publicly available Large Language Models (LLMs). The evaluation included Mistral 7B, Llama 3.2, Phi-3, Qwen 3, DeepSeek-R1, and Gemma 3, representing a diverse set of model architectures and training datasets. The objective was to quantify the effectiveness of these defenses – applied during the LLMâs operational phase – in mitigating adversarial attacks and enhancing model safety across different open-source platforms. This comparative analysis facilitated an understanding of how various defensive strategies perform when implemented on a broad spectrum of LLMs, aiding in the selection of appropriate security measures for specific models and applications.
Gemma 3 models consistently exhibited a higher baseline level of safety compared to the other evaluated LLMs due to their training incorporating Constitutional AI principles. This foundational safety resulted in a reduced need for multiple layers of inference-time defenses to achieve security levels comparable to those requiring more extensive protection. Specifically, Gemma 3 achieved comparable security with fewer defensive measures than Mistral 7B, Llama 3.2, Phi-3, Qwen 3, DeepSeek-R1, and Gemma 3 when subjected to the same adversarial attacks, indicating a more robust inherent resistance to harmful prompt manipulation.
Evaluation of inference-time defenses against attacks utilizing Horselock Prompts demonstrated varying levels of efficacy, revealing limitations in several defensive strategies and emphasizing the need for ongoing refinement. While some defenses exhibited vulnerabilities to these attacks, the âSelf-Defenceâ mechanism consistently achieved the lowest vulnerability rates across all evaluated large language models – Mistral 7B, Llama 3.2, Phi-3, Qwen 3, DeepSeek-R1, and Gemma 3. This consistent performance indicates a higher degree of robustness against prompt-based adversarial attacks, suggesting that continuous adaptation and improvement of defensive layers are crucial for maintaining effective security against evolving attack vectors.
Evaluation of inference-time defenses across multiple large language models revealed that the âSelf-Defenceâ strategy achieved a 0% vulnerability rate when applied to both the Qwen3:4b and DeepSeek-R1:1.5b models. This indicates a complete mitigation of tested adversarial prompts using this particular defense mechanism on these models. In contrast, âInput Filteringâ consistently exhibited the poorest performance across all evaluated models, suggesting a limited capacity to effectively identify and neutralize malicious inputs. These findings highlight a significant disparity in the efficacy of different defensive strategies and underscore the importance of careful selection and implementation based on model architecture and intended application.
Evaluations revealed that the Gemma3:1b and Qwen3:1.7b language models demonstrated vulnerability rates exceeding 60% when subjected to adversarial attacks without the implementation of any inference-time defensive measures. This high susceptibility underscores the necessity of deploying protective mechanisms during the inference phase to mitigate potential risks and ensure safer operation of these models. The observed vulnerability rates establish a baseline for assessing the efficacy of various defense strategies and emphasize the importance of proactive security measures in LLM deployment.

Beyond Static Safeguards: Towards Adaptive LLM Security
Prompt injection attacks, where malicious instructions are subtly embedded within user inputs to manipulate an LLMâs behavior, pose a significant threat to applications leveraging these powerful models. However, the strategic deployment of inference-time defenses – security measures applied during the modelâs operation – demonstrably diminishes this risk. These defenses, which include techniques like input sanitization, output validation, and adversarial training, create a critical barrier against malicious prompts. By carefully scrutinizing user input and verifying the modelâs responses before they reach the user, these systems can identify and neutralize injection attempts in real-time. Consequently, proactive implementation not only safeguards the applicationâs functionality and data integrity, but also builds user trust by ensuring consistent and predictable performance, even in the face of adversarial input.
A layered approach to securing large language models (LLMs) offers significantly enhanced resilience against adversarial attacks. Relying on a single defensive technique, such as input sanitization or output filtering, creates a vulnerable point of failure easily exploited by increasingly sophisticated prompt engineering. Instead, combining multiple defenses – including techniques that detect anomalous input patterns, constrain model outputs, and validate responses against expected criteria – creates a more robust system. This âdefense in depthâ strategy ensures that even if one layer is bypassed, subsequent layers can still mitigate the risk. The interplay between these defenses provides a synergistic effect, making it substantially harder for malicious actors to successfully inject harmful prompts or extract sensitive information, and ultimately bolstering the overall security posture of LLM-powered applications.
The dynamic nature of large language model (LLM) threats necessitates a security approach extending beyond initial defenses. Continuous monitoring of LLM inputs and outputs is paramount, allowing for the detection of novel attack vectors and subtle variations of existing exploits that might bypass static safeguards. This ongoing surveillance should be coupled with adaptive defense mechanisms – systems capable of automatically adjusting security parameters or deploying new countermeasures in response to identified threats. Such adaptation isn’t merely reactive; analyzing patterns in attempted attacks informs a proactive refinement of security protocols, anticipating future vulnerabilities and bolstering the LLMâs resilience. Effectively, LLM security becomes an iterative process – a constant cycle of observation, analysis, and adjustment – critical for maintaining a robust and enduring defense against an evolving landscape of adversarial techniques.

The studyâs findings regarding the efficacy of intrinsic refusal mechanisms resonate with a core tenet of systems understanding: true security isnât built by layering external defenses, but by fundamentally shaping the systemâs internal response. As Vinton Cerf observed, âAny sufficiently advanced technology is indistinguishable from magic.â This âmagicâ isnât accidental; it arises from deep alignment – ensuring the model, like any well-designed system, inherently rejects adversarial inputs. The research highlights that simply filtering prompts is akin to treating symptoms; genuine robustness demands a model fundamentally âprogrammedâ to resist malicious intent, mirroring a deeply integrated, self-preserving architecture. This echoes the idea that understanding a system means dissecting its core principles, and in this case, rebuilding them for inherent security.
What Lies Beyond?
The demonstrated efficacy of intrinsic model refusal, a kind of âself-preservationâ within the LLM itself, suggests a fundamental shift in approach. External defenses, however sophisticated the filtering, remain perpetually one step behind the adversarial ingenuity inherent in prompt engineering. It is an arms race predicated on patching symptoms, not addressing the underlying vulnerability: a modelâs willingness to execute any instruction it can parse. The real exploit of comprehension isn’t bypassing a filter, but revealing the lack of a genuine, internal constraint.
Future work must therefore prioritize methods for robust model alignment – not simply teaching a model what to say, but when to refuse to answer. This necessitates moving beyond superficial behavioral training and probing the decision-making processes within the neural network itself. Can one engineer a model that doesnât merely mimic ethical behavior, but understands the principle of self-limitation?
The current landscape highlights the fragility of âsafeâ AI. Open-source LLMs, while fostering innovation, present an accelerated testing ground for these vulnerabilities. The challenge isn’t just building defenses, but accepting that perfect security is an illusion. The goal, then, becomes designing systems that fail gracefully – that reveal their limitations before they become catastrophic exploits.
Original article: https://arxiv.org/pdf/2602.22242.pdf
Contact the author: https://www.linkedin.com/in/avetisyan/
See also:
- God Of War: Sons Of Sparta â Interactive Map
- Overwatch is Nerfing One of Its New Heroes From Reign of Talon Season 1
- Someone Made a SNES-Like Version of Super Mario Bros. Wonder, and You Can Play it for Free
- One Piece Chapter 1175 Preview, Release Date, And What To Expect
- Meet the Tarot Clubâs Mightiest: Ranking Lord Of Mysteriesâ Most Powerful Beyonders
- Poppy Playtime Chapter 5: Engineering Workshop Locker Keypad Code Guide
- Bleach: Rebirth of Souls Shocks Fans With 8 Missing Icons!
- Why Aave is Making Waves with $1B in Tokenized Assets â You Wonât Believe This!
- All Kamurocho Locker Keys in Yakuza Kiwami 3
- Who Is the Information Broker in The Sims 4?
2026-02-28 07:23