
Principal Identity Security Researcher
Microsoft
To announce a very special speaker, well known as the author of the powerful AAD Internals tool and now Principal Identity Security Researcher at Microsoft, Nestori Syynimaa. Welcome to the stage to tell us about deep dive into Entra ID token theft protection. Okay. Hey everybody. Nice to to be here and thanks for joining the session. So some deep dives, quite many things I am going to talk about today is already covered by others slightly, and now we are going to go to the deep dive thing. So I am going to cover these things, so basically, first about what kind of token based authentication attacks we have, and then I'm going to drill down to token theft attacks, and then three scenarios how we can mitigate those attacks. So let's start. So who am I? I'm doctor Nestori Syynimaa, also known as DrAzureAD. And as mentioned, I created the tool AAD Internals, which is right there. Who has used that? Okay. Quite many. And what I do for a living? So I'm living my dream, so I'm a researcher, I can try to break stuff, and I can do that at Microsoft now, so I'm doing that a lot, but I I can't talk about that publicly that much anymore. But Okay. That is not changing. Oh, that's better. Okay. And basically, so my job is to find things before bad guys do, and then nowadays I'm building detections for those, so that my job is to keep you safe, so you are most welcome. Past year, I had a tour that was not in the US, so I had like 11 talks in three continents, and this is my 4th in Germany in a year, so I've been quite busy. I even had a tool shirt. And if you want to know more, you can use that one. It's recrawling, so don't do that. And when you travel a lot, many things can happen. This happened in Black Hat Asia in 2024, but that was just 5 minutes before the talk, so I survived from that. Okay. So let's move on. So let's start with token based authentication attacks, and and let's start with key concepts I'm using in this presentation. So first, we have a user or app, or nowadays agent, and that guy, let's use that word, so they are consuming services. Then we have service providers who are providing services. Right? And the 3rd role is identity provider, which is providing access and identity management services. So now how the cloud works, so that you know kind of like what I'm talking about here. So we have the user, let's say Nestori , and the user wants to use something. So let's say that I have an Outlook client and I want to use XS Online. So I need to go to identity provider and prove her identity. And the identity provider doesn't know anything about me, so I have to tell everything. So I tell who I am, I prove my identity, let's say, username and password or maybe some passkey or whatever. It depends on how you configure that. And then what happens is that identity provider creates you an access token, and then with that access token, you go to the service provider and say that, okay, this isn't my token, and I want to use the service. Now, the service provider doesn't know anything about you, just the token. So whatever is inside the token tells who you are and what you can do in that service provider. So that's how simply cloud works. And nowadays, the identity is the new security perimeter, so hackers don't break in their login because there's no, like, let's say, server room that you need to enter. Cloud is out there, so you can just connect to cloud. And what that means, if you look at the numbers, so I heard that you have seen these kind of slides already. So this is from our, what's that called, digital defense report from 2024. And you as you can see, only one percent is not password related attacks. And password related attacks means like brute forcing or password spraying, phishing, that kind of things. But this is from the last year. Now password attacks is 97%, and three percent is something else. And the token theft is the most important one. And then we have things like adversary in the middle and then infrastructure. But why the number has raised that much? So actually, the attacks against infrastructure, which means basically, like your On Prem environment or hybrid environment, that has raised 8 times in the past 2 years. But why? Because you guys have been listening what I we have been telling you that use MFA and that kind of thing, so it's not that easy to do the password attack. So attackers need to go hybrid or they need to steal the token. So that's the only way that you can actually get in. Okay. The second quote from our vice president and security follow fellow. So basically, what Tony is trying to say here, that's at least how I understood that, is that attackers are trying to get to the whatever their end goal is and try to find all the ways that they can use to get there. And defenders are thinking that, okay, I'm just not going to block the firewall, and or apply this policy or so on. So this means that you need to also know those attack paths, otherwise you can protect against them. Okay? So that's why we have graphs. And speaking about graphs, so I'm Doctor. Nestori because I am an am an actual doctor, and I do like a proper scientific research every now and then. And this is like I made a nice research about using graph theory to find attack paths to pass through authentication. And I submitted the paper, and when you are doing like this scientific research, the reviewers are like, well, it's double blind, so you don't know who are your reviewers, and they don't know who they are reviewing. And the first reviewer said, oh, this is a very nice paper. No need to taste anything, just it's good as good as just like it is. The second reviewer said that, okay, so where's the graph theory and the graphs in the paper? I was like, okay, and that was just the first question. He had a lot of questions. But it got accepted anyway, so this is a graph. It's scientifically proven that that is a graph. So I'm using that now. So basically, with token based authentication attacks, there's two things that you can do. So if you have access to secrets, so what does that mean? So basically, like if you are using ADFS to sign tokens, and I think Eric mentioned the incident we had with the actor a couple of years ago, where they were able to get our token signing keys or they were able to sign tokens. So you can steal secret, and then you can forge tokens, and then you can be anybody, and then you can just use the token. If you don't have access to secrets, you can steal the token. So that's basically all you can do, unless you are Dirkjian. So then you can port tokens. And this is the incident from the from the last summer. So whenever you see Dirkjian, just buy him a glass of wine because he saved us, because that's what what he found allowed him to access any tenant in the world. It's a very big big thing. And I have some links to the attack, migrate attack, so you can go and click and see the details of those. Okay. But now, we today, we are going to talk about token theft. So let's talk about that. I also have some demos, so let's see how how this work. So let's start with adversary in the middle attack. A couple of questions, you already mentioned that, but basically, it goes is that, usually, when you go and authenticate, you go to, for instance, to Entra, you go to login. Microsoftware.com, but in this case, you don't, so they will send you a link that looks like a similar, but it's not. And instead, it goes to something like Yield Sync, for instance. And when you log in, it is proxying stuff from Entra, so it looks like your own login page. But when you give your credentials, they will steal those, and also the tokens, whatever comes back from from Entra. Anybody wanna see demo about that? Okay. Let's do this then. So here we have a attackers machine. Oh, by the way, I just prepare for the later demos. Okay. So we have evil things. K. Let's make it a little bigger. K. Lures get no. Sorry. Lures get URL number zero. So here we have a URL that is almost similar. So just one always replaced with a zero. Okay? And then it doesn't matter how you deliver this to to the to the victim, but here is our victim. Opens the browser. Okay. Open. You can paste the URL, and then we're gonna go and try to log in. Okay. So it looks like a let it like a sign in page. You just log in, And let's try again. Okay. That's better. Then the password, like this. And I don't want to show my real password, so it just says like, hello, Frankfurt. So But anyways, what happened now is that when because my username and password were given in the attacker controlled like page, they were able to steal that. They were if I would have given my real password, they would have also got all the access tokens and system cookies and that kind of things. Okay. So let's continue. Okay. My presentation view doesn't work that well now, so just a second. And try again. Okay. That's better. Okay. So that's what I showed you was an adversary in the middle attack, and that we sometimes call like network based attacks. But there's another option, so you can go and you can compromise user's computer, and then you can steal stuff from there. What you can steal is that if you don't have a TPM and you have admin permissions, you can steal the identity of the device. And with that, along with user's identity, you can create PRTs and so on and so on. But if you don't have admin permissions, you only have user permissions, you can still get stuff. So you can have like for instance, the ESTS authentication cookie, which is basically single sign on cookie to login. Microsoftware.com. Or you can steal PRT cookie or you can steal tokens. And what kind of tokens we have? We have the primary reference token, that is the most important one. And if you can steal the session key, then you can be the user and the re devise where you steal that. But that, again, it means that you need to have admin permissions and no TBM. And then we have a refresh tokens and access tokens that only requires user permissions to do that. So let's see how that works. So second demo. So I go back to the victim's computer. Just now close that. Start another session, and then I'm gonna hit the hacker button, so F12. So we have developer tools, then I go to Outlook. Okay. So let's sign in. Yeah. Actually, funny thing about this window, I don't know if you heard about that, but somebody said that there's the two biggest lie in Entra. Don't show this again and stay signed in. It's not true, but it's funny. Okay. So now, let's go here. So I type here bearer, e y stands something. So now here we have a token that we can use. So we can just copy this, and let me show it to you. Like, a k m s or circle j w e j w t. Yeah. So we can just paste it, and it shows you that this access token is for Graph API, and it's for Outlook web app, and that's the guy, so Diego Sisiliani. So now, when I have this token, I can go and access Graph API as that user. So this token is good for one service, one resource, and for one hour, roughly. But now, if we go back here and let's say ESTS out resistant, so let's try that. So let's go here and where it is here. So now if I copy this one, let's see if it work. And I go to to attackers machine. Just a second. There you go. So get a a d in access token for teams, for instance, and I can provide the yesterday's old cookie. And I think I was missing one from the start. And now when I have this cookie and and hopefully it works, it didn't. So ok. So there's something so I either didn't copy it correctly or let's try another one from here. Because this worked earlier when I tried that today, so bear with me. Like that. No. Not now it's better. So basically, when you have that ESTS auth cookie, you have a single sign, you have logged in to that Entra ID, that user, so that's much more powerful. And again, trust user. Nothing nothing special. So whenever you leave your computer at your work, lock it. Otherwise, your coworker can come there, steal your SDS cookie, and be you. Okay? That's not nice. Okay. So kind of to sum up, so token theft attack graph. So we have two options. So do you have access to endpoint? If you do, do you have admin permissions? If you do, you can install malware, you can steal secrets and some secrets. So if you don't have that TPM and so on, then you can acquire tokens and then use them. If you don't have admin permissions, just steal tokens, what you have there, use them. And if you don't have access to endpoint, you can use adversarial middle kind of attacks. And there we have those things. So now, the three security best practices we have against token theft attack. Rum answered three four out of three. So I have only three, you have you got four. So we have the Conditional Access policies, the point of this is trying to ensure that the tokens are issued only to a safe devices from trusted networks and so on. Then we have the token binding, and the purpose of token binding is to bind the token to the device, so if it's stolen, it doesn't work. Well, we'll see how that really works. The wording might be a little bit different here. And then we have the continuous access evaluation, that tries to make sure that the session is safe, which you have. So let's start with conditional act policies. So how this works? So you go to Entra, you say, I'm Nestori, I'm using this device, blah blah blah, and then conditional act policies are evaluated. You may be required to use MFA or certain kind of strong authentication method, but anyways, after you pass that, you have the token. So you have now done all the authentication stuff, and you have the token that says that you used MFA or whatever, and then you can access the thing. And as long as the access token is valid, so it expires, I think nowadays about in 90 minutes or so, so you can use that. Regardless, do you reset the user's password, it still works because it's valid. Okay. So conditional access policies may protect you against adversary in the middle attacks. And why may? Anyone? Because we don't know how you configure that. So it's up to you. So you can mess your configuration. Okay. So demo for that then. Okay. So let's see how we can block the adversary in the middle attack. So we go to Entra, security, protect, control access. Come on. Come on. And policies. It's always too challenging to have live demos because we don't know how the network works. I was in the hacker conference in Belgium in September, and everything worked just fine before the talk, but then when hackers came to the room, it didn't. And I have a recording of that, so it's actually quite funny to try to do that. So require compliant device from Diego. And let's just turn it on. K. And now we can go back here. But before that, I'm gonna go here and move the window so that you don't see my password because that's also what I did in hacker conference. They saw my password. Okay. So now let's close this one and go to log in to that site. So this is the phishing link like that. Maybe I should move a little bit. Better. Okay. I don't know why it's doing this, so it's it's the evil things, not me. Okay. Now the password. So now let's use the let's use the correct password this time. Yeah. But anyways, it says that you can't get there from here because, you know what? The evil things that is controlled by the threat actor is not compliant according to my policies. So that's why that's why it's but but but interesting to see that Microsoft noticed that this is something bad. So so I need to update my demo domain. Okay. Let's move forward. So next, about token protection. So so I noticed that the more the content there is on the screen, the brighter that is. So let's just put it all there. So basically, what this means that it's supported by certain applications. So so what we have here, it says online teams and so on, and you need to have at least Windows 10, it'd be joined and so on. And how you configure this, that you create a conditional access policy where you enforce the token protection. And there's a lot of stuff here that it says, but basically, the purpose is that it will bound the tokens to the device. So what does it really do? So because it it doesn't bound at least all the tokens, so just one actually. So you go to Entra, and when the token protection is required, the client knows that because Entra says that, okay, you need to use token protection. Okay? So now your client goes to Entra and prove the identity. And how do you prove that? There's a JWS or JSON Web Signature Token that has a PRT. It has a client ID which you want to use, so Outlook, and the destination like IXYS Online, and then that's signed with the session key. And then what comes back is access token and refresh token, but they are in encrypted container, so j JSON web encryption, so JWE. And they are encrypted with the session key, which means that if you have like a manual middle attack, what do say, the middle attack, the attacker can get those but doesn't do anything with this because they are encrypted. So you need to have like a the session key so that you can decrypt them. So and that happens on the client, so they are decrypted. But then after that, they are plaintext in memory. So whenever, like, I was using Outlook, for instance, so if we enforce token protection for there, I can still steal those access tokens from the endpoint. So they are not protected there, but they are protected on transit. So token protection prevents adversary in the middle attacks. So that's where you can help or token protection helps. But if the threat actor is able to install malware, token protection doesn't help because after authentication has happened and you have the access token, you can still steal those and use them somewhere else. Okay. Pepsi time. Okay. Then to continue to access evaluation or CAE, I just call it CHI. And what does this do? So basically, again, you need to have a supported client and also the resource. So currently, we support like Exchange Online, SharePoint Online, and Teams for this. And you also need to have your supported clients, so not everything works. And you can customize this with CondisLax policy. You cannot sorry. You can disable that or you can enforce, like Ruh said, that strict IP address, for instance. So if you go to outside of that certain IP address space, you won't get in. So how this works? So now you go to Entra, and you you are using Outlook, you want to access Exchange Online, so you tell that to Entra. But again, if you remember from the start, Entra doesn't know anything about you. So how Entra knows that you are using a client that should use CAE or CHI? So that client tells that to Entra. So it adds some claims there, so xmscc equals cp1, which stands for capability one, I don't know what that means, but it's a sales enterprise that, okay, now I'm car compatible. Then you will get access token back, and it has also the same information that x m s underscore c c equals c p one. And the lifetime of that token is now for up to 28 hours. So not one hour, but longer period of time. And now, Outlook goes to Exchange Online using this token. And now, because let's let's select Exchange Online. So it is supporting this continuous evaluation. So Entra can send event notifications, so they are near real time. Like for instance, if you, let's say, reset user's password, Entra tells that to Exchange Online, and now Exchange Online knows that, okay, I can't accept this anymore, so I need to ask for another one. So that's how this works. And if there is this kind of event, the token is even though that it's it's valid, so it's not expired, but if there's some kind of event that happens after that token was created, it got gets rejected. So yes. Now okay. No no demo yet, but okay. So the continuous accuracy evaluation that may prevent token replay. Now, why may? Because, again, it depends how you configure stuff, but also it doesn't cover all clients and resources, just only a couple. But this is a safe technology, so you can use that. Now, how threat actors can, however, abuse this? So if they are able to compromise the user's endpoint, they can ask those tokens, even though that you have the TPM, you can can ask, give me your card token, and now that's valid for 28 hours instead of one hour. So that way you can have a much longer access than you normally have. And you can disable this using conditional access policies, but it still creates you those tokens. The lifetime is just one hour. So that's a little bit tricky, Because I'm very bad at KQL, there are other people in the room who can write better, but this can help you detect, so if somebody uses these CARE tokens. But there's a lot of false positives because if it even though that you disable that, you still have those that information, but the lifetime is just shorter. But at least I tried. Okay. So let's see if I can show a demo about this. So let's disable. No. We don't wanna disable that. That was another demo. So we go here. So now what I'm gonna do is that I'm gonna reset password, like, of the user with the same password. So so the token that has the Kai so beforehand, I I acquired two tokens. One is Kai and one is not. And so let's try this SKY one. So this is a real near near near real time in our whatever. So kicks in in a couple of minutes, but you never know. So there should be an error message there. There isn't. So let's just copy this so it's easier. Yeah. Maybe I should have done this earlier, so we don't need to wait. But but anyways, it's nice to see that it should, in a couple of minutes, like a break. But how much do we have time? 5 minutes. Okay. So we can come back here in a minute. So so let's kind of sum up the whole presentation. So those three best practices I told you, so how they actually protect your against token theft. So ADFR is in the middle, so we have CondisLax policies and then token protection, so that helps there. We have CondisLax policies that helps you against acquired tokens. So basically, even though that you are able to steal, let's say, some secrets, like the PRT and session key, you may still have conditional policy that says that you can only log in from certain, let's say, network, so you can prevent that. And then the token usage, pretty much the same that you can no, no, not the same, with continuous access evaluation, that helps, I guess, to replaying those tokens in a certain place. But with these security best practices, there still are open things, so it doesn't this doesn't protect you against malware that is installed on your endpoints. So bring your own device. My personal opinion, don't do that. Rules are the same thing. So and why? The reason is that because you don't know what kind of malware is there. If user brings their own device, you never know. They are not managed by you, so be very careful about that. Okay. Now let's see how our demo goes. Okay. Now there's error message because it's a CHI token. I reset the user's password. Entra told that to Exchange Online, and now Exchange Online knows that, so it doesn't let you get the token. However, the other token that was acquired at the same time, it doesn't have COI, it
As organizations move to stronger authentication methods to combat password-related attacks, token theft attacks—which enable attackers to impersonate users even in environments with strong authentication—are on the rise.
Fortunately, Entra ID has built-in protections, such as token protection and continuous access evaluation (CAE), to mitigate attacks such as Adversary-in-the-Middle (AitM) and malware on the endpoint.
This demo-packed session explains how to use those protections, how they work under the hood, what they protect against, how threat actors can leverage them in specific scenarios, and how to detect such abuse.

Principal Identity Security Researcher
Microsoft
Thanks for subscribing!