NEWNightwatch is live. Autonomous hunting and detection engineering. See how it works →
Back

Nightwatch in Action: How Nightwatch traced a device-code phish that ended on Microsoft's own sign-in page.

Tim Peck

Written by Tim Peck · Director of Threat Research

Nightwatch in Action: How Nightwatch traced a device-code phish that ended on Microsoft's own sign-in page.
Share on social
November 10, 20268 minute read

A device-code attack, usually run as part of a phishing campaign, ends on Microsoft’s real sign-in page. The attacker starts a sign-in on their own machine, receives a short code from Microsoft, and persuades someone to type that code into Microsoft’s device-code page.

When the person finishes signing in with their own password and MFA, Microsoft hands the session’s tokens to the attacker.

This Nightwatch hunt started from a threat intel report on a data-extortion crew that phishes Microsoft 365 credentials and gets around MFA. None of the report’s direct indicators appeared in the environment, so Nightwatch searched for one of the techniques the report described:

… a user using an attacker’s code on Microsoft’s real sign-in page.

Well, it turns out that one PC within an organization had done just that. Its user had followed a PDF lure through a Google Sites page to a look-alike document-sharing site, then entered a code just seconds after the Microsoft page loaded.

No SIEM or EDR alert triggered on the activity, and the sign-in logs couldn’t single it out. The clearest record of the phish was the browser’s own web traffic on the endpoint. The figure below shows how the attack played out and how Nightwatch followed it:


The map groups recorded evidence checks for readability, without claiming exact query timing. Customer identifiers, attacker infrastructure and timestamps are omitted. The footer summarizes follow-up activity described in the last section.


A sign-in that ends on Microsoft's own page

The device code flow exists for hardware without a keyboard, such as conference-room displays and command-line tools. The device shows a code, and the user enters it on another screen at Microsoft's device-login page. Once the code is generated, it stays valid for 15 minutes.

In February 2025, Microsoft described Storm-2372 sending fake Teams meeting invitations that walked targets into entering attacker-generated device codes, then using the resulting tokens to get into their accounts (Microsoft Threat Intelligence). Microsoft recommends blocking the device code flow with Conditional Access wherever it isn't needed (Microsoft Learn).

Phishing kits now package the technique. The Intel Exchange has carried Threat Reports on seven device-code phishing kits in the last 60 days, including ARToken and GhostCode, each with community detections attached.

Defenders usually hunt for it in Entra ID sign-in logs, which record the authentication method each sign-in used. In this environment, the sign-in records Nightwatch could read didn’t carry that method. Everything else looks legitimate: a Microsoft domain, the user’s own MFA and no malware. What gives it away is the order of events on the endpoint, and that is where Nightwatch started looking.

Frame the hunt around the technique

The Nightwatch hunt was initially triggered from threat intel on detections.ai. The intel described a crew that registers organization-specific look-alike domains, runs adversary-in-the-middle phishing kits, calls targets, and uses device-code phishing as one of its ways to get tokens. Nightwatch selected the report for hunting.
The exact indicators came first. Nightwatch searched 30 days of DNS, web and email records for the report’s phishing domains, kit paths, infrastructure address and callback numbers. None appeared, and a pattern search for organization-named look-alike sign-in domains found only ordinary vendor sites. Page source, domain registration records, email bodies and call logs aren’t collected here, so Nightwatch recorded those parts of the report as gaps rather than clean results.

Next, it searched 14 days of endpoint web requests for browsers loading Microsoft’s device-code page.

Follow the browser back to the lure

One PC had loaded it, under a sales user's account. Nightwatch listed every web request and lookup in the hours around the visit and found that SmartScreen had checked a launched file four minutes before the device-code page opened.

Outlook file writes and a line-of-business application filled that listing. Nightwatch kept only browser and Outlook requests from the surrounding minutes, and the path appeared.

The user had opened a PDF lure. Its link led to a Google Sites page, then to a document-sharing page on a look-alike domain, which sent the browser to Microsoft's device-code page. The same Edge process posted a code to Microsoft's device-authorization endpoint 19 seconds after the page loaded.

A later hunt, framed around a public report on the “SkyW4lker” phishing kit, matched the look-alike page's URL to that kit's document-sharing naming pattern.


Tell a phish from an admin

Legitimate device-code sign-ins happen every day. Command-line tools such as Azure CLI and many PowerShell modules print a code in the terminal, and the administrator opens Microsoft’s device-code page in a browser to enter it. A rule that fires on every visit to that page fires on them too.

The month of telemetry held one of each. Web proxy records showed an IT administrator opening the device-code page right after installing PowerShell modules, with no web page leading to it. The sales user reached the same page by redirect, from a PDF, through a Google Sites page and a look-alike document-sharing site.

What came before the page is the tell:

  • What opened the browser. A mail client or PDF reader launching it points to a lure. A terminal session that has just run an admin tool points to an administrator.
  • How the browser arrived. The phish arrives by redirect from a site the organization doesn’t use. An administrator types or pastes the address and arrives with no referring page.

Look for the token

The damage from a device-code phish happens on the identity side, once the attacker holds a token. Nightwatch pulled the cloud-app audit events for the minutes after the code was entered to find which account had signed in and where the token was used.

Routine self-service password resets and authenticator enrollments filled the identity searches. Nightwatch narrowed them to app consents, security-info registrations and resets made for another person's account. Those checks, and the checks of mailbox rules and downloads after the sign-in which didn't settle whether anything followed. Whether the attacker received and used a token is still open, and the finding says so.

Test the scope

Next, Nightwatch searched back a month for any other host reaching the look-alike domain or the Google Sites page. Only the sales PC had.

A later hunt using web proxy records found one other device-code page visit in 30 days. An IT administrator had opened it right after installing PowerShell modules, which fits a command-line admin tool asking for a code.

Nothing unusual ran on the PC or under the user's account in the hours before and after the sign-in, and neither visited the device-code page again. The finding recommended revoking the user's Microsoft 365 sessions and tracing any use of the token.

Turn the finding into coverage

This finding came with a detection proposal to catch this type of attack in the future. Later hunts added variants as new details surfaced and each was tested against retained telemetry before it was offered.

  • The lure sequence. A mail client or PDF reader launches a browser that reaches Microsoft’s device-code page within 15 minutes on the same host. It follows the order of steps rather than any domain, so a kit that rotates its domains doesn’t break it, and an administrator signing in from a terminal doesn’t match it. Across 30 days of the team’s telemetry it fired once, on the sales PC.
  • The code submission. A browser loads the device-code page and the same process posts a code within 15 minutes. It also matches legitimate browser sign-ins, so it suits hunting better than alerting. It too fired once in 30 days, on the sales PC.

Keep watching after the report

Several hunts later, each framed around a public report on a device-code phishing kit or a token-replay campaign, ran across the same sign-in. Each recognized it as already reported, checked it again and added its own detection variant.

A monitoring run the following week found nothing new on the PC. A hunt in early November still lists device-code sign-ins as an open question for the tenant.

Evidence scope

The reviewed material establishes:

• the lure path from a PDF through a Google Sites page and a look-alike document-sharing site

• the device code entered on Microsoft's page by the same browser process

• the absence of a matching alert in the sources and period checked

It doesn't establish that Microsoft issued a token to the attacker, that a token was used, or that any mailbox or file was accessed. It doesn't connect the activity to the crew in the source report, and the telemetry doesn't show whether the PDF arrived by email or not, though it’s the most likely path.

Examine device-code sign-ins in your own telemetry

Nightwatch's Adaptive Threat Discovery searched for one technique from the report after its indicators came back empty, followed the browser back to the lure and forward to the identity records, and kept the question open in later hunts.

The free Nightwatch Risk Assessment includes a 30-day backtest of available telemetry. Use it to examine browser visits to Microsoft's device-code page in your own data.

Talk to us about a free Nightwatch Risk Assessment.

Read more

Subscribe

Stay connected

Join the community that moves faster than the threat.

Subscribe to our newsletter