# Device Code Phishing Abuse Against AI Coding Agents (GitHub Copilot CLI) - Microsoft Security Research

> Microsoft Security Research demonstrated in a controlled lab that a victim who approves a phished GitHub device code gives an attacker-controlled client OAuth access to the victim's GitHub account via the GitHub Copilot CLI sign-in flow. Lab outcomes were steering an active remote-enabled session, injecting misleading Copilot Memory entries, reading cloud-synced sessions, and accessing private repositories. Microsoft states these outcomes were not observed in the wild.

- **Published:** 2026-11-17T17:01:19Z
- **Last reviewed:** 2026-11-17T17:01:19Z
- **Canonical:** https://intel.threadlinqs.com/threat/TL-2026-6261
- **Card image:** https://intel.threadlinqs.com/og/threat/TL-2026-6261.png
- **ID:** TL-2026-6261
- **Severity:** MEDIUM
- **Category:** VULNERABILITY
- **Status:** MONITORING
- **Detections:** 9 (1 shown free below) · **IOCs:** 9 (1 shown free below)

## Description

Microsoft Security Research (Uri Oren, Dor Edry) published on 2026-11-17 a lab proof of concept showing how OAuth device authorization (device code) phishing can be turned against AI coding agents. The device flow lets a client without a browser obtain a token after a user enters a short code on the service's real verification page. In the lab the attacker started a device-code sign-in using the Copilot CLI public client (any public client supporting the device flow would work), chose the requested scopes (repo, read:user, read:org, gist, codespace), and sent the victim the short code plus the genuine GitHub verification link under a pretext such as an IT request or a Copilot license check. Because the page is genuinely hosted by GitHub and the authorization appears under a legitimate application name, neither the domain nor the app name reveals who initiated the request. Once the victim approved, the attacker's client signed in automatically and operated within the granted permissions.

Microsoft analyzed four outcomes, each dependent on account permissions, enabled features and organization policy. (1) Remote steering: when remote control is enabled for a session, allowed by org policy, and the interactive session is active and online, the attacker can steer it; commands run on the victim machine subject to session approval prompts and local OS permissions. This is misuse of an authorized feature, not unauthenticated remote code execution. (2) Copilot Memory poisoning: misleading entries can be added through the agent's /memory command, can influence later interactions and outlast the sign-in; disabling memory does not delete existing entries. (3) Cloud session exposure: where cloud session storage is enabled, synced Copilot CLI sessions (including older ones) were readable and may hold code snippets, file paths and architecture discussions. (4) Private repository access follows the account's repository permissions and can expose application code and infrastructure definitions.

The post maps the PoC to MITRE ATT&CK T1566.002 (Spearphishing Link) and T1528 (Steal Application Access Token). It references earlier device code phishing campaigns (Storm-2372, an AI-enabled campaign in April 2026, and EvilTokens) but states the Copilot CLI outcomes were not seen in them. Microsoft Defender XDR provides two detections, 'Suspected GitHub Copilot CLI device code phishing via email' and 'via Microsoft Teams', which require the GitHub Enterprise Cloud connector in Defender for Cloud Apps and correlate suspicious messages and clicks with GitHub OAuth token creation and regeneration events; for GitHub Enterprise Managed Users a disruption action can suspend the managed identity through the IdP (validated in the research environment only). No CVE, CVSS score, attributed actor or network IOCs exist for this research; severity is an analyst estimate. The IOC list therefore contains documented protocol endpoints, scope strings and behavioral indicators useful for hunting, not attacker infrastructure.

## MITRE ATT&CK

- T1566.002 Spearphishing Link
- T1204.001 Malicious Link
- T1528 Steal Application Access Token
- T1550.001 Application Access Token
- T1078.004 Cloud Accounts
- T1059 Command and Scripting Interpreter
- T1213.003 Code Repositories
- T1530 Data from Cloud Storage
- T1565.001 Stored Data Manipulation

## Free detection (Splunk SPL, Microsoft KQL, Sigma)

**GitHub Copilot CLI OAuth Grant With Broad Scopes (Device Code Phishing Exploitation)** (`TL-2026-6261-SPL-001`)

Behaviour-first detection for TL-2026-6261 (T1528 / T1550.001 / T1078.004). In Microsoft's lab, the victim approves an attacker-initiated GitHub device code and the attacker's client receives an OAuth token for the GitHub Copilot CLI app with scopes repo, read:user, read:org, gist and codespace. The authorization shows under a legitimate app name on the genuine github.com verification page, so the GitHub audit log event for the OAuth grant is the reliable server-side signal. Alerts when a Copilot app authorization carries at least three of repo/read:org/gist/codespace so analysts can confirm with the user that they started the sign-in themselves.

- **Languages:** Splunk SPL, Microsoft KQL, Sigma
- **ATT&CK:** T1528, T1550.001, T1078.004
- **Data sources:** github_enterprise_audit_log (index=github, sourcetype=github:cloud:audit), defender_for_cloud_apps_github_connector (CloudAppEvents)
- **Severity:** high
- **Confidence:** high

### Splunk SPL

```spl
index=github sourcetype="github:cloud:audit" earliest=-24h (action="oauth_authorization.create" OR action="oauth_access.create" OR action="oauth_access.regenerate")
| eval app=lower(coalesce(application_name, oauth_application_name, "unknown"))
| where like(app, "%copilot%")
| eval scopes=lower(mvjoin(coalesce(token_scopes, scopes, ""), ","))
| eval scope_hits=if(match(scopes, "(^|[^a-z:_])repo([^a-z:_]|$)"), 1, 0) + if(like(scopes, "%read:org%"), 1, 0) + if(like(scopes, "%gist%"), 1, 0) + if(like(scopes, "%codespace%"), 1, 0)
| where scope_hits>=3
| stats count earliest(_time) as first_seen latest(_time) as last_seen values(action) as actions values(scopes) as granted_scopes values(actor_ip) as src_ip values(user_agent) as user_agent by actor, app
| convert ctime(first_seen) ctime(last_seen)
```

### Microsoft KQL

```kql
CloudAppEvents
| where Timestamp > ago(24h)
| where Application =~ "GitHub"
| where ActionType in~ ("oauth_authorization.create", "oauth_access.create", "oauth_access.regenerate")
| extend Raw = parse_json(tostring(RawEventData))
| extend AppName = tolower(coalesce(tostring(Raw.application_name), tostring(Raw.oauth_application_name), "")),
         Scopes = tolower(tostring(Raw.token_scopes)),
         Actor = coalesce(tostring(Raw.actor), AccountDisplayName)
| where AppName has "copilot"
| extend ScopeHits = toint(Scopes matches regex @"(^|[^a-z:_])repo([^a-z:_]|$)") + toint(Scopes contains "read:org") + toint(Scopes contains "gist") + toint(Scopes contains "codespace")
| where ScopeHits >= 3
| summarize FirstSeen = min(Timestamp), LastSeen = max(Timestamp), Events = count(), Actions = make_set(ActionType), SourceIPs = make_set(IPAddress) by Actor, AppName, Scopes
```

### Sigma

```yaml
title: GitHub Copilot CLI OAuth Authorization With Broad Scopes (Device Code Phishing)
id: 3f2b8a64-6c1e-4d0b-9a57-1e4c7d2a9b10
status: experimental
description: Detects creation or regeneration of an OAuth authorization for a GitHub Copilot application carrying the repo, read:org, gist and codespace scope set used in the Microsoft device-code phishing lab (TL-2026-6261). A phished victim approving an attacker-initiated device code produces this audit event under a legitimate application name.
references:
    - https://www.microsoft.com/en-us/security/blog/2026/11/17/the-risks-of-device-code-authentication-for-ai-coding-agents/
    - https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps
author: Threadlinqs Team
date: 2026-11-17
tags:
    - attack.credential-access
    - attack.t1528
    - attack.defense-evasion
    - attack.t1550.001
    - attack.initial-access
    - attack.t1078.004
logsource:
    product: github
    service: audit
detection:
    selection_action:
        action:
            - 'oauth_authorization.create'
            - 'oauth_access.create'
            - 'oauth_access.regenerate'
    selection_app:
        application_name|contains: 'copilot'
    selection_scope_repo:
        token_scopes|contains: 'repo'
    selection_scope_org:
        token_scopes|contains: 'read:org'
    selection_scope_gist:
        token_scopes|contains: 'gist'
    selection_scope_codespace:
        token_scopes|contains: 'codespace'
    condition: selection_action and selection_app and 3 of selection_scope_*
falsepositives:
    - Developers legitimately signing in to Copilot CLI with the default broad scope set
    - Onboarding waves for new engineering hires
level: medium

```

**Known false positives:**

- Developers legitimately signing in to GitHub Copilot CLI who started the device flow themselves
- Mass onboarding of engineers to Copilot CLI producing many grants with the default scope set

**Tuning notes:** Confirm the field names in your GitHub audit ingestion (application_name, token_scopes, actor_ip) and adjust the coalesce lists. Raise or lower the scope_hits threshold, allowlist actors during planned Copilot rollouts, and enrich with the user's recent email/Teams link clicks (see TL-2026-6261-KQL-003). Audit log streaming must be enabled for GitHub Enterprise Cloud.

### 8 more detection rules (Splunk SPL, Microsoft KQL, Sigma), unlock with TL Creds

- User Click On GitHub Device Verification Link From Email Or Teams (Device Code Lure) (locked: unlock with TL Creds)
- Copilot CLI Agent Spawns Shell With Credential Or Exfiltration Commands (Remote Steering) (locked: unlock with TL Creds)
- Device Code Link Click Followed By GitHub OAuth Token Creation (Phish-To-Token Correlation) (locked: unlock with TL Creds)
- Device Code Lure: GitHub Device Verification Link Delivered By Email Or Teams (locked: unlock with TL Creds)
- Copilot CLI Local State Tampering By Non-Agent Process (Memory/Instruction Poisoning Heuristic) (locked: unlock with TL Creds)
- Unexpected Client Initiating GitHub OAuth Device Flow (Device Code Tooling) (locked: unlock with TL Creds)
- OAuth Token Mass Private Repository Clone/Fetch (Post-Exploitation Repo Access) (locked: unlock with TL Creds)
- GitHub OAuth Token Activity From Previously Unseen IP (Attacker Client Using Phished Token) (locked: unlock with TL Creds)

Sign up free to unlock the detection rules: https://threadlinqs.com/?modal=signup

## Sample indicators (1 of 9)

Defanged, TLP:CLEAR.

- Domain: `github[.]com`

Full set of 9 indicators unlocks with TL Creds: https://threadlinqs.com/tl-creds

## Sources

- [The risks of device code authentication for AI coding agents (Microsoft Security Blog)](https://www.microsoft.com/en-us/security/blog/2026/11/17/the-risks-of-device-code-authentication-for-ai-coding-agents/)
- [Storm-2372 conducts device code phishing campaign (Microsoft)](https://www.microsoft.com/en-us/security/blog/2025/02/13/storm-2372-conducts-device-code-phishing-campaign/)
- [AI-enabled device code phishing campaign, April 2026 (Microsoft)](https://www.microsoft.com/en-us/security/blog/2026/04/06/ai-enabled-device-code-phishing-campaign-april-2026/)
- [Unmasking EvilTokens: getting to the root of device code phishing (Microsoft)](https://www.microsoft.com/en-us/security/blog/2026/09/22/unmasking-eviltokens-getting-to-the-root-of-device-code-phishing/)
- [Disrupting EvilTokens: the AI chatbot built for cybercrime (Microsoft On the Issues)](https://blogs.microsoft.com/on-the-issues/2026/09/22/disrupting-eviltokens-the-ai-chatbot-built-for-cybercrime/)
- [Authorizing OAuth apps - device flow (GitHub Docs)](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps)
- [Authenticating GitHub Copilot CLI (GitHub Docs)](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli)
- [About remote control of Copilot CLI sessions (GitHub Docs)](https://docs.github.com/copilot/concepts/agents/copilot-cli/about-remote-control)
- [Copilot CLI session data / cloud sync (GitHub Docs)](https://docs.github.com/copilot/concepts/agents/copilot-cli/chronicle)
- [Managing Copilot Memory as an administrator (GitHub Docs)](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/copilot-memory/manage-as-administrator)
- [Reviewing your authorized OAuth apps (GitHub Docs)](https://docs.github.com/en/apps/oauth-apps/using-oauth-apps/reviewing-your-authorized-oauth-apps)
- [Protect your GitHub Enterprise environment (Defender for Cloud Apps)](https://learn.microsoft.com/en-us/defender-cloud-apps/protect-github)
- [Configure Safe Links policies (Defender for Office 365)](https://learn.microsoft.com/en-us/defender-office-365/safe-links-policies-configure)
- [Manipulating AI memory for profit: the rise of AI Recommendation Poisoning (Microsoft)](https://www.microsoft.com/en-us/security/blog/2026/02/10/ai-recommendation-poisoning/)

## Full data

The other 8 detection rules (Splunk SPL / Microsoft KQL / Sigma) unlock with TL Creds; a free account includes daily creds: https://threadlinqs.com/?modal=signup
Indicator values unlock with TL Creds, at a lower price on Red and Purple; AI agents can query rules and IOCs through the Threadlinqs MCP server (Purple): https://intel.threadlinqs.com/mcp

Canonical: https://intel.threadlinqs.com/threat/TL-2026-6261
