Threat analysis

The login was real: device code phishing on Microsoft 365

A fake data room asked people to “verify with Microsoft”. They signed in on the real Microsoft page, with MFA, and the attacker still got into the account. We took the page apart: here is how the technique works.

Riccardo Brigatti ·

Illustration: a data room page hands over a verification code; on the real Microsoft device sign-in page, Fency asks “Were you asked to enter a code here?” before the code is entered, and the attacker's device stays out.

The page looks like the entrance to a virtual data room. The heading announces a proposal and an investment opportunity, the layout is Microsoft’s, down to the four-colour logo and a “Secured by Microsoft” badge. To open the documents you have to verify your identity with Microsoft: the page shows a nine-character verification code and a button, “Continue to Microsoft”.

The button opens a Microsoft sign-in window. It is the real one, on Microsoft’s own address. You paste the code, enter your password, approve the MFA prompt, and a spreadsheet opens. Nothing looked wrong, and nothing you typed went to a fake page. Your account now belongs to someone else as well.

We analysed this page this week. The technique is called device code phishing. This post takes it apart: the protocol it abuses, what the lure page does line by line, and what the attacker holds at the end.

The protocol being abused

When you set up a streaming app on a smart TV, the TV shows a short code. You open the service on your phone, type the code, sign in there, and the TV is connected. You never typed your password with the remote.

That is a standard part of OAuth 2.0, the device authorization grant, and Microsoft supports it for devices with no proper browser: meeting-room screens, printers, command-line tools. It runs in three exchanges.

1. The device asks for a code. It sends Microsoft the identifier of the application it claims to be and the access it wants. No secret is required: the applications that use this flow are public clients, and their identifiers are published. Microsoft answers with two codes:

{
  "user_code": "ABCD2EFGH",
  "device_code": "<long secret, kept by the device>",
  "verification_uri": "https://microsoft.com/devicelogin",
  "expires_in": 900,
  "interval": 5
}

The user_code is short because a person has to type it. The device_code is long and never shown: it is what the device will use to collect the result.

2. A person approves. Someone opens the verification address in any browser, on any machine, enters the user code, and signs in with whatever the organisation requires: password, MFA, a passkey.

3. The device collects. Meanwhile the device asks Microsoft’s token endpoint, every few seconds, whether the code has been approved. The answer is “pending” until the person finishes; then it is an access token and a refresh token.

In the attack, the device is the attacker’s server.

  1. AttackerAsks Microsoft for a codeThe attacker's server starts a “connect a device” request and gets a short code back.
  2. AttackerShows the code on a lure pageA fake data room displays the code and asks the visitor to “verify with Microsoft”.
  3. VictimEnters the code at MicrosoftOn the real microsoft.com page, the person pastes the code, then signs in with password and MFA.
  4. MicrosoftMicrosoft approves the “device”The sign-in is genuine, so Microsoft issues tokens to whoever asked for the code.
  5. AttackerCollects the tokensThe attacker's server now holds an access token and a refresh token for the account.
The device code flow as the attacker uses it. The victim never types a password on a fake page.

The weakness is in what the protocol leaves out on purpose. Nothing ties the browser where the code is entered to the device that asked for it: they are meant to be two separate things, possibly on different networks. Microsoft checks that the code is valid and that the person signing in is who they say they are. It has no way to check that this person meant to authorise that device.

Two properties used to limit the damage. The code expires after 15 minutes, and it had to reach the victim somehow, usually typed into an email. The page we analysed removes both limits.

The lure page, taken apart

The page is a single HTML document with about ninety lines of plain JavaScript. Nothing is obfuscated. Read top to bottom, it does five things.

Annotated reconstruction of the lure page: a browser window on a non-Microsoft address shows “Access virtual data room”, a verification code with a Copy Code button, two numbered instructions, a “Continue to Microsoft” button, a “Secured by Microsoft” badge and a Microsoft copyright footer.

The lure page, redrawn from its source rather than screenshotted. The texts and layout are the page’s own; the code shown is made up and the address is defanged.

It arrives with a live code already in it

The user code is written into the page source when the server builds the response. So the attacker’s backend performs exchange 1 at the moment someone opens the link, and the 15 minutes start when the victim arrives, not when the email was sent. The same link works for days and for any number of recipients, each of whom gets a different, fresh code.

The code is a genuine one: it has the nine-character format that Microsoft’s own page checks for before accepting input.

It makes the code impossible to mistype

The page gives two numbered instructions: copy the code above, then click “Continue to Microsoft” and paste it. In practice the person doesn’t need to do the first. Clicking the button writes the code to the clipboard, shows a “Code copied to clipboard!” notice styled like Microsoft’s, and waits 800 milliseconds so the notice is seen. Clicking the code itself does the same.

By the time the Microsoft page appears, the only thing left to do is paste.

It opens Microsoft in a popup, through its own domain

The button doesn’t link to Microsoft. It opens a 520 × 680 window on a path of the attacker’s own domain, /ms_auth_redirect, which then sends the browser to Microsoft’s device sign-in page.

The extra hop gives the attacker’s server one more event to record, the click, and a place to change the destination without touching the page. The page also instructs the browser to send no referrer, so the sites it leads to are not told where the visitor came from.

The popup matters for a second reason: the lure stays open underneath, and keeps running.

It watches the sign-in from the outside

While the victim signs in, two polling loops run. The attacker’s server is doing exchange 3 against Microsoft. And the lure page asks the attacker’s server, every second and a half, how that is going. Shortened and commented:

// The lure keeps asking its own backend: has the victim finished signing in?
var pollInterval = setInterval(function () {
  fetch('/poll_status?code=' + userCode)
    .then(function (res) { return res.json(); })
    .then(function (data) {
      if (data.status === 'authorized') {
        // Tokens issued: close the Microsoft popup and send the victim to a decoy document.
        authPopup.close();
        clearInterval(pollInterval);
        window.location.href = redirectUrl;
      } else if (data.status === 'blocked' || data.status === 'failed') {
        // The sign-in was refused or the code expired: close the popup and stop.
        authPopup.close();
        clearInterval(pollInterval);
      }
    });
}, 1500);

The user code doubles as the session key: it is the only thing the page sends, and it is enough for the server to find the matching device code and its state.

The three answers are worth a look. authorized and failed are what any implementation of the flow would have. blocked is a separate state, which suggests the backend reads the reason Microsoft gives when it refuses, and tells apart a code that ran out from a tenant whose policy doesn’t allow the flow. For an operator running this at scale, that is a list of which organisations are worth another attempt.

It ends with a real document

On authorized, the page closes the popup itself and sends the browser to a real Excel file hosted on a legitimate SharePoint tenant, probably a compromised one. The victim asked for a document, signed in to Microsoft, and is now looking at a document on SharePoint. There is no error message, no second prompt, nothing to mention to IT.

What else is in the source

A few details say more about the tool than about this campaign.

  • It is built to be embedded. If the page is running inside a frame, it doesn’t redirect itself: it sends a message to the page that contains it and lets that page do it. The same lure can be dropped into other sites.
  • It has a countdown that isn’t used here. The script includes a timer component, five minutes by default, that this template doesn’t display. Urgency is an option the operator can switch on.
  • It comes out of a page builder. The markup keeps the scaffolding of a visual editor: a canvas container, element-type attributes, a flag marking the block that holds the code. The pretext, logo and colours are template settings.

That structure is consistent with the phishing-as-a-service kits reported during 2026, such as EvilTokens. We can’t say which kit or group is behind this page, and we aren’t attributing it.

Just as telling is what the page doesn’t contain: no password field, no form that posts credentials, no copied Microsoft sign-in page, no download. The things that scanners look for in a phishing page aren’t there, because the phishing doesn’t happen on it.

The Microsoft half

The second page in the chain is Microsoft’s genuine device sign-in page, served from Microsoft’s domain with Microsoft’s certificate. We compared it with a clean copy: it is the same page. It always asks for the code first and the sign-in second, whoever sends you there.

It does carry a warning not to enter codes from sources you don’t trust. The victim reads it immediately after a page with Microsoft’s logo told them that entering this code is how they verify their identity.

After the code, Microsoft shows the name of the application that is asking for access. That name comes from the identifier the attacker chose in exchange 1, and attackers choose Microsoft’s own applications, so what appears is a familiar product name.

Why the usual checks pass

  • The address is right. There is no look-alike domain at the point where credentials are entered.
  • MFA is completed, by the right person. The victim approves their own sign-in. The tokens then go to whoever holds the device code.
  • Passkeys and security keys don’t help. They protect against fake sign-in pages by refusing to work on the wrong site. Here the site is the right one.
  • The email link is clean. It leads to a new domain with no credential form and no malware.

Every control is checking that the sign-in is genuine, and it is. The deception is in what the sign-in was for.

What the attacker holds

Not a password. The attacker holds an access token, good for about an hour, and a refresh token that can keep producing new ones for as long as it stays in use. That is the mailbox, OneDrive and SharePoint, and Teams, from the attacker’s own infrastructure, with no further prompt to the victim.

Which application the attacker impersonated in exchange 1 decides how far this goes. Some of Microsoft’s own clients can trade their refresh token for tokens to other Microsoft services. One, the authentication broker used in the Storm-2372 campaign that Microsoft documented in 2025, can be used to register a new device in the tenant, which gives the attacker a longer-lived credential tied to a device they own.

This is why changing the password is not enough on its own. The sessions have to be revoked, and anything added in the meantime, registered devices, MFA methods, inbox rules, application consents, has to be found and removed.

Where Fency comes in

In cases like this one, Fency recognises the threat and stops it before the code is entered. It also tells the person, in plain words, why it stepped in, so the next request to “verify with a code” is easier to recognise.

Illustration: Fency stands in front of a page that asks for a code and asks “Were you asked to enter a code here?”; a shield stops the sign-in before it reaches the attacker’s device.

Indicators of compromise

For defenders who want to check their own logs. Values are defanged; don’t visit them.

Type Value
Lure domain verifdataroomarchive[.]biz
Path, popup to Microsoft /ms_auth_redirect
Path, sign-in polling /poll_status

See it in your own browser

This attack never asked for a password on a fake page. It needed a plausible document and one pasted code. Book a demo and we’ll show you Fency stepping in on this attack, in your own browser.

Keep reading

See Fency stop this trap.

We'll show the traps from this article being stopped and explained in a real browser.