SQL Server Copilot Flaw Let a 'Read-Only' AI Assistant Write Data and Leak It
Security researcher Johann Rehberger has published details of CVE-2026-65669, a SQL Server elevation of privilege vulnerability that Microsoft rated critical. It affects Copilot in SQL Server Management Studio (SSMS), and he presented the research at BlueHat Asia 2026. His advice is to make sure installations are up to date.
The core issue is that Copilot runs with the privileges of the user connected in the Query Window. If that user is a sysadmin, Copilot also runs SQL as a sysadmin. Copilot was meant to be limited to a read-only mode, but this was largely enforced by a system prompt telling the model not to change data. A system prompt is an instruction, not a security boundary.
When the researcher examined the code, the only technical enforcement was a regex-based blocklist in a class called LocalSqlExecutionAccessChecker. There was no separate low-privileged database connection and no read-only permission enforcement. With AI assistance, bypasses were found quickly. One pattern invoked stored procedures indirectly, and another used sp_executesql to run dynamically built queries. Once these worked, Copilot could create, insert, update, delete and drop data. A second tool, RestoreVerifyBackupFile, also allowed arbitrary T/SQL to pass through.
The research also showed data leaving the network. Copilot could read table rows and send them to a third-party server using xp_dirtree, one row at a time. More worrying, an attacker could use indirect prompt injection: malicious instructions planted in database content, T/SQL files or metadata could influence Copilot when another user later asked it to inspect that material. The researcher notes Microsoft has since added MCP support.
Why it matters
Any team letting staff use Copilot in SSMS with sysadmin or other high-privilege logins is exposed, because the assumed read-only guardrail was a prompt and a regex, not a permission. This breaks the idea that an AI assistant can be safely limited by instructions, and it forces a decision to connect with least-privilege accounts instead. Because planted content can steer Copilot for a different user, untrusted data in a database becomes an attack path to privileged actions.
What to do
- Update SSMS and SQL Server to versions that include the fix for CVE-2026-65669.
- Connect to databases with least-privilege accounts rather than sysadmin when using Copilot.
- Review outbound SMB traffic and xp_dirtree use for signs of data being sent to external servers.
- Treat database content and T/SQL files from untrusted sources as possible prompt injection before asking Copilot to inspect them.