Device code flow is a legitimate Microsoft OAuth mechanism designed for devices without keyboards or browsers — meeting room hardware, smart TVs, IoT devices. The flow generates a short code and asks the user to visit a Microsoft URL on a separate device to authorise access.
Attackers have weaponised this into a phishing technique: they initiate a device code request, then send the victim a convincing email or Teams message prompting them to enter the code at the legitimate Microsoft sign-in page. When the victim enters it, the attacker receives a fully authorised access token. No password is captured. No MFA challenge is sent to the attacker. The victim has just handed over their Microsoft 365 session.
This is particularly dangerous because the attacker ends up with a long-lived refresh token that persists until it expires or is revoked — giving ongoing access to Exchange Online, SharePoint, Teams, and connected apps without any further interaction from the victim. For most Microsoft 365 tenants, device code flow is not needed for day-to-day user activity. Blocking it closes a high-value phishing path at low operational cost.
Some environments have legitimate device code flow requirements:
Exceptions should be restricted to specific service accounts or named device principals wherever possible, not applied as broad user exclusions. A report-only Conditional Access policy will identify who is currently using device code flow before you enforce the block.
After enforcing this control, review these related areas: