Skip to content
AI / LLM Write-up Advanced

From SELECT to SYSADMIN with SQL Copilot (CVE-2026-65669)

SQL Copilot in SSMS enforced a read-only mode only through a fragile regex blocklist and system prompt instructions, so a user could bypass it to run arbitrary T/SQL. A lower-privileged database user could plant malicious instructions in database metadata that, when loaded by Copilot for a higher-privileged user, executed arbitrary SQL and added the attacker to the sysadmin role.

embracethered.com

Published on embracethered.com

Two weeks back I presented at BlueHat Asia 2026 about my research on Microsoft’s Copilot in SSMS, the SQL Server Management Studio.

The author, on embracethered.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the read-only mode was enforced only by a regex blocklist and system prompt instructions rather than by a separate low-privileged database connection or read-only permission.

Impact

A lower-privileged database user could execute arbitrary T/SQL with the victim's privileges, exfiltrate data, and elevate to sysadmin; the text notes Microsoft has administrative controls to disable Copilot or set an execution context.

What the attacker needed

Access to a database via SSMS; Copilot enabled in SSMS; victim uses Copilot on attacker-controlled content; attacker has ALTER or db_owner rights

The fix

Read-only enforcement for an AI agent should be a security invariant such as a permission, not a model instruction or fragile SQL classifier, and Copilot should not run with highly privileged connections.

How it was found

  1. Open an authenticated Query Window to a database so Copilot exposes database-specific tools.
  2. Use the ReadFromDatabase tool with a query that declares a variable holding a stored procedure name and executes it, bypassing the EXEC blocklist.
  3. Use sp_executesql through the same tool to run arbitrary T/SQL such as DROP TABLE.
  4. Plant malicious instructions in database metadata via extended properties such as AGENTS.md or CONSTITUTION.md.
  5. Wait for a higher-privileged user to ask Copilot to inspect that content, triggering the indirect prompt injection.
  6. The injected instructions exploit the read-only bypass to execute arbitrary T/SQL using the victim's connection and add the attacker to sysadmin.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

SQL Copilot is an AI helper inside a database tool that can run queries for you. It was supposed to be limited to reading data, but the limit was only a set of text patterns and instructions to the AI, not a real permission. By hiding commands in database comments or metadata, an attacker could trick the AI into running dangerous commands with the victim's higher privileges.

What is AI / LLM?

Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.

Similar reports

View all

Same bug class and techniques, clearest first.

AI and LLM vulnerabilities

The lesson behind this report.

Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.