1 00:00:00,000 --> 00:00:03,400 Next up, I have the pleasure of introducing Dimitri Berioza. 2 00:00:03,400 --> 00:00:10,400 Dimitri is a senior security researcher with Vector AI, where he works on threat detection in cloud and on-prem networks. 3 00:00:10,400 --> 00:00:15,680 His interests include reverse engineering, secure software development, and CTF competitions. 4 00:00:15,680 --> 00:00:29,340 In this talk, we're going to examine logging facilities in Azure, concentrating on events generated by Azure AD and Microsoft 365, where we can discuss multiple problems that he's observed in monitoring them. 5 00:00:29,340 --> 00:00:32,400 So please give a warm welcome for Dimitri. 6 00:00:34,120 --> 00:00:35,220 Thank you. 7 00:00:35,420 --> 00:00:36,660 Thank you, Mike. 8 00:00:39,000 --> 00:00:40,020 Hello, everyone. 9 00:00:40,020 --> 00:00:41,660 Really excited to be here. 10 00:00:44,240 --> 00:00:45,460 Some housekeeping. 11 00:00:45,460 --> 00:00:49,080 The slides, you can just scan the QR code to get the slides. 12 00:00:49,220 --> 00:00:54,640 If we run out of time and there are questions, I'll be happy to discuss things outside. 13 00:00:54,640 --> 00:00:57,420 So I'll just hang around outside the door. 14 00:00:57,420 --> 00:01:06,280 So Dimitri Berioza is my name, and I'll be talking about logs, which are the most exciting topic in cybersecurity. 15 00:01:06,760 --> 00:01:10,580 All right, so Mike already mentioned a few things about me. 16 00:01:10,580 --> 00:01:15,980 There are my handles on Discord, Twitter, and connect with me on LinkedIn. 17 00:01:16,760 --> 00:01:23,100 Before Vector, I worked at IBM as a pen tester, and I come from a software engineering background. 18 00:01:25,120 --> 00:01:26,440 So why this talk? 19 00:01:26,440 --> 00:01:33,720 I currently do security research in the Azure space, and I also respond to incidents that our customers have. 20 00:01:34,060 --> 00:01:40,680 And in that, I concentrate on Azure AD and Microsoft 365. 21 00:01:40,680 --> 00:01:43,360 I'll talk about that a little bit more later. 22 00:01:43,580 --> 00:01:57,740 And in the course of doing that for a few years, I stumbled upon multiple issues that complicate log analysis, that complicate creating automated detection queries, and that's what I'll describe for you today. 23 00:01:57,740 --> 00:02:00,080 It's not an Azure bashing talk. 24 00:02:00,080 --> 00:02:02,360 I love Azure. 25 00:02:03,060 --> 00:02:07,460 And actually, some of the same issues, I think, exist in other cloud providers. 26 00:02:07,460 --> 00:02:14,120 My goal here is to raise awareness for defenders and those on the offensive side, the red timers, pen testers. 27 00:02:14,120 --> 00:02:18,180 And also, hopefully, maybe there's someone from Azure here. 28 00:02:18,180 --> 00:02:19,140 Raise your hand. 29 00:02:19,140 --> 00:02:19,980 No? 30 00:02:20,080 --> 00:02:20,940 Oh, wow. 31 00:02:20,940 --> 00:02:21,300 Okay. 32 00:02:21,300 --> 00:02:22,080 Hello. 33 00:02:22,680 --> 00:02:23,560 All right. 34 00:02:23,560 --> 00:02:26,280 So please pay attention. 35 00:02:28,340 --> 00:02:32,220 So maybe, maybe this will affect some actual change. 36 00:02:32,380 --> 00:02:33,480 Who knows? 37 00:02:33,480 --> 00:02:34,980 Miracles do happen. 38 00:02:35,600 --> 00:02:37,620 And of course, opinions are my own. 39 00:02:37,720 --> 00:02:44,900 My employer just sponsored me to come here, but they don't control the contents of the talk. 40 00:02:44,900 --> 00:02:48,800 So a quick refresher on what Azure is, for those who are not familiar. 41 00:02:49,400 --> 00:02:54,720 I'll speak a little bit about how monitoring was done before cloud and how it's done now. 42 00:02:54,760 --> 00:03:01,780 And actually, the bulk of the talk will be on the problems that I observed and my kind of wish list for what actually should happen. 43 00:03:02,600 --> 00:03:05,600 So Azure, for those who don't know, one of the big three cloud providers. 44 00:03:05,600 --> 00:03:07,260 Actually, I think it's number two now. 45 00:03:07,260 --> 00:03:09,960 They have about a quarter of the market share. 46 00:03:10,680 --> 00:03:13,780 Huge array of services, over 200 now. 47 00:03:13,780 --> 00:03:19,440 It's infrastructure-as-a-service, a platform-as-a-service, software-as-a-service, like the full set. 48 00:03:19,680 --> 00:03:21,280 And it's massive. 49 00:03:21,280 --> 00:03:25,200 It's impossible to talk even about logging in the whole Azure environment. 50 00:03:25,200 --> 00:03:28,400 So I'll just concentrate on Azure AD and Microsoft 365. 51 00:03:28,900 --> 00:03:34,000 So Azure AD, directory and identity management service, really important. 52 00:03:34,000 --> 00:03:35,640 Provides authentication authorization. 53 00:03:35,640 --> 00:03:39,840 So if you want to do anything in Azure, you have to get through that service first. 54 00:03:39,840 --> 00:03:40,820 You have to have an identity. 55 00:03:40,820 --> 00:03:42,520 You have to have certain permissions. 56 00:03:42,520 --> 00:03:51,080 And, of course, they support the whole set of features, Azure, for federation, multi-factor authentication. 57 00:03:51,080 --> 00:03:52,040 You mentioned it. 58 00:03:52,040 --> 00:03:57,340 And has, by what stats are about two years old, almost half a billion daily active users. 59 00:03:57,340 --> 00:03:58,660 So it's kind of a big deal. 60 00:03:59,220 --> 00:04:06,620 Microsoft 365, you're probably familiar with it from back in the Office days, when Office was just on our personal computers. 61 00:04:06,620 --> 00:04:11,060 This is essentially Office in the cloud with a bunch of additions. 62 00:04:11,060 --> 00:04:14,880 So there's also Teams, Exchange Online, Skype, SharePoint, OneDrive. 63 00:04:14,880 --> 00:04:15,960 There's a whole bunch of it. 64 00:04:15,960 --> 00:04:19,600 It's its own big lineup of products. 65 00:04:19,600 --> 00:04:21,240 Also very popular. 66 00:04:21,240 --> 00:04:23,460 I think it's a market leader at this point. 67 00:04:23,640 --> 00:04:26,780 And lots of monthly active users. 68 00:04:26,860 --> 00:04:38,420 So I think if you pick a random person, if they deal with Azure in any way at all, it'll be probably through, well, first of all, through Azure AD. 69 00:04:38,420 --> 00:04:41,180 And most likely they'll have a Microsoft 365 account. 70 00:04:41,180 --> 00:04:43,120 They'll have email hosted in the cloud. 71 00:04:43,120 --> 00:04:45,980 So both of these are really high-profile services. 72 00:04:45,980 --> 00:04:48,860 And this is where it kind of fits in the whole ecosystem. 73 00:04:48,860 --> 00:04:52,560 So Azure AD is a platform-as-a-service service. 74 00:04:52,720 --> 00:04:59,820 And the software-as-a-service Microsoft 365, or Office 365 as it used to be called, is a good example of that. 75 00:05:00,780 --> 00:05:04,640 So event monitoring is based on logs, of course. 76 00:05:04,640 --> 00:05:08,620 Microsoft Sentinel is their native CM solution. 77 00:05:08,620 --> 00:05:14,000 It ingests logs from cloud services, but also can, I think, ingest external logs. 78 00:05:14,280 --> 00:05:16,400 And you can build detections in it. 79 00:05:16,400 --> 00:05:19,000 I think there are a bunch of built-in detections. 80 00:05:19,240 --> 00:05:24,420 There's also something called Azure Log Analytics, which is a great log analysis platform. 81 00:05:24,420 --> 00:05:28,880 You can kind of run ad hoc queries in there and do investigations. 82 00:05:28,960 --> 00:05:31,540 I love Kusto language that they implement. 83 00:05:31,540 --> 00:05:33,440 It's a very powerful query language. 84 00:05:33,440 --> 00:05:39,260 And queries are very, very fast because I think they massively index on the back end. 85 00:05:39,260 --> 00:05:47,100 So it was a breath of fresh air when I could run a query of a massive data set and really get results really quickly. 86 00:05:47,520 --> 00:05:50,040 So logs can be analyzed in Log Analytics. 87 00:05:50,040 --> 00:05:54,660 It can be streamed internally if you have your own CM in your environment. 88 00:05:54,920 --> 00:06:00,000 And third-party solutions that you can buy, they can help you analyze logs. 89 00:06:00,000 --> 00:06:03,900 But they cannot help you produce logs or different logs or better logs. 90 00:06:03,900 --> 00:06:05,180 Microsoft controls that. 91 00:06:05,180 --> 00:06:07,580 And that's kind of part of the problem. 92 00:06:07,800 --> 00:06:13,280 So logs, there are different types of logging available in Azure AD and Microsoft 365. 93 00:06:13,300 --> 00:06:18,040 Azure AD mostly deals with sign-ins, with changes to directory settings. 94 00:06:18,040 --> 00:06:20,700 It's based on a more modern API called Graph API. 95 00:06:20,700 --> 00:06:24,900 I think Microsoft's plan is to migrate all of their services to that. 96 00:06:25,140 --> 00:06:29,000 And it currently exists in base version, in a beta. 97 00:06:29,000 --> 00:06:34,400 I see Microsoft using the beta version in their production products. 98 00:06:34,400 --> 00:06:35,920 And yet it's a beta. 99 00:06:35,920 --> 00:06:37,920 I don't know if they want their customers to use it. 100 00:06:37,920 --> 00:06:39,660 And the schemas are very different. 101 00:06:39,660 --> 00:06:46,060 So it's a bit of a mystery of what the recommendation is for their customers to actually standardize on. 102 00:06:46,060 --> 00:06:50,500 Microsoft 365, kind of a completely different beast in terms of logging. 103 00:06:50,500 --> 00:06:52,500 They have something called Management Activity API. 104 00:06:52,500 --> 00:06:53,980 There are a bunch of logs there. 105 00:06:54,000 --> 00:06:57,640 They're sort of split by general functionality types. 106 00:06:57,640 --> 00:07:01,560 So there's a separate log for Exchange, separate log for SharePoint. 107 00:07:01,560 --> 00:07:06,180 And there's audit general, kind of all other events fall into that. 108 00:07:06,180 --> 00:07:09,380 And I think the plan is to migrate to Graph API eventually. 109 00:07:09,980 --> 00:07:16,800 So if you think back to if you dealt with on-prem networks before, migration to cloud is great. 110 00:07:16,800 --> 00:07:19,540 We get a lot of really neat features. 111 00:07:19,640 --> 00:07:21,860 A lot of things are easier in the cloud. 112 00:07:21,860 --> 00:07:25,400 But when it comes to logging, I think it's kind of a mixed bag. 113 00:07:25,400 --> 00:07:32,140 The problem is that when you control your own environment, when you control your own network, you can set up logging pretty much anywhere. 114 00:07:32,140 --> 00:07:36,400 You could have logging on individual machines, on the edges of your network. 115 00:07:36,400 --> 00:07:38,640 You can put network tabs anywhere you want. 116 00:07:38,640 --> 00:07:40,800 You can go with software. 117 00:07:40,800 --> 00:07:44,340 You can have hardware solutions plugging in, like physical cables. 118 00:07:44,340 --> 00:07:45,800 So you have a lot of choices. 119 00:07:45,800 --> 00:07:48,060 If you don't like one vendor, you ditch them. 120 00:07:48,060 --> 00:07:48,820 You go to another. 121 00:07:48,820 --> 00:07:49,720 No problem. 122 00:07:49,760 --> 00:07:51,740 In the cloud, things are more streamlined. 123 00:07:51,740 --> 00:07:53,800 However, you lose that choice. 124 00:07:53,800 --> 00:07:58,920 So whatever logging you want to have, it only comes from Microsoft. 125 00:07:58,920 --> 00:08:00,880 You don't really have much of a choice. 126 00:08:01,200 --> 00:08:06,420 And if the quality of those logs is great, if everything is really well thought through, perfect. 127 00:08:06,460 --> 00:08:11,140 But unfortunately, if you see issues, you don't have much choice. 128 00:08:11,140 --> 00:08:18,980 You can either migrate to another cloud provider, and it's a huge undertaking, or complain to Microsoft and hope that things get fixed. 129 00:08:18,980 --> 00:08:25,200 Unfortunately, that doesn't happen quickly enough, I guess, when that happens. 130 00:08:25,560 --> 00:08:34,620 So my expectations for log quality in the cloud are such that, first of all, it's easy to consume API, timely logging of events. 131 00:08:34,620 --> 00:08:36,660 The speed is really important here. 132 00:08:36,860 --> 00:08:41,280 Clear and complete documentation for everything that I see in the logs. 133 00:08:41,280 --> 00:08:46,220 I don't want to guess what I'm looking at when I'm analyzing an incident, for example. 134 00:08:46,220 --> 00:08:49,240 All log records should be complete. 135 00:08:49,520 --> 00:08:53,500 And I want the following data consistently available everywhere. 136 00:08:53,600 --> 00:08:56,700 What the operation was and all the corresponding parameters. 137 00:08:56,980 --> 00:08:59,300 All the identity and session information. 138 00:08:59,300 --> 00:09:03,000 I want to know everything about the user that performed that action. 139 00:09:03,000 --> 00:09:08,440 I want full IP information, geolocation, device information, threat and reputation indicators. 140 00:09:08,440 --> 00:09:13,200 They are slowly becoming available, and they really help in incident response. 141 00:09:13,200 --> 00:09:15,160 I also want to correlate between logs. 142 00:09:15,160 --> 00:09:18,700 Somebody logged in, and then they did something in Exchange. 143 00:09:18,700 --> 00:09:20,300 They did something in SharePoint. 144 00:09:20,300 --> 00:09:23,980 I want to connect all the dots there and see the full attack. 145 00:09:24,400 --> 00:09:26,120 That's my wish list. 146 00:09:26,120 --> 00:09:32,980 Unfortunately, that doesn't fully happen to my liking. 147 00:09:33,580 --> 00:09:39,440 Let me run through a big list of things that I see that complicate my work as a defender. 148 00:09:40,320 --> 00:09:45,060 First of all, there are some difficulties in log consumption. 149 00:09:45,220 --> 00:09:52,520 In some of the logs, primarily in Microsoft 365 logs, the schema that you observe is fluid. 150 00:09:52,520 --> 00:10:04,040 Every new event type that you get, if you look at the log as a table, if that new event type has five new fields, you get five new columns. 151 00:10:04,040 --> 00:10:08,160 You can see the log growing not only vertically, but horizontally. 152 00:10:08,160 --> 00:10:13,080 Microsoft itself and Log Analytics may handle it, but actually they don't always handle it. 153 00:10:13,080 --> 00:10:19,100 I've seen this error of limit of maximum 500 columns reached, which is kind of insane. 154 00:10:19,360 --> 00:10:24,180 But if you start to consume these logs externally, it's a big problem. 155 00:10:24,180 --> 00:10:27,380 You need to pick and choose which fields you want to see. 156 00:10:27,580 --> 00:10:34,520 You want to have the foresight to predict what fields you will want to see for this new operation that Microsoft decides to log. 157 00:10:34,520 --> 00:10:36,380 So it's really, really hard to handle. 158 00:10:36,980 --> 00:10:43,060 And also, when you pull on the APIs, you have to be really careful because of delays. 159 00:10:43,060 --> 00:10:45,200 And I'll talk about those further. 160 00:10:45,260 --> 00:10:46,840 Sometimes events come late. 161 00:10:46,840 --> 00:10:51,860 So if you pulled on the log API, you got your logs for today. 162 00:10:51,860 --> 00:10:56,420 Maybe another event is still hanging in there, arrives late. 163 00:10:56,820 --> 00:11:08,680 To get it, you need to call the same API with the same parameters again, and then deduplicate the events to remove the duplicates that you have already seen to get the few events that were late. 164 00:11:08,680 --> 00:11:13,340 So it just adds work to you as a defender. 165 00:11:13,940 --> 00:11:16,020 There are occasionally log flow issues. 166 00:11:16,020 --> 00:11:21,660 In my memory, there were a few log outages there, the ones that were announced. 167 00:11:21,660 --> 00:11:25,740 And one of them that I remember lasted several weeks, and we noticed it just by accident. 168 00:11:25,740 --> 00:11:31,080 So things fell silent, and we didn't have any mechanism in place to actually detect that. 169 00:11:31,080 --> 00:11:34,500 So that was kind of a big problem when you're blind for that long. 170 00:11:34,640 --> 00:11:48,580 Nothing really you can do about it, rather than maybe invest some kind of solution that monitors log flow, and tells you that, oh, you know, this is the normal log patterns, and things all of a sudden have dropped off. 171 00:11:48,580 --> 00:11:49,980 Something is going on. 172 00:11:50,980 --> 00:11:57,420 Also, another kind of, I think, a general issue with all cloud providers, logs are enabled and disabled in band. 173 00:11:57,420 --> 00:12:01,840 So you log in as admin, and you can stop logging. 174 00:12:01,840 --> 00:12:11,840 That's kind of a problem, because if your admin gets popped, as a red teamer, one of the first things to do, I would actually stop logs to blind the security tools. 175 00:12:11,840 --> 00:12:29,080 So I think we need more mechanisms for preventing that, for an event as big as stopping the logs, it has to be more, I guess, difficult for attacker to control that. 176 00:12:29,080 --> 00:12:31,680 And things can actually be changed more stealthily. 177 00:12:31,680 --> 00:12:41,240 You can not only stop logs completely, but stop individual logs, and in exchange, you can stop auditing for specific users. 178 00:12:41,380 --> 00:12:48,140 So as an attacker, you could be selective, and kind of try to stay under the radar. 179 00:12:48,140 --> 00:13:01,320 So the outcome for this, I think defenders just need to pay attention to how their logs are flowing, really pay attention to what events they see that actually trigger log disabling. 180 00:13:01,560 --> 00:13:08,100 And attackers, I think it's a great technique to actually just turn off the logs, even temporarily, to blind the defense. 181 00:13:08,100 --> 00:13:11,840 And Azure just, I think, needs to be aware of this. 182 00:13:12,540 --> 00:13:15,500 So events are also getting delayed. 183 00:13:15,500 --> 00:13:22,100 Microsoft SLA says, I think it's between like 5 and 15 minutes, they pretty much guarantee that you will get events that happen. 184 00:13:22,180 --> 00:13:26,840 Which is also, like 15 minutes is already kind of, you know, it's not very comfortable. 185 00:13:26,980 --> 00:13:31,820 I actually see in Graph API-based logs delays up to 40 minutes. 186 00:13:32,240 --> 00:13:35,640 And in Microsoft 365, sometimes more than 24 hours. 187 00:13:35,640 --> 00:13:38,640 Like if you look, these are recent stats that I pulled. 188 00:13:38,640 --> 00:13:44,380 This is actually one day and 14 hours for this event to arrive in the logs. 189 00:13:44,380 --> 00:13:47,740 Which is just, I don't think this should happen. 190 00:13:47,860 --> 00:13:49,880 Delay really hurts defenders. 191 00:13:49,880 --> 00:13:53,360 You cannot react as it is. 192 00:13:53,360 --> 00:14:04,460 Like even if, let's say, logs arrive in 30 minutes, there were some attackers that are known that actually started doing their work within 30 minutes of the breach. 193 00:14:04,460 --> 00:14:08,700 So you are almost, as a defender, you're almost late by design. 194 00:14:08,700 --> 00:14:16,700 So by the time you see the events, if attacker is, you know, really competent and they have scripted a lot of their actions, they're already done. 195 00:14:16,700 --> 00:14:19,140 You're just, you know, cleaning up and picking up the pieces. 196 00:14:19,320 --> 00:14:31,640 So I think the lesson here is that as defenders, you, I think, need to run, maybe run to some stats to see when, how long it takes for logs to actually get to you. 197 00:14:34,060 --> 00:14:40,100 Attackers take advantage of these delays because I think defenders will be continuously late. 198 00:14:40,100 --> 00:14:43,580 And Azure, I think, should really speed things up. 199 00:14:43,580 --> 00:14:47,200 We need logs to arrive very, very quickly. 200 00:14:47,400 --> 00:14:49,400 There's also something called login tax. 201 00:14:49,400 --> 00:14:59,320 Depending on your level of license that you pay for, you get different, I guess, granularity, different level of security details in the logs. 202 00:14:59,320 --> 00:15:00,180 And that's a big problem. 203 00:15:00,180 --> 00:15:03,580 So you essentially have to pay premium for better security. 204 00:15:03,580 --> 00:15:06,220 There was this great quote from a U.S. 205 00:15:06,220 --> 00:15:13,980 senator that charging people for premium features, necessary not to get hacked, is like selling car and then charging extra for seat belts and airbags. 206 00:15:13,980 --> 00:15:16,300 I completely agree with that. 207 00:15:16,340 --> 00:15:18,240 I understand that Microsoft is a business. 208 00:15:18,240 --> 00:15:19,540 They need to make money. 209 00:15:19,540 --> 00:15:22,560 But this is kind of, I think, a wrong place to make money. 210 00:15:22,560 --> 00:15:25,680 You need to make sure all of your customers are really secure. 211 00:15:25,720 --> 00:15:29,620 And there was a recent incident that really kicked things into high gear. 212 00:15:29,620 --> 00:15:32,000 CISA got involved because a bunch of U.S. 213 00:15:32,000 --> 00:15:35,300 departments got hacked in Azure. 214 00:15:35,320 --> 00:15:43,060 And I think they pushed Microsoft to actually expand access to these types of logs that are not visible to ordinary users. 215 00:15:43,060 --> 00:15:43,980 And that's amazing. 216 00:15:43,980 --> 00:15:45,820 I hope this trend continues. 217 00:15:46,380 --> 00:15:50,780 So for defenders, not much to suggest here. 218 00:15:50,780 --> 00:15:56,000 If things that you want are paid, you have a difficult choice. 219 00:15:56,000 --> 00:16:01,320 You'd have to pay extra or agree with not fully seeing everything. 220 00:16:02,460 --> 00:16:09,580 While these features are still being developed and coming online, attackers can take advantage of some things being hidden from the majority of the customers. 221 00:16:09,580 --> 00:16:14,260 Because not everybody can afford something like $37 per user or something. 222 00:16:14,740 --> 00:16:18,220 It's a big expense to get those extra features. 223 00:16:18,220 --> 00:16:23,120 And Azure, please, don't charge extra for such a basic security feature. 224 00:16:23,120 --> 00:16:28,040 I would say documentation on logs is generally deficient. 225 00:16:28,040 --> 00:16:32,860 The best you can probably hope for is the names of operations that you'll see in the logs. 226 00:16:32,860 --> 00:16:39,340 But if you actually go into the actual log record and start looking at the individual fields, most of them are a mystery. 227 00:16:39,900 --> 00:16:45,740 Individual, let's say, enum values, you get authentication code 278. 228 00:16:45,740 --> 00:16:52,000 And you look online and there's nothing there and you're lost. 229 00:16:52,000 --> 00:16:55,560 You have to hunt through blogs and ask questions and discussion boards. 230 00:16:55,560 --> 00:16:57,120 And this is fine. 231 00:16:57,120 --> 00:16:59,840 I understand that it's just probably part of your daily work. 232 00:16:59,840 --> 00:17:02,100 But as a defender, you shouldn't be doing that. 233 00:17:02,100 --> 00:17:10,320 You should be looking at the logs and analyzing incidents, not digging into all kinds of blogs just to find bits of information. 234 00:17:10,320 --> 00:17:16,280 Microsoft really needs to document everything that they log to help us as defenders. 235 00:17:16,280 --> 00:17:20,560 And attackers, again, any defender's loss is an attacker's gain. 236 00:17:20,560 --> 00:17:25,060 You can't really hide in cases that are not well documented. 237 00:17:25,740 --> 00:17:29,140 I find that Microsoft does a lot of changes that are unannounced. 238 00:17:29,280 --> 00:17:35,540 In my experience, I was at one point monitoring mailbox login events in Exchange logs. 239 00:17:35,540 --> 00:17:37,440 And then all of a sudden they disappeared. 240 00:17:37,480 --> 00:17:40,300 And I noticed maybe several months later. 241 00:17:40,300 --> 00:17:41,760 Because it was just completely silent. 242 00:17:41,760 --> 00:17:43,120 So you have your queries running. 243 00:17:43,120 --> 00:17:44,380 They're not finding anything. 244 00:17:44,380 --> 00:17:47,160 And that's because that event is not logged anymore. 245 00:17:47,160 --> 00:17:56,100 Or I had queries that detected attackers trying to enumerate users coming from the outside of the enterprise. 246 00:17:56,100 --> 00:18:02,620 They would try different combinations of usernames, like a first name, dot, last name, or last name, dot, first name, etc., etc. 247 00:18:02,620 --> 00:18:04,620 They tried those enumeration attacks. 248 00:18:04,620 --> 00:18:05,800 I used to see those logs. 249 00:18:05,800 --> 00:18:06,880 They're gone now. 250 00:18:06,880 --> 00:18:09,380 Again, silently, without announcement. 251 00:18:09,420 --> 00:18:10,900 It's kind of upsetting. 252 00:18:10,940 --> 00:18:13,780 And also we had a case underlined there. 253 00:18:13,780 --> 00:18:14,960 You can see it in the slides. 254 00:18:14,960 --> 00:18:15,900 There's a link. 255 00:18:15,900 --> 00:18:29,480 We documented a case where passwordless authentication, when it was introduced and encouraged, the error codes that you get for that are completely different from anything you got before. 256 00:18:29,820 --> 00:18:30,560 Undocumented. 257 00:18:30,560 --> 00:18:32,460 We discovered them by accident. 258 00:18:33,340 --> 00:18:35,260 Just didn't know how to react to that. 259 00:18:35,260 --> 00:18:39,720 But this is important if you're doing threat hunting and responding to incidents. 260 00:18:40,180 --> 00:18:44,360 So it's really the worst kind of failure when you don't know that you have a problem. 261 00:18:44,360 --> 00:18:53,100 So for anonymous changes, I don't know how much defenders can do rather than just study and continuously look at the logs and learn. 262 00:18:53,100 --> 00:18:54,880 But it shouldn't be this hard. 263 00:18:54,880 --> 00:18:56,740 I think Microsoft can do better. 264 00:18:56,860 --> 00:19:03,080 And again, anything that's difficult for defenders, attackers can put in their TTPs. 265 00:19:03,540 --> 00:19:06,620 So cloud is a recon paradise. 266 00:19:07,020 --> 00:19:11,540 Get type events, when you enumerate something, almost never get logged. 267 00:19:11,540 --> 00:19:16,400 I think it's the same thing in AWS and maybe the same thing in other places. 268 00:19:16,720 --> 00:19:20,740 So when an attacker gets access, they can look around without you noticing. 269 00:19:20,740 --> 00:19:21,920 I actually did an experiment. 270 00:19:21,920 --> 00:19:28,420 I ran a bunch of open source Microsoft 365 Azure AD attack tools, the ones that do enumeration. 271 00:19:28,480 --> 00:19:30,520 Virtually no signal in the logs. 272 00:19:30,520 --> 00:19:36,900 As soon as you try to maybe try different passwords, that's when things start to show up in the logs. 273 00:19:36,900 --> 00:19:38,640 Before that, it's silent. 274 00:19:38,640 --> 00:19:42,940 So if you're a red teamer, have a ball. 275 00:19:43,000 --> 00:19:47,940 As soon as you get in, you're free to look around and not be noticed. 276 00:19:48,040 --> 00:19:52,720 Again, Azure doesn't even give you an option to turn this on. 277 00:19:52,980 --> 00:19:56,000 I'm sure there's some serious reason for not logging them. 278 00:19:56,000 --> 00:20:01,100 Maybe there's space concerns, like the logs will just explode if you log all of these events. 279 00:20:01,100 --> 00:20:06,780 But at least give me an option to turn them on if I'm extra careful in my particular environment. 280 00:20:06,780 --> 00:20:10,320 I may want to actually turn these things on. 281 00:20:11,620 --> 00:20:15,020 There are a bunch of inconsistencies I see in the data that's being logged. 282 00:20:15,020 --> 00:20:22,560 So when you run your detection queries, you have to be really careful to make sure that you kind of clean up, let's say, the IDs that you see. 283 00:20:22,560 --> 00:20:29,340 Because, as you can see, the same user can be logged with different letter case in different log records. 284 00:20:29,440 --> 00:20:32,920 Sometimes the log ID is different altogether. 285 00:20:32,920 --> 00:20:36,600 And Exchange really throws a wrench in the works. 286 00:20:36,600 --> 00:20:42,700 This huge chunk of texture is an actual user ID that gets logged for some of the users. 287 00:20:42,700 --> 00:20:55,020 So you can imagine, if you're investigating an incident and you're trying to consolidate different logs and tell a story of what happened, it's really difficult to connect the dots if you just want to join on username. 288 00:20:55,120 --> 00:20:58,860 There are unique IDs available that you may want to... 289 00:20:58,860 --> 00:21:03,560 It's probably a better way of consolidating, but again, I don't have to discover this. 290 00:21:03,560 --> 00:21:05,880 This really has to be clearly explained to me. 291 00:21:08,180 --> 00:21:11,180 Occasionally things are just missing, not available. 292 00:21:11,560 --> 00:21:15,300 I'll try to go quicker because I think there's a lot more material. 293 00:21:15,300 --> 00:21:17,880 For IP also, lots of inconsistencies. 294 00:21:17,880 --> 00:21:26,300 You usually get the clean IP v4 or v6 address, but sometimes you get IPs logged together with ports. 295 00:21:26,480 --> 00:21:31,300 So you have to call a port number, you have to cut that off to clean things up. 296 00:21:31,300 --> 00:21:38,580 I've seen empty IPs, I've seen local and private IPs, I've seen all zero IPs, I've seen all 255 IPs. 297 00:21:39,080 --> 00:21:43,020 None of this is useful, but we still see that. 298 00:21:43,020 --> 00:21:46,040 So it's hard to deal with. 299 00:21:47,520 --> 00:21:52,260 Geolocation also, it's a useful feature, it's only available in sign-ins log. 300 00:21:52,780 --> 00:21:55,440 Sometimes it breaks, sometimes it's empty. 301 00:21:55,440 --> 00:21:59,380 You can see here the real record that I pulled last night. 302 00:21:59,640 --> 00:22:01,240 Country, state, everything is empty. 303 00:22:01,240 --> 00:22:03,320 So that's not helping everyone. 304 00:22:03,320 --> 00:22:05,360 I understand that geolocation is kind of tricky. 305 00:22:05,540 --> 00:22:10,720 You can be easily fooled, and it does get fooled by Autor, by VPNs, proxies, etc. 306 00:22:10,720 --> 00:22:14,400 But when an attacker is not careful, they're revealing their real location. 307 00:22:14,400 --> 00:22:16,540 It's helpful in this investigation. 308 00:22:16,540 --> 00:22:19,820 So it really has to work consistently. 309 00:22:19,840 --> 00:22:22,200 Device information also hit and miss sometimes. 310 00:22:22,200 --> 00:22:25,440 I think it's mostly grabbed from the user agent, and it's a mixed bag. 311 00:22:25,440 --> 00:22:32,400 You get sometimes a full user agent, sometimes you get pieces of it parsed out, and parsed not always consistently. 312 00:22:32,420 --> 00:22:35,440 So some consistency in all of the logs would be great. 313 00:22:36,120 --> 00:22:39,000 Sometimes you get broken values in the logs. 314 00:22:39,000 --> 00:22:42,600 So as part of your query, you may want to parse a field that's JSON. 315 00:22:43,700 --> 00:22:51,080 I think when things run out of space, you actually get broken JSON, as you can see in this example here. 316 00:22:51,080 --> 00:22:54,020 These three dots is not something you click on to expand. 317 00:22:54,020 --> 00:22:57,480 These are literal three dots at the end of JSON. 318 00:22:57,480 --> 00:23:00,420 And of course, your parser will choke on that. 319 00:23:00,660 --> 00:23:03,220 So something to be aware of. 320 00:23:03,940 --> 00:23:10,200 Again, for all of these, the running lesson is defenders be aware. 321 00:23:10,400 --> 00:23:14,000 Try to factor that in your analysis queries. 322 00:23:14,000 --> 00:23:18,040 Attackers, maybe something to take advantage of, because these are not some fancy zero days. 323 00:23:18,040 --> 00:23:25,780 You could probably add stealth to your actions by just taking advantage of all these little deficiencies. 324 00:23:25,780 --> 00:23:28,220 And Azure, please fix stuff. 325 00:23:28,480 --> 00:23:40,940 All right, so all of this is mostly about log analysis and the signal you see in the logs, but you could actually occasionally be attacked through the logs. 326 00:23:40,940 --> 00:23:44,320 I just want to explain this example here. 327 00:23:44,320 --> 00:23:50,480 So log pollution is a type of attack where attacker controls the content in your log maliciously. 328 00:23:50,480 --> 00:23:58,480 And it could be coupled with something called CSV injection, which is an Excel formula you could embed in a CSV field. 329 00:23:58,480 --> 00:24:05,700 And because most of us open CSVs in Excel, Excel actually interprets those formulas and executes them. 330 00:24:05,700 --> 00:24:09,280 And sometimes those formulas can actually run external commands. 331 00:24:09,280 --> 00:24:20,360 So there was a case of log pollution with CSV injection that was documented by Rhino Security five years ago in AWS and Azure. 332 00:24:20,360 --> 00:24:23,300 I think it got fixed since, but I found another one. 333 00:24:23,300 --> 00:24:26,820 And this one is pre-authentication, so I'll just do a demo of that. 334 00:24:26,860 --> 00:24:39,260 So the idea is to get a malicious payload in the logs and social engineer the admin to open the log to get this payload to detonate on their machine. 335 00:24:39,260 --> 00:24:44,220 It's harder to do these days because Microsoft put some defenses in Microsoft Office. 336 00:24:44,620 --> 00:24:54,920 You could do it with the old version of the Office, or you could maybe social engineer admin to drop this particular setting in their Excel. 337 00:24:54,920 --> 00:24:59,860 It's not easy to do, so it's not like a zero-click thing, but it's something to be aware of. 338 00:24:59,860 --> 00:25:06,760 And when I reported it to Microsoft, they didn't seem really excited about it, so I'm just going to tell you guys about it. 339 00:25:08,160 --> 00:25:11,800 So anyway, this is the payload. 340 00:25:11,800 --> 00:25:14,940 You may recognize it as a DDE formula from Excel. 341 00:25:14,940 --> 00:25:18,240 It just pops a calc because we're all white hats here, right? 342 00:25:19,880 --> 00:25:27,020 It attempts to sign in into Azure with an existing account and a bad password, so actually you don't want to log in. 343 00:25:27,020 --> 00:25:32,500 You just want to try to log in with that special user agent field. 344 00:25:32,500 --> 00:25:44,900 And then when a defender, admin, opens the log as a CSV file, if he has the right version of Office, like the old version of Office, or if these defenses are dropped, it will detonate. 345 00:25:44,900 --> 00:25:46,520 So this is the demo. 346 00:25:48,840 --> 00:25:50,220 Takes a bit of time. 347 00:25:54,720 --> 00:26:00,200 So the first step is to override the user agent with an exploit that I just showed. 348 00:26:06,840 --> 00:26:14,340 I think you can do it in pretty much any browser nowadays, or use Zap, or use Burp, it doesn't matter. 349 00:26:25,400 --> 00:26:28,580 So there's a field for user agent. 350 00:26:29,220 --> 00:26:31,260 It's under network conditions. 351 00:26:31,260 --> 00:26:37,780 Instead of using browser default, we use this custom string that we drop in there. 352 00:26:38,760 --> 00:26:45,040 And then, the second step, where we try to log in as an existing user. 353 00:27:00,830 --> 00:27:15,030 So I type my username, and then I intentionally type the invalid password, so that there's just a record of me trying to log in and failing. 354 00:27:15,030 --> 00:27:18,110 But the user agent gets into the log. 355 00:27:18,110 --> 00:27:19,610 So this fails. 356 00:27:19,790 --> 00:27:24,630 Then I call up the admin and say, hello, this is Microsoft support. 357 00:27:24,630 --> 00:27:26,890 I want to help you investigate an incident. 358 00:27:26,890 --> 00:27:29,170 We're seeing something fishy in your system. 359 00:27:29,170 --> 00:27:30,990 Can you please pull up the logs? 360 00:27:32,210 --> 00:27:35,730 It takes a bit of time for the records to actually get there. 361 00:27:41,650 --> 00:27:47,290 And then, so admin says, well, Microsoft told me to do this. 362 00:27:47,290 --> 00:27:48,410 I must do this. 363 00:27:48,410 --> 00:27:50,790 They open the logs in Log Analytics. 364 00:27:51,130 --> 00:27:54,790 I added this query to kind of filter things down to make things clearer. 365 00:27:54,790 --> 00:27:56,350 You don't have to run any queries. 366 00:27:56,350 --> 00:27:59,510 As long as you open that log, that payload should be in there. 367 00:27:59,510 --> 00:28:01,690 And you export it as CSV. 368 00:28:01,690 --> 00:28:03,610 You open it in Excel. 369 00:28:06,530 --> 00:28:10,290 You tell the user to click through these useless prompts. 370 00:28:12,290 --> 00:28:13,330 And boom. 371 00:28:13,330 --> 00:28:14,170 All right. 372 00:28:18,270 --> 00:28:19,190 Thank you. 373 00:28:19,410 --> 00:28:20,310 All right. 374 00:28:20,310 --> 00:28:28,650 So the lesson here is to kind of be aware that this may happen and attackers maybe try and, you know, integrate this into your tactics. 375 00:28:28,650 --> 00:28:29,790 So why is this happening? 376 00:28:29,790 --> 00:28:30,570 I have no idea. 377 00:28:30,570 --> 00:28:31,470 I'm speculating. 378 00:28:31,470 --> 00:28:34,870 I think logs are an afterthought for many software developers. 379 00:28:34,870 --> 00:28:37,930 I know when I was developing software, it was an afterthought for us. 380 00:28:38,010 --> 00:28:41,590 Features were the focus, and then everything else comes after. 381 00:28:41,650 --> 00:28:46,370 Sometimes maybe other fixes take priority to fixing these things. 382 00:28:46,370 --> 00:28:53,030 Some of the logs come from legacy products probably, so they just integrate with them and forget about them. 383 00:28:53,090 --> 00:28:57,370 And sometimes provider doesn't have an incentive to fix things. 384 00:28:57,370 --> 00:28:59,850 But whatever the reason is, I think things have to be fixed. 385 00:28:59,850 --> 00:29:08,110 So I think what should happen is full documentation for everything, logs treated as an API, so all the changes announced. 386 00:29:09,210 --> 00:29:14,590 You know, you have time to react if you have queries running against the current scheme of the logs. 387 00:29:14,590 --> 00:29:16,510 Logs are timely, arrive quickly. 388 00:29:16,530 --> 00:29:17,510 Values are clean. 389 00:29:17,510 --> 00:29:19,370 This is my Christmas wish list. 390 00:29:19,370 --> 00:29:26,990 I don't know how much of it is actually going to happen, but Microsoft, this is what the customers long for. 391 00:29:27,310 --> 00:29:37,930 And as a maximum goal, I think this thing should be refactored because it feels like it's pulled together from many different pieces and held together, like with duct tape. 392 00:29:39,450 --> 00:29:47,810 Ideally, a refactor is in order because I have seen logs in AWS and Okta, and I think they do a much better job, much cleaner job of doing this. 393 00:29:48,470 --> 00:29:49,670 So that's it. 394 00:29:51,250 --> 00:29:54,110 Logging, you know, we see it's in the cloud. 395 00:29:54,110 --> 00:29:55,250 This has a lot of advantages. 396 00:29:55,250 --> 00:29:56,190 It's uniform. 397 00:29:56,190 --> 00:30:00,170 It's kind of better understood, probably, than on-prem. 398 00:30:00,170 --> 00:30:06,350 But there's a lack of alternatives and no strong incentive for a provider to fix things. 399 00:30:06,350 --> 00:30:08,690 As defenders, we just want to be aware of these issues. 400 00:30:08,690 --> 00:30:13,110 And red teamers, until the issues are fixed, maybe try to take advantage of them. 401 00:30:13,110 --> 00:30:13,850 That's it. 402 00:30:13,850 --> 00:30:15,910 I think I'm out of time. 403 00:30:16,970 --> 00:30:19,350 Do we have time for questions? 404 00:30:19,570 --> 00:30:20,170 Okay . 405 00:30:20,590 --> 00:30:21,950 Sure, go ahead. 406 00:30:21,950 --> 00:30:36,960 Yeah, I think actually Microsoft monitors for... 407 00:30:37,580 --> 00:30:38,600 Oh, yes, sorry. 408 00:30:38,600 --> 00:30:45,360 Is there software that can monitor for these things happening and sending alerts? 409 00:30:45,360 --> 00:30:47,400 I think Microsoft has logging for that. 410 00:30:47,400 --> 00:30:52,360 Other external players have products that monitor for things like that. 411 00:30:52,360 --> 00:30:55,840 Our product company I'm working for does that. 412 00:30:56,380 --> 00:30:59,740 Or you can roll your own, execute your own queries. 413 00:31:00,180 --> 00:31:01,600 One more question. 414 00:31:04,840 --> 00:31:05,540 Yes. 415 00:31:05,540 --> 00:31:11,140 Do you have a query to turn AWS JSON log back to where it was supposed to be at? 416 00:31:11,140 --> 00:31:17,660 No, because when it's logged and sent, it only breaks down the entire AWS logs into whole fields. 417 00:31:18,300 --> 00:31:21,840 So the question is, do I have a query for what? 418 00:31:21,840 --> 00:31:22,740 I'm sorry, for... 419 00:31:22,740 --> 00:31:27,060 For changing Azure logs at AWS. 420 00:31:27,060 --> 00:31:29,160 That's back to their AWS JSON format. 421 00:31:29,160 --> 00:31:33,180 Because when you get JSON, you just have to call it with them. 422 00:31:34,900 --> 00:31:36,940 Okay, I don't think I got that. 423 00:31:36,940 --> 00:31:39,280 Maybe we can discuss this outside. 424 00:31:39,280 --> 00:31:40,240 You'll explain it to me.