إطار هجيني في الوقت الحقيقي لاكتشاف هجمات حقن الطلب التكيفية في نماذج اللغة الكبيرة Hybrid Real-time Framework for Detecting Adaptive Prompt Injection Attacks in Large Language Models

شارك:
المجلة: Journal of Computing Theories and Applications، المجلد: 3، العدد: 3
DOI: https://doi.org/10.62411/jcta.15254
تاريخ النشر: 2026-01-09
المؤلف: Chandra Prakash وآخرون
الموضوع الرئيسي: الصلابة ضد الهجمات في تعلم الآلة

نظرة عامة

تتناول الورقة التهديد الأمني الكبير الذي تشكله هجمات حقن الأوامر على نماذج اللغة الكبيرة (LLMs)، والتي تستغل صعوبة النماذج في التمييز بين التعليمات والبيانات. تستعرض الورقة مجموعة متنوعة من طرق الهجوم، بما في ذلك حقن الأوامر المباشر وغير المباشر، وتنتقد الدفاعات الحالية، وخاصة ضعف كشف الإجابات المعروفة (KAD) ضد الهجمات التكيفية مثل DataFlip. للتخفيف من هذه المشكلات، يقترح المؤلفون إطار كشف هجين جديد يعمل في الوقت الحقيقي، يجمع بين التصفية المبدئية الاستدلالية، والتحليل الدلالي مع تضمينات المحولات الدقيقة، والتعرف على أنماط السلوك. حقق هذا النهج متعدد الطبقات دقة بلغت 0.974، ودقة 1.000، واسترجاع 0.950، ودرجة F1 بلغت 0.974، مما يدل على قدرات كشف قوية عبر الأبعاد المدخلة والدلالية والسلوكية.

في الختام، بينما يقدم الإطار المقترح آلية دفاع استباقية وغير مرتبطة بنموذج معين، إلا أن له قيودًا، بما في ذلك الاعتماد على مجموعة بيانات واحدة وغياب التحقق المتقاطع الطبقي، مما قد يؤثر على قابلية تعميم النتائج. تركز التنفيذ الحالي بشكل أساسي على أنماط المخرجات القابلة للملاحظة دون الاستفادة من حالات النموذج الداخلية. تشمل اتجاهات البحث المستقبلية تقييمات تجريبية أوسع عبر مجموعات بيانات ومجالات متنوعة، بالإضافة إلى استكشاف إشارات سلوكية أغنى. بشكل عام، تؤكد الدراسة على إمكانيات استراتيجيات الكشف متعددة الطبقات والواعية بالسلوك كنهج قابل للتطبيق لتعزيز الأمان ضد حقن الأوامر في تطبيقات LLM.

مقدمة

تناقش مقدمة الورقة التقدم السريع لنماذج اللغة الكبيرة (LLMs) في مجال معالجة اللغة الطبيعية (NLP) وتبرز قدراتها الواسعة، التي تتراوح من الوكلاء المحادثين إلى توليد الشيفرة. ومع ذلك، فإن هذا الاعتماد الواسع قد قدم مخاطر أمنية كبيرة، خاصة من خلال هجمات حقن الأوامر، التي يمكن أن تتلاعب بنماذج LLMs لأداء إجراءات ضارة تتجاوز مجرد توليد المحتوى. يمكن أن تؤدي هذه الهجمات إلى عواقب وخيمة، بما في ذلك سرقة البيانات، واستخراج بيانات الاعتماد، وتنفيذ الشيفرة التعسفية، مما يحول حقن الأوامر من قلق بشأن سلامة المحتوى إلى تهديد أمني مباشر.

تصنف الورقة ثغرات حقن الأوامر إلى نوعين رئيسيين: حقن الأوامر المباشر، حيث يتم تضمين أوامر صريحة في مدخلات المستخدم، وحقن الأوامر غير المباشر (IPI)، حيث يتم إخفاء التعليمات الضارة في مصادر البيانات الخارجية. يجادل المؤلفون بأن الدفاعات الحالية غير كافية، وغالبًا ما تكون تفاعلية وتؤدي إلى تدهور الأداء، ويقترحون إطار كشف متعدد الطبقات يعمل في الوقت الحقيقي يدمج التصفية المبدئية الاستدلالية، والتحليل الدلالي، والتعرف على أنماط السلوك. يهدف هذا الهيكل الهجين إلى تعزيز المرونة ضد استراتيجيات حقن الأوامر المتطورة، مع معالجة قيود الدفاعات الحالية وتقديم نهج شامل لحماية تطبيقات LLM ضد هذه الهجمات المتطورة.

طرق

في هذا القسم، يصف المؤلفون الإعداد التجريبي لتطوير وضبط نموذج xlm-roberta-large، وهو نموذج تحويل متعدد اللغات على نطاق واسع تم تدريبه مسبقًا على حوالي 2.5 تيرابايت من النصوص عبر 100 لغة. تم ضبط النموذج مع حجم دفعة قدره 8 ومعدل تعلم قدره $2 \times 10^{-5}$. تعزز هيكله، الذي يتكون من 24 طبقة تحويل ومفردات مشتركة تتكون من حوالي 250,000 وحدة فرعية، قدرته على الفهم الدلالي وتجعل منه فعالًا بشكل خاص في تصنيف النصوص على مستوى النية والتعلم الانتقالي.

تُبرر اختيار xlm-roberta-large بقدرته على نمذجة الهياكل اللغوية المعقدة، وهو أمر حاسم لكشف محاولات حقن الأوامر المعقدة والمتعددة اللغات. تم إجراء التجارب على وحدة معالجة الرسوميات NVIDIA T4 ضمن بيئة Google Colab، مع تقديم تفاصيل تكوين إضافية في الجدول 4 من الورقة.

نتائج

تقدم نتائج الدراسة تقييمًا شاملاً لمجموعة متنوعة من النماذج لكشف حقن الأوامر، مع تسليط الضوء على مقاييس الأداء من دقة، ودقة، واسترجاع، ودرجة F1 عبر فترات تدريب مختلفة. أظهر النموذج المضبوط تحسنًا مستمرًا في خسارة التحقق ومقاييس الأداء، كما هو موضح في الأشكال 3 و4. من بين المصنفات التقليدية، حقق الانحدار اللوجستي وآلة الدعم الناقل (SVM) دقة عالية بلغت 0.966 و0.957، على التوالي، مع دقة مثالية (1.000) وقيم استرجاع تتجاوز 0.91. في المقابل، أدت أداء النموذج المدرب مسبقًا xlm-roberta-large بشكل ضعيف، بدقة بلغت 0.440 فقط، مما يبرز عدم كفاية النماذج العامة لهذه المهمة المحددة.

حقق النموذج الهجين المقترح، الذي يدمج التصفية المبدئية الاستدلالية والتحليل الدلالي، أعلى أداء بدقة ودرجة F1 بلغت 0.974، إلى جانب دقة مثالية واسترجاع قدره 0.950. يشير هذا إلى أن النموذج حدد بفعالية الأوامر الضارة مع تجنب الإيجابيات الكاذبة، وهو عامل حاسم للتطبيقات العملية. تم أيضًا تقييم نموذج هجين ثلاثي الطبقات موسع، والذي حافظ على استرجاع قابل للمقارنة ولكنه أظهر انخفاضات طفيفة في الدقة ودرجة F1. تؤكد النتائج على أهمية تحقيق توازن بين فعالية الكشف وقابلية الاستخدام، خاصة في السياقات الحساسة للأمان، حيث تكون تكاليف الإيجابيات الكاذبة والسلبية الكاذبة غير متكافئة. تكشف النتائج، المدعومة بتحليل مصفوفة الارتباك، عن هيمنة الإيجابيات الحقيقية والسلبيات الحقيقية، مما يشير إلى قدرة كشف قوية مع مجال للتحسين في معالجة الهجمات التكيفية.

نقاش

تسلط قسم النقاش في الورقة البحثية الضوء على الطبيعة متعددة الأوجه لهجمات حقن الأوامر على نماذج اللغة الكبيرة (LLMs)، والتي يمكن أن تؤدي إلى نتائج ضارة متنوعة مثل نقل البرمجيات الضارة، والمعلومات المضللة، وهجمات الحرمان من الخدمة (DoS)، واستخراج البيانات. تستغل هذه الهجمات الثغرات الكامنة في LLMs من خلال التلاعب بالأوامر لإنتاج مخرجات متحيزة أو ضارة، متجاوزة بروتوكولات الأمان، ومتجنبة الكشف من خلال تقنيات التعتيم. يؤكد المؤلفون أن حقن الأوامر ليس مجرد ثغرة فردية، بل يمثل فئة واسعة من التهديدات التي تتطلب نموذج كشف شامل قادر على تحديد نوايا ضارة متنوعة من خلال عدة أنماط، بما في ذلك التحليل الدلالي، والبنائي، والسلوكي.

تشير مراجعة الأدبيات إلى أنه على الرغم من اقتراح العديد من استراتيجيات الكشف والتخفيف، بما في ذلك التصفية الاستدلالية والتحليل الدلالي، إلا أنه لا يوجد منها ما يعالج بالكامل الطبيعة المتطورة لهذه التهديدات. يتم مناقشة قيود الأساليب الحالية، مثل كشف الإجابات المعروفة (KAD) والتصفية المدخلة/المخرجة، وخاصة حساسيتها للهجمات التكيفية مثل DataFlip، التي تستغل السياق المشترك داخل LLM. يقترح المؤلفون إطار كشف هجين يعمل خارجيًا عن خط أنابيب اتباع التعليمات في LLM، ويجمع بين التصفية المبدئية الاستدلالية، والتحليل الدلالي، والتعرف على أنماط السلوك. يهدف هذا النهج الطبقي إلى تعزيز قوة الدفاعات ضد حقن الأوامر من خلال الكشف عن كل من وجود النية الضارة وعواقب الحقن الناجح، مما يعالج الفجوات الحرجة في المنهجيات الحالية.

قيود

تسلط قسم القيود في هذه الورقة الضوء على قيود إطار الكشف متعدد الطبقات المقترح للدفاع ضد حقن الأوامر، الذي يدمج التصفية المبدئية الاستدلالية، والتحليل الدلالي، والتعرف على أنماط السلوك. بينما يقدم هذا النهج استراتيجية شاملة للأمان العميق غير المرتبطة بنموذج معين وقابلة للتكيف، إلا أنه لا يمكنه ضمان الحماية المطلقة ضد تقنيات حقن الأوامر الجديدة أو ذات اليوم الصفري. تعتمد فعالية الإطار على التحسين المستمر والتكامل ضمن خط أنابيب MLOps الأوسع، والذي يتضمن المراقبة المستمرة والتحديثات بناءً على أساليب الهجوم الجديدة. بالإضافة إلى ذلك، قد يحد الاعتماد على مجموعة بيانات عامة واحدة من قابلية تعميم النتائج عبر متغيرات حقن الأوامر المختلفة وبيئات النشر.

تم تحديد اتجاهات البحث المستقبلية، مع التأكيد على الحاجة إلى تقييمات عبر منصات LLM متنوعة وحالات استخدام محددة بالنطاق لتعزيز قابلية التعميم. يقترح المؤلفون استخدام التحقق المتقاطع الطبقي k-fold لتقييم استقرار الأداء وتباين الاسترجاع، بالإضافة إلى إجراء تحليلات إلغاء منهجية لتحديد مساهمات كل مكون من مكونات الإطار. كما يُوصى بإجراء دراسات مقارنة لمقارنة النموذج الهجين مع الأساليب الحالية، لتوضيح مزاياه وعيوبه. بشكل عام، تؤسس الورقة إطارًا أساسيًا لكشف حقن الأوامر، مما يمهد الطريق لدفاعات أكثر مرونة في الأنظمة المدمجة مع LLM.

Journal: Journal of Computing Theories and Applications, Volume: 3, Issue: 3
DOI: https://doi.org/10.62411/jcta.15254
Publication Date: 2026-01-09
Author(s): Chandra Prakash et al.
Primary Topic: Adversarial Robustness in Machine Learning

Overview

The paper addresses the significant security threat posed by prompt injection attacks on Large Language Models (LLMs), which exploit the models’ difficulty in distinguishing between instructions and data. It reviews various attack vectors, including direct and indirect prompt injection, and critiques existing defenses, particularly the vulnerability of Known-Answer Detection (KAD) against adaptive attacks like DataFlip. To mitigate these issues, the authors propose a novel hybrid detection framework that operates in real-time, combining heuristic pre-filtering, semantic analysis with fine-tuned transformer embeddings, and behavioral pattern recognition. This multi-layered approach achieved an accuracy of 0.974, precision of 1.000, recall of 0.950, and an F1 score of 0.974, demonstrating robust detection capabilities across input, semantic, and behavioral dimensions.

In conclusion, while the proposed framework offers a proactive and LLM-agnostic defense mechanism, it has limitations, including reliance on a single dataset and a lack of stratified cross-validation, which may affect the generalizability of the findings. The current implementation primarily focuses on observable output patterns without leveraging internal model states. Future research directions include broader empirical evaluations across diverse datasets and domains, as well as exploring richer behavioral signals. Overall, the study underscores the potential of layered, behavior-aware detection strategies as a viable approach to enhance security against prompt injection in LLM applications.

Introduction

The introduction of the paper discusses the rapid advancement of Large Language Models (LLMs) in the field of Natural Language Processing (NLP) and highlights their extensive capabilities, which range from conversational agents to code generation. However, this widespread adoption has introduced significant security risks, particularly through prompt injection attacks, which can manipulate LLMs to perform harmful actions beyond mere content generation. These attacks can lead to severe consequences, including data theft, credential exfiltration, and the execution of arbitrary code, thereby transforming prompt injection from a concern about content integrity into a direct security threat.

The paper categorizes prompt injection vulnerabilities into two main types: Direct Prompt Injection, where explicit commands are embedded in user input, and Indirect Prompt Injection (IPI), where malicious instructions are hidden in external data sources. The authors argue that current defenses are inadequate, often reactive and performance-degrading, and propose a multi-layered, real-time detection framework that integrates heuristic pre-filtering, semantic analysis, and behavioral pattern recognition. This hybrid architecture aims to enhance resilience against evolving prompt injection strategies, addressing the limitations of existing defenses and providing a comprehensive approach to safeguarding LLM applications against these sophisticated attacks.

Methods

In this section, the authors describe the experimental setup for developing and fine-tuning the xlm-roberta-large model, which is a large-scale multilingual transformer pre-trained on approximately 2.5 TB of text across 100 languages. The model was fine-tuned with a batch size of 8 and a learning rate of $2 \times 10^{-5}$. Its architecture, consisting of 24 transformer layers and a shared vocabulary of around 250,000 subword units, enhances its capability for semantic understanding and makes it particularly effective for intent-level text classification and transfer learning.

The choice of xlm-roberta-large is justified by its ability to model complex linguistic structures, which is crucial for detecting obfuscated and multilingual prompt injection attempts. The experiments were conducted on an NVIDIA T4 GPU within the Google Colab environment, with additional configuration details provided in Table 4 of the paper.

Results

The results of the study provide a comprehensive evaluation of various models for prompt injection detection, highlighting the performance metrics of accuracy, precision, recall, and F1 score across different training epochs. The fine-tuned model demonstrated consistent improvement in validation loss and performance metrics, as illustrated in Figures 3 and 4. Among the traditional classifiers, Logistic Regression and Support Vector Machine (SVM) achieved high accuracies of 0.966 and 0.957, respectively, with perfect precision (1.000) and recall values exceeding 0.91. In contrast, the pre-trained xlm-roberta-large model performed poorly, with an accuracy of only 0.440, underscoring the inadequacy of general-purpose models for this specific task.

The proposed Hybrid Model, which incorporates heuristic pre-filtering and semantic analysis, achieved the highest performance with an accuracy and F1 score of 0.974, alongside perfect precision and a recall of 0.950. This indicates that the model effectively identified malicious prompts while avoiding false positives, a critical factor for practical applications. An extended three-layer hybrid model was also evaluated, which maintained comparable recall but showed slight reductions in precision and F1 score. The findings emphasize the importance of balancing detection effectiveness with usability, particularly in security-sensitive contexts, where the costs of false negatives and false positives are asymmetric. The results, supported by a confusion matrix analysis, reveal a predominance of true positives and true negatives, indicating a robust detection capability with room for improvement in addressing adaptive attacks.

Discussion

The discussion section of the research paper highlights the multifaceted nature of prompt injection attacks on large language models (LLMs), which can lead to various malicious outcomes such as malware transmission, disinformation, denial-of-service (DoS) attacks, and data exfiltration. These attacks exploit the inherent vulnerabilities of LLMs by manipulating prompts to produce biased or harmful outputs, bypassing safety protocols, and evading detection through obfuscation techniques. The authors emphasize that prompt injection is not merely a singular vulnerability but represents a broad class of threats that necessitate a comprehensive detection model capable of identifying diverse malicious intents through multiple modalities, including semantic, structural, and behavioral analyses.

The literature review indicates that while several detection and mitigation strategies have been proposed, including heuristic filtering and semantic analysis, none fully address the evolving nature of these threats. The limitations of existing approaches, such as Known-Answer Detection (KAD) and input/output filtering, are discussed, particularly their susceptibility to adaptive attacks like DataFlip, which exploit shared context within the LLM. The authors propose a hybrid detection framework that operates externally to the LLM’s instruction-following pipeline, integrating heuristic pre-filtering, semantic analysis, and behavioral pattern recognition. This layered approach aims to enhance the robustness of defenses against prompt injection by detecting both the presence of malicious intent and the consequences of successful injections, thereby addressing critical gaps in current methodologies.

Limitations

The limitations section of this paper highlights the constraints of the proposed multi-layered detection framework for prompt injection defense, which integrates heuristic pre-filtering, semantic analysis, and behavioral pattern recognition. While this approach offers a comprehensive security-in-depth strategy that is LLM-agnostic and adaptable, it cannot guarantee absolute protection against novel or zero-day prompt injection techniques. The framework’s effectiveness relies on continuous refinement and integration within a broader MLOps pipeline, which includes ongoing monitoring and updates based on new attack methods. Additionally, the reliance on a single public dataset may restrict the generalizability of the findings across various prompt injection variants and deployment environments.

Future research directions are outlined, emphasizing the need for evaluations across diverse LLM platforms and domain-specific use cases to enhance generalizability. The authors suggest employing stratified k-fold cross-validation to assess performance stability and variance in recall, as well as conducting systematic ablation analyses to quantify the contributions of each framework component. Comparative studies are also recommended to benchmark the hybrid model against existing approaches, clarifying its advantages and trade-offs. Overall, the paper establishes a foundational framework for prompt injection detection, paving the way for more resilient defenses in LLM-integrated systems.