arXiv:2511.06778cs.CL2025-11AAAI被引 4

让大模型生成数据库查询时自动保护隐私,防数据泄露。

SAFENLIDB: A Privacy-Preserving Safety Alignment Framework for LLM-based Natural Language Database Interfaces

  • 用自动生成的思维链数据训练模型,融合安全推理与SQL生成。
  • 在不依赖人工标注的情况下,显著降低数据泄露风险,保持查询准确率。
  • 适合开发安全可靠的自然语言数据库接口的研究者与工程师。

大型语言模型(LLMs)的快速发展推动了自然语言数据库接口(NLIDB)的进步,但其广泛应用也带来了严重的隐私与安全问题。在交互过程中,LLMs可能无意中暴露敏感数据库内容,或被攻击者利用,通过看似无害的查询窃取数据。现有方法多依赖规则启发式或LLM代理来缓解泄漏风险,但仍难以应对复杂的基于推理的攻击,存在高误报率,且常损害SQL查询的可靠性。为此,我们提出 extsc{SafeNlidb},一种面向LLM-based NLIDB的隐私-安全对齐框架。该框架采用自动化流水线,从零生成混合思维链交互数据,无缝结合隐式安全推理与SQL生成。此外,引入推理预热和交替偏好优化,克服直接偏好优化(DPO)中的多偏好振荡问题,使LLM在无需人类标注偏好数据的前提下,通过细粒度推理生成具备安全意识的SQL。大量实验表明,本方法优于更大规模的LLMs及理想设定基线,在显著提升安全性的同时保持高实用性。

原文摘要 · Abstract (English)

The rapid advancement of Large Language Models (LLMs) has driven significant progress in Natural Language Interface to Database (NLIDB). However, the widespread adoption of LLMs has raised critical privacy and security concerns. During interactions, LLMs may unintentionally expose confidential database contents or be manipulated by attackers to exfiltrate data through seemingly benign queries. While current efforts typically rely on rule-based heuristics or LLM agents to mitigate this leakage risk, these methods still struggle with complex inference-based attacks, suffer from high false positive rates, and often compromise the reliability of SQL queries. To address these challenges, we propose \textsc{SafeNlidb}, a novel privacy-security alignment framework for LLM-based NLIDB. The framework features an automated pipeline that generates hybrid chain-of-thought interaction data from scratch, seamlessly combining implicit security reasoning with SQL generation. Additionally, we introduce reasoning warm-up and alternating preference optimization to overcome the multi-preference oscillations of Direct Preference Optimization (DPO), enabling LLMs to produce security-aware SQL through fine-grained reasoning without the need for human-annotated preference data. Extensive experiments demonstrate that our method outperforms both larger-scale LLMs and ideal-setting baselines, achieving significant security improvements while preserving high utility. WARNING: This work may contain content that is offensive and harmful!

隐私保护大模型数据库安全对齐

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