Are Your LLM-based Text-to-SQL Models Secure? Exploring SQL Injection via Backdoor Attacks
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
- 2024BEEAR: Embedding-based Adversarial Removal of Safety Backdoors in Instruction-tuned Language Models24 Jun
- 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detection10 Jun
- 2024Universal Vulnerabilities in Large Language Models: Backdoor Attacks for In-context Learning11 Jan
- 2023Detecting Backdoors in Pre-trained Encoders23 Mar
- 2021RAP: Robustness-Aware Perturbations for Defending against Backdoor Attacks on NLP Models15 Oct
- 2021Mind the Style of Text! Adversarial and Backdoor Attacks Based on Text Style Transfer14 Oct
- 2021Hidden Killer: Invisible Textual Backdoor Attacks with Syntactic Trigger26 May
Other references · 57
- 2023GPT-4 Technical Reportcited by 18,396
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,380
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
- 2019Parameter-Efficient Transfer Learning for NLPcited by 4,236
- 2023QLoRA: Efficient Finetuning of Quantized LLMscited by 3,418
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
- 2023G-Eval: NLG Evaluation using GPT-4 with Better Human Alignmentcited by 2,276
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2024Gemma 2: Improving Open Language Models at a Practical Sizecited by 1,998
38 more
- 2018Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Taskcited by 1,139
- 2024ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Toolscited by 1,121
- 2017BadNets: Identifying Vulnerabilities in the Machine Learning Model Supply Chaincited by 1,106
- 2017Targeted Backdoor Attacks on Deep Learning Systems Using Data Poisoningcited by 1,055
- 2023Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLscited by 688
- 2018Fine-Pruning: Defending Against Backdooring Attacks on Deep Neural Networkscited by 580
- 2023Jailbreaking ChatGPT via Prompt Engineering: An Empirical Studycited by 498
- 2023"Do Anything Now": Characterizing and Evaluating In-The-Wild Jailbreak Prompts on Large Language Modelscited by 489
- 2023DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correctioncited by 477
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 411
- 2023Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluationcited by 385
- 2020Invisible Backdoor Attack with Sample-Specific Triggerscited by 353
- 2020Weight Poisoning Attacks on Pre-trained Modelscited by 341
- 2020ONION: A Simple and Effective Defense Against Textual Backdoor Attackscited by 263
- 2021Anti-Backdoor Learning: Training Clean Models on Poisoned Datacited by 263
- 2020BadNL: Backdoor Attacks against NLP Models with Semantic-preserving Improvementscited by 211
- 2023RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQLcited by 195
- 2023SneakyPrompt: Jailbreaking Text-to-image Generative Modelscited by 189
- 2024CodeS: Towards Building Open-source Language Models for Text-to-SQLcited by 187
- 2021Adversarial Unlearning of Backdoors via Implicit Hypergradientcited by 166
- 2023C3: Zero-shot Text-to-SQL with ChatGPTcited by 164
- 2024Next-Generation Database Interfaces: A Survey of LLM-based Text-to-SQLcited by 120
- 2024A Comprehensive Study of Jailbreak Attack versus Defense for Large Language Modelscited by 106
- 2024DrAttack: Prompt Decomposition and Reconstruction Makes Powerful LLM Jailbreakerscited by 101
- 2023SCALE-UP: An Efficient Black-box Input-level Backdoor Detection via Analyzing Scaled Prediction Consistencycited by 97
- 2023Combating Misinformation in the Age of LLMs: Opportunities and Challengescited by 95
- 2021Backdoor Pre-trained Models Can Transfer to Allcited by 86
- 2024The Dawn of Natural Language to SQL: Are We Fully Ready?cited by 79
- 2019Design and Evaluation of a Multi-Domain Trojan Detection Method on Deep Neural Networkscited by 71
- 2021Natural SQL: Making SQL Easier to Infer from Natural Language Specificationscited by 68
- 2025OpenSearch-SQL: Enhancing Text-to-SQL with Dynamic Few-shot and Consistency Alignmentcited by 53
- 2023UNICORN: A Unified Backdoor Trigger Inversion Frameworkcited by 46
- 2023ScienceBenchmark: A Complex Real-World Benchmark for Evaluating Natural Language to SQL Systemscited by 45
- 2024IBD-PSC: Input-level Backdoor Detection via Parameter-oriented Scaling Consistencycited by 39
- 2024FinSQL: Model-Agnostic LLMs-based Text-to-SQL Framework for Financial Analysiscited by 36
- 2024PET-SQL: A Prompt-Enhanced Two-Round Refinement of Text-to-SQL with Cross-consistencycited by 27
- 2023Improving Generalization in Language Model-Based Text-to-SQL Semantic Parsing: Two Simple Semantic Boundary-Based Techniquescited by 24
- 2024PreCurious: How Innocent Pre-Trained Language Models Turn into Privacy Trapscited by 23
50 most cited of 57 All 57 (JSON)
Built on by
Citing papers per year: 2025: 1; 2026: 5.
6 papers.
- 2025Toward Real-World Table Agents: Capabilities, Workflows, and Design Principles for LLM-based Table Intelligencecited by 2
- 2026Data Agents Under Attack: Vulnerabilities in LLM-Driven Analytical Systemscited by 2
- 2026GenDB: The Next Generation of Query Processing -- Synthesized, Not Engineeredcited by 1
- 2026BadDLM: Backdooring Diffusion Language Models with Diverse Targetscited by 0
- 2026Policy-Conditioned Constrained Decoding for Column-Level Access Control in Text-to-SQLcited by 0
- 2026TrustDABench: Benchmarking Reliability and Robustness of LLMs for Structured Data Analysiscited by 0
- 2026TrustDABench: Benchmarking Reliability and Robustness of LLMs for Structured Data Analysis25 Aug 2026
- 2026Policy-Conditioned Constrained Decoding for Column-Level Access Control in Text-to-SQL14 Jul 2026
- 2026Data Agents Under Attack: Vulnerabilities in LLM-Driven Analytical Systems7 Jun 2026
- 2026BadDLM: Backdooring Diffusion Language Models with Diverse Targets10 May 2026
- 2026GenDB: The Next Generation of Query Processing -- Synthesized, Not Engineered2 Mar 2026
- 2025Toward Real-World Table Agents: Capabilities, Workflows, and Design Principles for LLM-based Table Intelligence14 Jul 2025
Similar, not cited
Close in wording, no citation either way
- 2026When Prompts Become Payloads: A Framework for Mitigating SQL Injection Attacks in Large Language Model-Driven Applications
- 2023From Prompt Injections to SQL Injection Attacks: How Protected is Your LLM-Integrated Web Application?
- 2025Revisiting Backdoor Attacks on LLMs: A Stealthy and Practical Poisoning Framework via Harmless Inputs
- 2025A Survey on Backdoor Threats in Large Language Models (LLMs): Attacks, Defenses, and Evaluations
- 2026Backdooring Bias in Large Language Models
- 2025Data Security in Large Language Models: Risks, Defense, and Directions
- 2023PoisonPrompt: Backdoor Attack on Prompt-based Large Language Models
- 2024A Survey of Recent Backdoor Attacks and Defenses in Large Language Models