Endpoint Craft

Device Code Phishing and AI Agents: Closing a Quiet Sign-In Gap

Back to Insights

A legitimate sign-in, used against you

Most phishing defences are built around a simple idea: stop users typing their password into a fake page. Device code phishing sidesteps that entirely. The user signs in on a genuine Microsoft page, completes their usual multi-factor prompt, and hands the attacker a valid session without ever seeing anything suspicious.

Microsoft's security team recently published research showing how this technique extends to AI coding agents, using GitHub Copilot CLI as an illustrative example. The point is not that one tool is flawed. It is that any client using the device code flow can be abused in the same way, and AI tools are spreading across developer and power-user machines faster than most IT teams can track them. If your organisation has not looked at device code authentication yet, now is a good time.

How the device code flow works

The device code flow exists for devices and tools that cannot easily show a browser sign-in: smart TVs, meeting room displays, command-line tools, and headless machines. Instead of signing in on the device itself, the tool shows a short code and asks you to visit a Microsoft sign-in page on another device, enter the code, and authenticate there. Once you do, the tool receives a token and carries on.

It is convenient, and in the right context it is perfectly reasonable. The weakness is that the code is not tied to the person who requested it.

Where the attack fits in

An attacker starts the device code flow themselves, receives a code, and then sends it to a target with a plausible pretext: "enter this code to join the meeting", "verify your access to the shared document", or, in the developer world, "authorise this tool to continue". The victim visits the real sign-in page, enters the code, and approves the prompt. The token goes to the attacker's session, not the victim's.

Because the sign-in page is genuine and multi-factor authentication is completed normally, the usual warning signs are absent. There is no misspelt domain and no strange login page. With AI coding agents, the pretext is even easier, because developers are used to authorising command-line tools this way, and those tools often hold access to source code, repositories, and cloud resources.

Why this matters for smaller organisations

Larger enterprises often have security teams who review sign-in logs and tune policies. Small and mid-market businesses usually rely on a sensible baseline and hope it covers new techniques. Device code phishing is a good example of a gap that baseline policies frequently leave open, because the flow is allowed by default and rarely used by most staff.

The commercial risk is straightforward. A stolen token can give access to email, files, Teams, and potentially developer platforms. That can lead to data loss, invoice fraud, or a foothold for a wider compromise, all starting from a sign-in that looked completely normal.

Practical steps to close the gap

1. Find out who actually uses device code sign-in

Before blocking anything, check your Microsoft Entra sign-in logs and filter by authentication protocol for device code. In many organisations the list is short: a handful of meeting room devices, a few administrators using command-line tools, and perhaps some developers. That list is your exception group. Anything outside it is either unknown or unnecessary.

2. Block the flow with Conditional Access

Microsoft Entra Conditional Access includes an authentication flows condition that lets you block the device code flow. Create a policy that blocks it for all users, then exclude only the accounts or devices with a genuine, documented need. Start in report-only mode for a week or two, review what would have been blocked, and then switch it on. This one policy removes the attack path for the vast majority of your users.

3. Tighten the exceptions you keep

For the accounts that still need device code sign-in, add conditions. Restrict them to compliant devices managed through Intune, to known network locations, or both. Shared meeting room accounts should have minimal permissions and no access to sensitive data. Administrative accounts should never use the flow from unmanaged machines.

4. Bring AI tools under management

AI coding agents and assistants are now part of the endpoint estate, whether or not IT approved them. Use Intune to control which developer tools are deployed, keep them updated, and make sure the devices running them meet your compliance policies. Agree which AI tools are sanctioned and how they authenticate, so developers are not left to work it out themselves.

5. Teach one simple rule

User awareness still matters, but keep it short. The message is: never enter a sign-in code that someone else sent you. Legitimate codes appear on a screen in front of you because you started the process. If a code arrives by email, chat, or message, it should be reported, not used.

6. Watch for the signs

Set up alerts for successful device code sign-ins from users outside your exception group, and for sign-ins from unusual locations shortly after. If you use Microsoft Defender or Microsoft Sentinel, these signals can feed into existing incident workflows rather than creating a new manual task.

Conclusion

Device code phishing works because it borrows a legitimate process and a trusted sign-in page. The fix is not complicated: understand who needs the flow, block it for everyone else, tighten the exceptions, and bring AI tools into the same management and compliance framework as the rest of your devices. For most organisations, that is a few hours of careful work that removes a quiet but serious risk.

If you would like a second pair of eyes on your Conditional Access policies, or help bringing AI tools and developer machines under proper Intune management, Endpoint Craft can review your current setup and put a practical, low-disruption plan in place.

Ready to bring your idea to life?

Get in touch to talk through your goals and find out how Endpoint Craft can help you work smarter, stay secure, and embrace the AI era.

Contact Now →