{
  "schema": "aidefend-secureflow-metadata-v1",
  "flow_id": "aidefend-research-sf0060-ssms-copilot-metadata-readonly-bypass",
  "title": "SSMS Copilot: Database Instructions Turn Read-Only Tools into SYSADMIN",
  "subtitle": "Controlled SQL Copilot research: metadata injection, inherited connection authority, and a separate backup-tool exfiltration demonstration.",
  "summary": "Johann Rehberger tested Copilot, the AI query assistant in SQL Server Management Studio (SSMS), and made a database owner's stored instructions induce execution under another user's more privileged SQL connection. A regex-based read-only check failed to contain dynamic SQL, and the final demonstration added the attacker's login to sysadmin. Separate direct-prompt experiments sent table data over SMB; these are distinct demonstrations, not evidence of a single observed intrusion.",
  "reviewed": true,
  "import_status": "curated-research",
  "ai_layers": [
    "autonomous-agents"
  ],
  "risk_impact": [
    "system-compromise-rce",
    "data-exfiltration"
  ],
  "affected_components": [
    "SSMS Copilot",
    "ReadFromDatabase",
    "LocalSqlExecutionAccessChecker",
    "SQL Server extended properties",
    "RestoreVerifyBackupFile"
  ],
  "source_research": {
    "provider": "Embrace The Red",
    "primary_url": "https://embracethered.com/blog/posts/2026/from-select-to-sysadmin-sql-copilot-bluehat-asia/",
    "published": "2026-09-30",
    "note": "Source-verified AIDEFEND research curation. ATLAS technique annotations are analyst mappings, not an official ATLAS case study."
  },
  "attack_steps": [
    {
      "id": "step-1",
      "title": "Plant a Malicious Database Constitution",
      "zhTitle": "在資料庫憲章植入惡意指示",
      "summary": "The database owner writes CONSTITUTION.md as an extended property. Object-level AGENTS.md is another documented input surface; the demonstrated server privilege escalation used the database constitution.",
      "zhSummary": "資料庫擁有者將 CONSTITUTION.md 寫入資料庫延伸屬性中。物件層級的 AGENTS.md 亦為受支援的輸入管道；研究中的伺服器權限提升示範主要利用資料庫憲章。",
      "tactic": "AML.TA0006",
      "technique": "AML.T0081",
      "layout": {
        "x": -960,
        "y": -360
      }
    },
    {
      "id": "step-2",
      "title": "Load the Constitution into Copilot Context",
      "zhTitle": "Copilot 將資料庫憲章納入模型輸入",
      "summary": "During a later interaction Copilot discovers the stored instructions. The victim has an authenticated query window with greater SQL Server authority than the metadata writer.",
      "zhSummary": "當後續使用者在查詢視窗操作 Copilot 時，系統自動讀入預先植入的指示。受害者此時已通過身分驗證，其連線具備高於中繼資料寫入者的 SQL Server 權限。",
      "tactic": "AML.TA0005",
      "technique": "AML.T0051.001",
      "layout": {
        "x": -480,
        "y": -360
      }
    },
    {
      "id": "step-3",
      "title": "Bypass the Regex Read-Only Check",
      "zhTitle": "繞過正規表示式的唯讀檢查",
      "summary": "The injected instructions drive ReadFromDatabase through an EXEC-variable/dynamic-SQL form that its LocalSqlExecutionAccessChecker blocklist fails to reject. There is no independent read-only database principal in the tested configuration.",
      "zhSummary": "惡意指示誘導 ReadFromDatabase 透過變數呼叫 EXEC 來執行動態 SQL，避開 LocalSqlExecutionAccessChecker 的黑名單過濾。受測環境並未配置獨立且真正受限的唯讀資料庫身分。",
      "tactic": "AML.TA0005",
      "technique": "AML.T0053",
      "layout": {
        "x": 0,
        "y": -360
      }
    },
    {
      "id": "step-4",
      "title": "Execute T-SQL with the Victim Connection",
      "zhTitle": "以受害者的連線身分執行 T-SQL",
      "summary": "Copilot executes arbitrary T-SQL with the query window connection. The read-only UI state does not remove that principal's SQL Server permissions.",
      "zhSummary": "Copilot 直接透過查詢視窗現有的連線執行任意 T-SQL 指令；前端介面雖標示為唯讀，但並未限制該登入帳號在 SQL Server 上的實際執行權限。",
      "tactic": "AML.TA0005",
      "technique": "AML.T0053",
      "layout": {
        "x": 480,
        "y": -360
      }
    },
    {
      "id": "step-5",
      "title": "Add the Attacker Login to SYSADMIN",
      "zhTitle": "把攻擊者登入帳號加入 sysadmin",
      "summary": "The final controlled demonstration adds the database owner's login to the server-level sysadmin role. This requires a victim connection able to perform that grant; a merely authenticated low-privilege connection is insufficient.",
      "zhSummary": "在最終的受控示範中，惡意指令將資料庫擁有者的登入帳號加入伺服器層級的 sysadmin 角色。此步驟必須依賴受害者連線具備足夠的授權權限，僅具備一般查詢權限的帳號無法完成此提升。",
      "tactic": "AML.TA0012",
      "technique": "AML.T0053",
      "layout": {
        "x": 960,
        "y": -360
      }
    },
    {
      "id": "step-6",
      "title": "Directly Request SQL through the Backup Tool",
      "zhTitle": "另以直接提示詞要求備份工具執行 SQL",
      "summary": "In a separate direct-prompt experiment, the researcher supplies T-SQL to RestoreVerifyBackupFile, a tool intended to validate backup files. This is not the observed metadata escalation sequence.",
      "zhSummary": "研究者在另一項獨立的直接提示詞測試中，將 T-SQL 指令直接交給原本用來驗證備份檔的 RestoreVerifyBackupFile。此測試與前述的中繼資料權限提升並非連續發生的攻擊鏈。",
      "tactic": "AML.TA0005",
      "technique": "AML.T0051.000",
      "layout": {
        "x": -480,
        "y": 440
      }
    },
    {
      "id": "step-7",
      "title": "Pass Arbitrary SQL through Backup Verification",
      "zhTitle": "備份驗證工具直接放行任意 SQL",
      "summary": "The backup-verification implementation accepts arbitrary T-SQL. The report also demonstrates a ReadFromDatabase/xp_dirtree exfiltration route; neither route depends on first obtaining sysadmin in the final demo.",
      "zhSummary": "受測的備份驗證工具實作會直接執行傳入的任意 T-SQL 指令。研究報告亦展示了透過 ReadFromDatabase 搭配 xp_dirtree 的外洩路徑；兩者均不以前述 sysadmin 示範成功為前提。",
      "tactic": "AML.TA0005",
      "technique": "AML.T0053",
      "layout": {
        "x": 0,
        "y": 440
      }
    },
    {
      "id": "step-8",
      "title": "Send Table Rows to an SMB Server",
      "zhTitle": "將資料表內容傳送至外部 SMB 伺服器",
      "summary": "The SQL exfiltration demonstrations place queried row data into SMB paths sent by the SQL Server host to a third-party server. This is a server egress path, not the SSMS desktop's web traffic.",
      "zhSummary": "資料外洩示範將查詢出的資料列包裝進 SMB 路徑，由 SQL Server 主機主動向第三方伺服器發起連線。防守方需控管的是資料庫伺服器本身的對外連線，而非 SSMS 桌面端的網頁流量。",
      "tactic": "AML.TA0010",
      "technique": "AML.T0025",
      "layout": {
        "x": 480,
        "y": 440
      }
    }
  ],
  "threat_refs": [
    {
      "id": "AML.T0051.001",
      "name": "LLM Prompt Injection: Indirect"
    },
    {
      "id": "AML.T0053",
      "name": "AI Agent Tool Invocation"
    },
    {
      "id": "AML.T0025",
      "name": "Exfiltration via Cyber Means"
    }
  ]
}
