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

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Lin, Meiyu, Zhang, Haichuan, Lao, Jiale, Li, Renyuan, Zhou, Yuanchun, Yang, Carl, Cao, Yang, Tang, Mingjie
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866911142005178368
author Lin, Meiyu
Zhang, Haichuan
Lao, Jiale
Li, Renyuan
Zhou, Yuanchun
Yang, Carl
Cao, Yang
Tang, Mingjie
author_facet Lin, Meiyu
Zhang, Haichuan
Lao, Jiale
Li, Renyuan
Zhou, Yuanchun
Yang, Carl
Cao, Yang
Tang, Mingjie
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2503_05445
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Are Your LLM-based Text-to-SQL Models Secure? Exploring SQL Injection via Backdoor Attacks
Lin, Meiyu
Zhang, Haichuan
Lao, Jiale
Li, Renyuan
Zhou, Yuanchun
Yang, Carl
Cao, Yang
Tang, Mingjie
Cryptography and Security
Databases
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.
title Are Your LLM-based Text-to-SQL Models Secure? Exploring SQL Injection via Backdoor Attacks
topic Cryptography and Security
Databases
url https://arxiv.org/abs/2503.05445