mlsanityData to 14 Oct 2026

Are Your LLM-based Text-to-SQL Models Secure? Exploring SQL Injection via Backdoor Attacks

arXiv 2503.05445 ↗First posted 7 Mar 2025cs.CR cs.DBcited by 6

On the map: LLM safety and security → Backdoor and data poisoning attacks

Abstract (arXiv)

Large language models (LLMs) have shown state-of-the-art results in translating natural language questions into SQL queries (Text-to-SQL), a long-standing challenge within the database community. However, security concerns remain largely unexplored, particularly the threat of backdoor attacks, which can introduce malicious behaviors into models through fine-tuning with poisoned datasets. In this work, we systematically investigate the vulnerabilities of LLM-based Text-to-SQL models and present ToxicSQL, a novel backdoor attack framework. Our approach leverages stealthy {semantic and character-level triggers} to make backdoors difficult to detect and remove, ensuring that malicious behaviors remain covert while maintaining high model accuracy on benign inputs. Furthermore, we propose leveraging SQL injection payloads as backdoor targets, enabling the generation of malicious yet executable SQL queries, which pose severe security and privacy risks in language model-based SQL development. We demonstrate that injecting only 0.44% of poisoned data can result in an attack success rate of 79.41%, posing a significant risk to database security. Additionally, we propose detection and mitigation strategies to enhance model reliability. Our findings highlight the urgent need for security-aware Text-to-SQL development, emphasizing the importance of robust defenses against backdoor threats.

Key facts. Cited by 6 papers in the map (data through 14 Oct 2026). Placed in Backdoor and data poisoning attacks, one of 12 directions in LLM safety and security. Builds on 64 of its 97 references that are in the map. First posted on arXiv 7 Mar 2025.

Builds on

64 of 97 references.

Closest ancestors · 7

Same direction, newest first

  1. 2024BEEAR: Embedding-based Adversarial Removal of Safety Backdoors in Instruction-tuned Language Models24 Jun
  2. 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detection10 Jun
  3. 2024Universal Vulnerabilities in Large Language Models: Backdoor Attacks for In-context Learning11 Jan
  4. 2023Detecting Backdoors in Pre-trained Encoders23 Mar
  5. 2021RAP: Robustness-Aware Perturbations for Defending against Backdoor Attacks on NLP Models15 Oct
  6. 2021Mind the Style of Text! Adversarial and Backdoor Attacks Based on Text Style Transfer14 Oct
  7. 2021Hidden Killer: Invisible Textual Backdoor Attacks with Syntactic Trigger26 May

Other references · 57

  1. 2023GPT-4 Technical Reportcited by 18,396
  2. 2024The Llama 3 Herd of Modelscited by 14,715
  3. 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
  4. 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,380
  5. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  6. 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
  7. 2019Parameter-Efficient Transfer Learning for NLPcited by 4,236
  8. 2023QLoRA: Efficient Finetuning of Quantized LLMscited by 3,418
  9. 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
  10. 2023G-Eval: NLG Evaluation using GPT-4 with Better Human Alignmentcited by 2,276
  11. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  12. 2024Gemma 2: Improving Open Language Models at a Practical Sizecited by 1,998
38 more
  1. 2018Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Taskcited by 1,139
  2. 2024ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Toolscited by 1,121
  3. 2017BadNets: Identifying Vulnerabilities in the Machine Learning Model Supply Chaincited by 1,106
  4. 2017Targeted Backdoor Attacks on Deep Learning Systems Using Data Poisoningcited by 1,055
  5. 2023Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLscited by 688
  6. 2018Fine-Pruning: Defending Against Backdooring Attacks on Deep Neural Networkscited by 580
  7. 2023Jailbreaking ChatGPT via Prompt Engineering: An Empirical Studycited by 498
  8. 2023"Do Anything Now": Characterizing and Evaluating In-The-Wild Jailbreak Prompts on Large Language Modelscited by 489
  9. 2023DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correctioncited by 477
  10. 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 411
  11. 2023Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluationcited by 385
  12. 2020Invisible Backdoor Attack with Sample-Specific Triggerscited by 353
  13. 2020Weight Poisoning Attacks on Pre-trained Modelscited by 341
  14. 2020ONION: A Simple and Effective Defense Against Textual Backdoor Attackscited by 263
  15. 2021Anti-Backdoor Learning: Training Clean Models on Poisoned Datacited by 263
  16. 2020BadNL: Backdoor Attacks against NLP Models with Semantic-preserving Improvementscited by 211
  17. 2023RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQLcited by 195
  18. 2023SneakyPrompt: Jailbreaking Text-to-image Generative Modelscited by 189
  19. 2024CodeS: Towards Building Open-source Language Models for Text-to-SQLcited by 187
  20. 2021Adversarial Unlearning of Backdoors via Implicit Hypergradientcited by 166
  21. 2023C3: Zero-shot Text-to-SQL with ChatGPTcited by 164
  22. 2024Next-Generation Database Interfaces: A Survey of LLM-based Text-to-SQLcited by 120
  23. 2024A Comprehensive Study of Jailbreak Attack versus Defense for Large Language Modelscited by 106
  24. 2024DrAttack: Prompt Decomposition and Reconstruction Makes Powerful LLM Jailbreakerscited by 101
  25. 2023SCALE-UP: An Efficient Black-box Input-level Backdoor Detection via Analyzing Scaled Prediction Consistencycited by 97
  26. 2023Combating Misinformation in the Age of LLMs: Opportunities and Challengescited by 95
  27. 2021Backdoor Pre-trained Models Can Transfer to Allcited by 86
  28. 2024The Dawn of Natural Language to SQL: Are We Fully Ready?cited by 79
  29. 2019Design and Evaluation of a Multi-Domain Trojan Detection Method on Deep Neural Networkscited by 71
  30. 2021Natural SQL: Making SQL Easier to Infer from Natural Language Specificationscited by 68
  31. 2025OpenSearch-SQL: Enhancing Text-to-SQL with Dynamic Few-shot and Consistency Alignmentcited by 53
  32. 2023UNICORN: A Unified Backdoor Trigger Inversion Frameworkcited by 46
  33. 2023ScienceBenchmark: A Complex Real-World Benchmark for Evaluating Natural Language to SQL Systemscited by 45
  34. 2024IBD-PSC: Input-level Backdoor Detection via Parameter-oriented Scaling Consistencycited by 39
  35. 2024FinSQL: Model-Agnostic LLMs-based Text-to-SQL Framework for Financial Analysiscited by 36
  36. 2024PET-SQL: A Prompt-Enhanced Two-Round Refinement of Text-to-SQL with Cross-consistencycited by 27
  37. 2023Improving Generalization in Language Model-Based Text-to-SQL Semantic Parsing: Two Simple Semantic Boundary-Based Techniquescited by 24
  38. 2024PreCurious: How Innocent Pre-Trained Language Models Turn into Privacy Trapscited by 23

50 most cited of 57 All 57 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 1; 2026: 5.

6 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026When Prompts Become Payloads: A Framework for Mitigating SQL Injection Attacks in Large Language Model-Driven Applications
  2. 2023From Prompt Injections to SQL Injection Attacks: How Protected is Your LLM-Integrated Web Application?
  3. 2025Revisiting Backdoor Attacks on LLMs: A Stealthy and Practical Poisoning Framework via Harmless Inputs
  4. 2025A Survey on Backdoor Threats in Large Language Models (LLMs): Attacks, Defenses, and Evaluations
  5. 2026Backdooring Bias in Large Language Models
  6. 2025Data Security in Large Language Models: Risks, Defense, and Directions
  7. 2023PoisonPrompt: Backdoor Attack on Prompt-based Large Language Models
  8. 2024A Survey of Recent Backdoor Attacks and Defenses in Large Language Models