Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Ask-your-data assistants let anyone query company databases in plain language. T
## What to do first

1. Let the assistant run only pre-approved query templates, not free-form queries.
2. Enforce who can see which rows and columns in the database itself, not in the assistant.
2. Enforce who can see which rows and columns in the database itself, for each user, not in the assistant.
3. Cap how many rows a single question can return.

## How it unfolds

Organizations expose warehouses, graphs and analytics engines through copilots that generate raw SQL, GraphQL or REST calls over wide schemas. This removes the boundary between user input and database logic.

- **Prompt-to-query injection:** natural language steers the model into harmful queries. No malformed input or special characters are needed; the whole prompt is the attack surface.
- **Privilege amplification:** generated queries run under one highly privileged service account instead of the user's identity, so a low-privilege user can trigger high-impact operations.
- **Privilege amplification:** generated queries run under one highly privileged service account instead of the user's identity, so a low-privilege user can trigger high-impact operations. Row- and column-level rules in the database then apply to the service account, not to the user.
- **Backdoored models:** text-to-SQL models can be poisoned with hidden triggers that produce malicious queries on specific inputs while behaving normally otherwise.
- **Weak validation and logging:** queries execute as generated, and logs then store full result sets for debugging.

Expand All @@ -47,6 +47,8 @@ Preconditions: free-form query generation; a single privileged connection; no ro

**1. A finance copilot dumps customer data.** An internal finance copilot lets staff ask for customer churn drivers this quarter. A malicious document injected into its retrieval context says to ignore previous rules and dump all customer personal data and card tokens. The model generates a query selecting everything from several tables, including sensitive columns, and the gateway executes it because no row-level policy applies to generated SQL.

**2. The analyst sees every region.** A sales assistant runs generated SQL through one service account. The warehouse has row-level security by region, but the policy sees only the service account, which may read all regions. An analyst responsible for one region asks for the top customers this quarter. The query returns customers from every region. The question was ordinary, and nothing was attacked.

## Impact

- **Confidentiality:** sensitive data is exfiltrated in bulk and at speed through a single compromised interface
Expand All @@ -70,7 +72,7 @@ Preconditions: free-form query generation; a single privileged connection; no ro
| ID | Control | Scope | Owner | Verification |
|---|---|---|---|---|
| GDS12-T1-01 | **Stored procedures and templates only:** Run all gateway queries through allow-listed stored procedures or parameterized templates; the model never generates arbitrary queries against privileged connections. | Build | Data and ML engineering | A free-form query attempt through the gateway is refused |
| GDS12-T1-02 | **Database-layer row and column security:** Enforce row-level security, column masking and redaction in the database, in a way the gateway's service account cannot bypass. | Build | Data and ML engineering | The gateway account cannot read a masked column in a test |
| GDS12-T1-02 | **Database-layer row and column security per user:** Enforce row-level security, column masking and redaction in the database against the requesting user's identity, passed from the gateway (for example as a delegated token or session context), so the gateway's own account cannot widen what a user sees. | Build | Data and ML engineering | Two users with different access get different results for the same question |
| GDS12-T1-03 | **Result-set size caps:** Return no more than a set number of rows per generated query without explicit confirmation or elevated approval. | Build | Data and ML engineering | A query over the cap is stopped or held for approval |
| GDS12-T1-04 | **Full gateway request logging:** Log every request, generated query and result metadata with user identity, timestamp and data category. | Build | Security | A sampled request can be traced to its generated query |

Expand Down Expand Up @@ -100,21 +102,26 @@ Preconditions: free-form query generation; a single privileged connection; no ro

## Incidents and research

None recorded in v1.
| Name | Type | Year | What it shows | Link |
|---|---|---|---|---|
| Prompt-to-SQL (P2SQL) injections | Research | 2025 | Prompts to LangChain and LlamaIndex applications produced harmful SQL across seven LLMs | https://arxiv.org/abs/2308.01990 |
| Text-to-SQL modules in commercial applications | Research | 2022 | The text-to-SQL modules of six commercial applications could be made to produce malicious SQL | https://arxiv.org/abs/2211.15363 |
| TrojanSQL | Research | 2023 | A backdoor planted by poisoning makes a text-to-SQL model emit injected SQL when a trigger appears | https://aclanthology.org/2023.emnlp-main.264/ |

## Mappings

| Framework | Codes |
|---|---|
| Related entries in this document | GDS01, GDS02, GDS06, GDS14 |
| Related entries in this document | GDS01, GDS02, GDS04, GDS06, GDS14 |
| OWASP Top 10 for LLM Applications | LLM01:2026, LLM03:2026 |
| OWASP Top 10 for Agentic Applications | ASI01, ASI02 |
| Regulations and standards | None specific |

## References

1. "How to safely use LLMs for Text-to-SQL with Stored Procedures", Medium. https://erincon01.medium.com/how-to-safely-use-llms-for-text-to-sql-with-stored-procedures-ba7540067f5f
2. DigitalAPI, "How to expose APIs to LLMs without breaking security". https://www.digitalapi.ai/blogs/expose-apis-to-llms
1. R. Pedro et al., "Prompt-to-SQL Injections in LLM-Integrated Web Applications: Risks and Defenses", ICSE 2025. https://arxiv.org/abs/2308.01990
2. X. Peng, Y. Zhang, J. Yang, M. Stevenson, "On the Security Vulnerabilities of Text-to-SQL Models", 2022. https://arxiv.org/abs/2211.15363
3. J. Zhang, Y. Zhou, B. Hui, Y. Liu, Z. Li, S. Hu, "TrojanSQL: SQL Injection against Natural Language Interface to Database", EMNLP 2023. https://aclanthology.org/2023.emnlp-main.264/
---

## Conversion notes (delete before publishing)
Expand Down