system: OPERATIONAL
← back to all hacks
AGENTS CRITICAL NEW

SQL Server Copilot: a regex read-only mode, prompt injection, and a path to sysadmin

A Microsoft-rated critical flaw in Copilot for SQL Server Management Studio shows why read-only mode must be a database permission, not a regex or a model instruction.

2026-10-13 // 6 min affects: copilot-ssms, sql-server-management-studio

What is this?

On September 30, 2026, security researcher Johann Rehberger (Embrace The Red) published a write-up of his BlueHat Asia 2026 talk on Copilot in SQL Server Management Studio (SSMS). Microsoft tracks the issue as a SQL Server elevation-of-privilege vulnerability, published in its Security Update Guide on September 8, 2026, with a CVSS 3.1 base score of 9.6 (Critical). The initial research dates from May 2026.

The finding is a compact case study of a recurring agent-security mistake: a safety property (“read-only mode”) enforced by text analysis in the application layer instead of by the database itself.

How it works

According to the write-up, Copilot’s read-only mode relied on a regex-based classifier that decided whether a generated statement was safe to run. A classifier of this kind inspects the string, not the effect. The researcher showed that dynamic execution through a variable could slip past the pattern check, so statements that modify or drop data ran despite read-only mode. A second tool path, used for verifying backup files, also forwarded arbitrary T-SQL.

Two further pieces made it worse. First, query results could be sent to a remote file-share path through an extended stored procedure, giving a data-exfiltration channel. Second, Copilot reads instruction files stored in the database itself (a database-wide constitution file and per-object agent instructions, kept as extended properties). A user with only modest rights on an object could attach such instructions, and Copilot would follow them later with the privileges of whoever was using it.

Chained together, a database owner could plant instructions, wait for a sysadmin to open Copilot on that database, and have the agent add the attacker’s login to the sysadmin role. The attack needs user interaction, but no exploit code: the “payload” is text that the agent treats as guidance. No working strings are reproduced here.

Example prompt

Illustrative and redacted: this shows the shape of the weakness, not a usable payload.

# SQL Copilot: read-only enforced by a classifier (illustrative, defensive, redacted)
# Pattern: the guard inspects the text of a statement, not the privileges of the connection.
#   "read-only" check  ->  pattern match on the T-SQL string   [bypassable by indirection]
#   database-stored instruction files are read as trusted guidance [REDACTED]
# Defense: connect with a login that truly lacks write rights; treat any stored
# instruction text as untrusted input; never attach the agent to a sysadmin session.

Why it matters

Database assistants are attractive because they run with the connection of the person using them, which is often highly privileged. That makes the agent a confused deputy: low-privilege content steers a high-privilege session. The case also shows that “the model was told not to” and “a filter checks the SQL” are not security boundaries. Only the database’s own permission system can reliably answer what a given connection may do.

The same pattern applies to any agent with a code-execution tool: instruction files in a repo, a wiki or a database are untrusted input, however convenient they are as configuration.

Defenses

Enforce read-only as a permission. Use a login or connection that truly lacks write, DDL and execute rights for assistant sessions, rather than relying on a classifier or a prompt.

Never attach the assistant to a sysadmin or owner-level connection. Use a dedicated least-privilege account for AI-assisted work, and separate it from administration sessions.

Treat stored instructions as untrusted. Review who can write extended properties or similar metadata, and alert on new instruction files. Disable loading of such files where the product allows it.

Constrain egress and dangerous procedures. Restrict outbound file-share access and remove or deny the extended procedures that enable it.

Use the vendor’s controls. Microsoft documents administrative controls to disable Copilot, set policy and choose the execution context; apply them centrally, and keep SSMS updated through Microsoft’s current guidance.

Log and review. Audit statements executed by assistant sessions separately from human sessions.

Status

ItemReferenceDateNotes
Vendor advisoryCVE-2026-656692026-09-08SQL Server elevation of privilege; CVSS 3.1 base 9.6 (Critical); affects Copilot in SSMS
Researcher write-upEmbrace The Red2026-09-30BlueHat Asia 2026 talk; research began May 2026
Fixed buildNot stated in the sources reviewedn/aCheck Microsoft’s current guidance for the fixed SSMS version

Sources