arXiv:2605.10176cs.CRcs.AI2026-05

为大模型数据库接口设计安全框架,防住恶意提示注入攻击

When Prompts Become Payloads: A Framework for Mitigating SQL Injection Attacks in Large Language Model-Driven Applications

  • 三重防护:提示净化、行为异常检测、已知攻击模式拦截
  • 在多种攻击场景下检测准确率高,误报率低
  • 适合开发大模型数据应用的安全团队参考

自然语言接口正广泛应用于结构化数据库查询,得益于大语言模型(LLM)使用户能用对话式输入替代传统SQL。然而,这种范式提升了易用性的同时也放大了SQL注入风险,恶意用户可通过构造对抗性提示操纵模型生成危险查询。本文提出一种多层安全框架,包含前端提示净化、基于行为与语义的异常检测模型,以及针对已知攻击模式的签名控制层。我们在包括提示注入、混淆SQL载荷和上下文操控在内的多种真实攻击场景下评估该框架,并构建了一个涵盖对抗性提示的基准数据集。实验表明,该方法在保持低误报率的前提下实现高检测准确率,显著提升大模型驱动数据库应用的安全部署能力。

原文摘要 · Abstract (English)

Natural language interfaces to structured databases are becoming increasingly common, largely due to advances in large language models (LLMs) that enable users to query data using conversational input rather than formal query languages such as SQL. While this paradigm significantly improves usability and accessibility, it introduces new security risks, particularly the amplification of SQL injection vulnerabilities through the prompt-to-SQL translation process. Malicious users can exploit these mechanisms by crafting adversarial prompts that manipulate model behavior and generate unsafe queries. In this work, we propose a multi-layered security framework designed to detect and mitigate LLM-mediated SQL injection attacks. The framework integrates a front-end security shield for prompt sanitization, an advanced threat detection model for behavioral and semantic anomaly identification, and a signature-based control layer for known attack patterns. We evaluate the proposed framework under diverse and realistic attack scenarios, including prompt injection, obfuscated SQL payloads, and context-manipulation attacks. To ensure robustness, we generate and curate a comprehensive benchmark dataset of adversarial prompts and assess performance across a fine-tuned LLM configuration. Experimental results demonstrate that the proposed approach achieves high detection accuracy while maintaining low false-positive rates, significantly improving the secure deployment of LLM-powered database applications.

大模型安全SQL注入提示攻击数据库接口

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。