1 00:00:00,000 --> 00:00:02,220 Hi, I'm Chef. 2 00:00:02,220 --> 00:00:03,120 Good morning. 3 00:00:03,120 --> 00:00:10,000 I'm the guest MC for this one, because your next speaker, Matt Nash, is a friend and colleague of mine. 4 00:00:10,000 --> 00:00:13,820 He and I worked together for NCC Group in Texas. 5 00:00:14,060 --> 00:00:26,140 So I've worked with Matt for the last four years, and when I heard about this research he was working on, I encouraged him to submit, because I think this is a wonderful topic for the Packet Acting Village. 6 00:00:26,140 --> 00:00:32,520 And so, Matt, I'll let you talk about yourself a little bit more, but welcome to the wall of sheep and break a leg. 7 00:00:32,620 --> 00:00:32,780 Thanks , Chef 8 00:00:36,840 --> 00:00:37,300 . 9 00:00:37,640 --> 00:00:40,760 So, as Chef said, I am Matt Nash. 10 00:00:40,760 --> 00:00:46,640 I am a security consultant with NCC Group, and this is my talk, Head in the Clouds. 11 00:00:47,560 --> 00:00:49,480 So what are we going to be doing today? 12 00:00:49,480 --> 00:00:58,840 We're going to be looking at the configuration of accounts within Amazon's AWS and then also Microsoft's Azure. 13 00:00:58,840 --> 00:01:15,120 Some of the resources that were put into this talk were native tooling developed by Amazon and Microsoft, security purpose tooling that was developed by NCC Group, and a third-party best practice reference. 14 00:01:16,660 --> 00:01:22,080 So, configuration reviews typically fall into two different categories. 15 00:01:22,080 --> 00:01:26,280 We're looking at services or the hosts or VMs themselves. 16 00:01:26,280 --> 00:01:28,080 Today, we're not going to be looking at the hosts. 17 00:01:28,080 --> 00:01:30,920 We're going to be focusing specifically on the services. 18 00:01:31,780 --> 00:01:35,440 So the first thing we're going to look at is Amazon's AWS. 19 00:01:36,200 --> 00:01:39,420 AWS is Amazon's web services. 20 00:01:39,500 --> 00:01:47,440 It is on-demand infrastructure, computing resources, storage resources, analytics, application services. 21 00:01:47,440 --> 00:01:49,560 They are available and scalable. 22 00:01:50,740 --> 00:02:01,860 And most people think of Amazon's AWS as infrastructure as a service, which contrasts with Microsoft's Azure, which we'll talk about a little bit later. 23 00:02:02,400 --> 00:02:06,880 So the tooling that we're going to use here is AWS CLI. 24 00:02:06,880 --> 00:02:16,460 It's developed by Amazon for querying AWS and interacting with the API. 25 00:02:16,460 --> 00:02:27,820 Another thing we're going to look at is Scout Suite, which is a tool that we developed for doing automated collection of data on AWS. 26 00:02:28,020 --> 00:02:33,380 And then CIS Benchmarks, which is a third-party best practice reference. 27 00:02:34,220 --> 00:02:42,800 So the first thing that we want to do when we're going to assess an AWS environment is we want to set up our auditing account. 28 00:02:42,800 --> 00:02:46,420 We want to apply a couple managed policies to it. 29 00:02:46,420 --> 00:02:50,800 The first one is read-only access, and the second one is security audit. 30 00:02:51,140 --> 00:02:58,820 We also want to establish programmatic access for the API, which is an access key and secret key pair. 31 00:02:59,260 --> 00:03:11,340 And then, not absolutely necessary, but it's nice to have access to the web console so that you can actually go through and click in the UI and look at that representation of the configuration. 32 00:03:12,600 --> 00:03:21,540 So with the access and secret key, we need to put those into something that we can feed into AWS CLI. 33 00:03:22,260 --> 00:03:25,700 There are a few other methods here that we're not going to cover today. 34 00:03:25,700 --> 00:03:28,640 The one that we're going to look at is the credentials file. 35 00:03:28,640 --> 00:03:33,080 And that credentials file looks something like this. 36 00:03:33,160 --> 00:03:42,440 If you run the AWS configure without a profile argument, you will get a default entry, which is the top one you see there. 37 00:03:42,480 --> 00:03:49,480 And if you run it with a profile name, in this case I used profile one, you'll get that second entry there. 38 00:03:50,840 --> 00:04:00,060 So the first thing that we want to do when assessing an AWS account is we'll dump out the account number so we know which one we're looking at. 39 00:04:00,120 --> 00:04:03,700 And we can also apply this to any findings that we come up with. 40 00:04:03,840 --> 00:04:07,940 So we'll run this command and we get the account number. 41 00:04:08,020 --> 00:04:12,760 We'll use that for our reporting so that we can identify what account the findings go to. 42 00:04:13,540 --> 00:04:17,180 And so the first service we're going to look at is IAM. 43 00:04:18,120 --> 00:04:21,840 IAM is the Identity and Access Management Service. 44 00:04:21,880 --> 00:04:31,560 This deals with authentication, or how your users sign in, authorization, which is permissions against resources or anything else in the account. 45 00:04:33,640 --> 00:04:39,080 So in IAM, the first thing we want to look at is the list of users on the account. 46 00:04:39,080 --> 00:04:40,780 So we'll run this command. 47 00:04:40,780 --> 00:04:42,260 We get some output. 48 00:04:42,300 --> 00:04:43,900 You can see here I've truncated it. 49 00:04:43,900 --> 00:04:49,100 You'll see an ellipsis on several slides just because we're dealing with a lot of data. 50 00:04:49,620 --> 00:04:52,060 So we see a user here, AWalters. 51 00:04:52,920 --> 00:04:54,880 We'll go ahead and take a look at that account. 52 00:04:55,640 --> 00:05:01,260 It was created on May 16th of 2015, so it's probably an older account. 53 00:05:02,520 --> 00:05:03,920 Probably good to look at. 54 00:05:03,920 --> 00:05:09,700 So first thing we want to do on a user is get a list of the access keys. 55 00:05:09,700 --> 00:05:14,380 So this is what gives them programmatic access to the API. 56 00:05:14,940 --> 00:05:18,420 So we'll run this command, specifying the username. 57 00:05:18,780 --> 00:05:20,540 We get some output here. 58 00:05:20,920 --> 00:05:23,820 We've got the access key ID for that user. 59 00:05:24,160 --> 00:05:31,260 And we see that that access key was created May 27th of 2015, so not long after the account was created. 60 00:05:31,620 --> 00:05:33,320 Probably an old key. 61 00:05:34,500 --> 00:05:40,420 And so we'll grab this access key ID and we'll use it in some future queries here. 62 00:05:41,900 --> 00:05:47,220 So the last time that this access key was used, when did the user actually use the API? 63 00:05:48,040 --> 00:05:53,840 So we'll take that access key from before, plug it into this command, get some output. 64 00:05:54,300 --> 00:06:02,140 We see the last time that they used it was June 16th of 2015, so this account hasn't been used in over four years. 65 00:06:02,140 --> 00:06:04,400 Probably a good thing to audit. 66 00:06:06,080 --> 00:06:13,320 So in the previous command, we looked at some user data on their access key specifically. 67 00:06:13,580 --> 00:06:26,420 Another thing you can do is you can generate a credential report, which gives you multiple access keys associated with the account and anything else associated with that user, like the last time they logged in, things like that. 68 00:06:26,420 --> 00:06:29,360 And you can generate these every four hours. 69 00:06:29,360 --> 00:06:34,180 Amazon doesn't want you just hammering with requests, so they put a time limit on there. 70 00:06:34,180 --> 00:06:43,520 So we'll run this command, we get the output of started, because we haven't actually run the generate credential report on this account before. 71 00:06:44,840 --> 00:06:49,200 And next thing you want to do is actually collect the report. 72 00:06:49,200 --> 00:06:57,600 So we'll run this next command here, and you'll get a very large Base64 encoded string. 73 00:06:57,600 --> 00:06:59,240 I've truncated it here. 74 00:07:00,180 --> 00:07:07,760 What we need to do to be able to read this credential report is decode it. 75 00:07:07,760 --> 00:07:18,280 So I've got a little cut command that I'm piping this into that's looking for the columns associated with the rotation dates of the keys. 76 00:07:18,280 --> 00:07:22,240 So we'll run this command, get some output. 77 00:07:22,320 --> 00:07:28,140 We see that Awalter's key was last rotated May 27th. 78 00:07:28,140 --> 00:07:31,560 So this is definitely an old access key. 79 00:07:31,560 --> 00:07:38,860 We need to go and audit and see if maybe that user still works with the company and maybe revoke their access. 80 00:07:40,320 --> 00:07:43,640 Next thing that we want to look at is root account usage. 81 00:07:43,640 --> 00:07:48,440 So root account in AWS is all-powerful. 82 00:07:48,440 --> 00:07:54,420 We don't like to see that account used habitually for administrative functions. 83 00:07:54,420 --> 00:08:02,120 We like to see an IAM role created for any of the permissions that you want an admin user to perform. 84 00:08:02,120 --> 00:08:04,780 So this is a very similar command. 85 00:08:04,780 --> 00:08:09,340 It's looking for the last login date of the root account. 86 00:08:09,620 --> 00:08:10,980 So we run this command. 87 00:08:10,980 --> 00:08:16,480 We can see the last time that this root account was used was July 2nd of this year. 88 00:08:16,480 --> 00:08:18,560 So probably habitual. 89 00:08:18,560 --> 00:08:26,820 The recommendation would be to lock away that root account, change any of their access keys, and just not use it if at all possible. 90 00:08:28,160 --> 00:08:31,840 Next thing that we want to look at is the account password policy. 91 00:08:31,840 --> 00:08:35,880 So this affects all users on the account. 92 00:08:36,100 --> 00:08:37,900 So we'll run this command. 93 00:08:37,900 --> 00:08:40,580 We get the password policy here. 94 00:08:40,760 --> 00:08:44,840 You can see that the minimum password length is 8 characters. 95 00:08:44,840 --> 00:08:46,160 It's pretty short. 96 00:08:46,300 --> 00:08:55,280 But what is also problematic is a user can use a password as long as it's not one of the last three used. 97 00:08:55,280 --> 00:09:02,980 So if a user figures out, hey, I changed my password three times, I can reuse my old password, you can see how that might be a problem. 98 00:09:04,080 --> 00:09:13,500 And what could be problematic with this configuration, depending on how they have the environment set up, passwords are set to not expire. 99 00:09:13,720 --> 00:09:14,940 That may be intentional. 100 00:09:14,940 --> 00:09:15,960 It may not be. 101 00:09:16,080 --> 00:09:22,100 You would want to go back to whoever runs this account and make sure that that's what they want. 102 00:09:22,100 --> 00:09:24,860 And also users are not able to change their password. 103 00:09:24,860 --> 00:09:26,820 That may also be a design decision. 104 00:09:26,820 --> 00:09:29,040 So we want to verify that. 105 00:09:30,260 --> 00:09:33,880 So some other common issues that we see with IAM. 106 00:09:34,360 --> 00:09:40,000 Policies that allow IAM pass role and STS assume role with a wildcard. 107 00:09:40,000 --> 00:09:43,020 So this could be for wildcard resources. 108 00:09:43,020 --> 00:09:49,040 This could be for wildcard principles or users. 109 00:09:49,040 --> 00:09:55,120 If you had wildcard for principles, that means anybody can do whatever this specific action is. 110 00:09:55,180 --> 00:09:59,780 And if you had resources, they could perform it against any resources. 111 00:10:00,080 --> 00:10:03,940 Another thing that we see is users without multi-factor authentication. 112 00:10:03,940 --> 00:10:06,140 That's a second factor. 113 00:10:06,140 --> 00:10:19,300 So if their access key and private or secret key were compromised or if their password were compromised, you would have a second factor there preventing an attacker from compromising the account further. 114 00:10:19,700 --> 00:10:21,760 Policies that allow not actions. 115 00:10:21,760 --> 00:10:24,080 So these are effectively blacklists. 116 00:10:24,080 --> 00:10:31,240 We like to see actions that are specified because that follows the principle of least privilege. 117 00:10:31,240 --> 00:10:35,840 So not actions essentially say you can perform everything except this action. 118 00:10:36,200 --> 00:10:43,460 And also cross-account assume role policies that lack an external ID or MFA. 119 00:10:43,460 --> 00:10:50,920 So the external ID can either be an account number for the account that you want to access your account's resources. 120 00:10:50,920 --> 00:10:57,040 Or it can just be a random string that you come up with that's unique to that third-party account. 121 00:10:57,040 --> 00:11:01,520 And then MFA, we've already discussed why that's a good thing. 122 00:11:01,520 --> 00:11:10,380 If the third-party account is compromised, this adds an additional step to keep an attacker from compromising your account's resources. 123 00:11:10,700 --> 00:11:13,900 So next service we want to look at is EC2. 124 00:11:14,020 --> 00:11:17,100 This is the Elastic Compute Cloud. 125 00:11:17,100 --> 00:11:29,900 It deals with scalable computing resources, which includes instances or VMs, network interfaces on the account, network access control, security groups, and any load balancing that's in place. 126 00:11:30,820 --> 00:11:37,200 So the first thing we want to do in EC2 is get a list of the VPCs, or Virtual Private Clouds. 127 00:11:37,200 --> 00:11:39,140 So we'll run this command. 128 00:11:39,160 --> 00:11:43,800 We get a list of VPCs, again truncated output. 129 00:11:43,800 --> 00:11:49,240 We see VPC IDs, we've got CIDR blocks that are associated with the VPCs. 130 00:11:49,240 --> 00:11:53,760 So we'll take this VPC ID and we'll use it in some next queries. 131 00:11:54,840 --> 00:11:59,020 Do the VPCs that we've found have flow logs enabled? 132 00:11:59,440 --> 00:12:06,660 So flow logs allow you to gain insight into the network actions that are going on relative to the VPCs. 133 00:12:06,660 --> 00:12:14,620 So we'll take that VPC ID from before, plug it into this command, and we get some output here on the flow logs. 134 00:12:14,700 --> 00:12:19,860 And you can see that flow log status active shows up in this output. 135 00:12:20,020 --> 00:12:27,320 If the flow logs were not enabled on the VPC that you're querying against, you would just get an empty set like here. 136 00:12:28,520 --> 00:12:31,880 So the next thing we want to do is get a list of network interfaces. 137 00:12:31,880 --> 00:12:36,540 So we'll run this command, which is the describe network interfaces command. 138 00:12:36,800 --> 00:12:38,340 We get some output. 139 00:12:38,380 --> 00:12:41,340 This is actually going to be one of those queries that generates a lot. 140 00:12:41,340 --> 00:12:45,520 So you'll probably have to scroll through to find the information that you want or grep it. 141 00:12:46,300 --> 00:12:49,160 So we see a network interface ID here. 142 00:12:49,560 --> 00:12:57,500 If we scroll down through the output, we can look for interfaces that are exposed to the internet. 143 00:12:57,500 --> 00:13:04,320 And in this case, we do see a public IP, and we also see public DNS. 144 00:13:04,320 --> 00:13:06,940 So this interface is exposed to the internet. 145 00:13:08,260 --> 00:13:12,540 Another thing we want to do is get a list of subnets on the account. 146 00:13:13,560 --> 00:13:15,680 So we run this command. 147 00:13:15,680 --> 00:13:23,660 We get CIDR blocks that are associated with that subnet, and also subnet ID and the VPC that it is associated with. 148 00:13:23,660 --> 00:13:29,700 We also get the availability zone and the ID of that zone. 149 00:13:30,380 --> 00:13:36,420 So we'll take this subnet ID and we'll use this in some future queries. 150 00:13:37,180 --> 00:13:43,020 So what NACLs are associated with this subnet? 151 00:13:43,260 --> 00:13:44,580 We'll run this command. 152 00:13:44,580 --> 00:13:47,100 We'll get a list of NACLs. 153 00:13:47,100 --> 00:13:57,560 And we can see this subnet ID has a rule action of allow for egress false. 154 00:13:57,560 --> 00:14:00,400 And in this case, egress false means ingress. 155 00:14:00,400 --> 00:14:06,520 So inbound connections for the CIDR block 0000 slash 0, or everyone. 156 00:14:07,900 --> 00:14:11,320 So the next thing we want to do is get a list of security groups. 157 00:14:11,320 --> 00:14:15,920 So NACLs and security groups are similar, but they are different. 158 00:14:15,920 --> 00:14:22,800 Security groups are in front of instances, whereas NACLs are in front of subnets. 159 00:14:23,620 --> 00:14:25,220 So we'll run this command. 160 00:14:25,220 --> 00:14:28,360 We get a list of security groups on the account. 161 00:14:30,060 --> 00:14:36,260 And so something we look for is default and Launch Wizard 1 security groups. 162 00:14:36,700 --> 00:14:41,580 And in this case, we see that both of those are in this listing of security groups. 163 00:14:42,620 --> 00:14:47,960 We'll probably focus a lot on this Launch Wizard 1 for the next queries. 164 00:14:49,360 --> 00:14:53,680 We'll grab the SG ID for that security group. 165 00:14:54,460 --> 00:14:56,840 And we'll use it in our next query. 166 00:14:56,840 --> 00:15:03,140 So something we want to look at is, is SSH exposed to the internet? 167 00:15:03,140 --> 00:15:16,680 So this is kind of a lengthy query, but essentially what it does is it looks for a port range from port 22 to port 22 for the CIDR block 0000 slash 0, or everyone. 168 00:15:16,980 --> 00:15:23,240 And it will output the name and ID of the groups that it finds. 169 00:15:23,900 --> 00:15:27,600 So we do see this Launch Wizard 1 again. 170 00:15:27,600 --> 00:15:30,640 We also see an OpenSSH group. 171 00:15:31,160 --> 00:15:43,160 OpenSSH, that's probably okay, but we definitely want to go back and verify, make sure it's not going to be a group that should be for only developers or a specific group. 172 00:15:43,720 --> 00:15:50,040 Since it is open to the internet, they probably want to lock that down if it's supposed to be for a smaller group. 173 00:15:50,600 --> 00:15:53,500 So let's focus on this Launch Wizard 1. 174 00:15:55,880 --> 00:15:59,980 What instances are associated with that security group? 175 00:15:59,980 --> 00:16:02,680 What instances or VMs are behind it? 176 00:16:02,680 --> 00:16:11,940 So we'll run this command, plugging in the SG value that we grabbed, and we'll get a list of instances that are associated with it. 177 00:16:11,940 --> 00:16:14,780 So we see here there are actually two instances. 178 00:16:14,800 --> 00:16:27,760 If you remember from the NACLs, the NACL that we saw before opened up SSH to the world, which is associated with this security group. 179 00:16:27,760 --> 00:16:35,100 So if there's any SSH services or services running on port 22 on these instances, that's going to be exposed to the internet. 180 00:16:35,100 --> 00:16:38,180 So that's our external attack surface. 181 00:16:38,800 --> 00:16:45,460 Some other common issues that we see with EC2 are security groups that whitelist AWS CIDRs. 182 00:16:45,460 --> 00:16:49,520 So these are network blocks within AWS. 183 00:16:49,520 --> 00:17:02,440 We like to see specific IPs for any instances that you want to be able to access resources rather than an entire net block. 184 00:17:03,280 --> 00:17:10,180 If somebody else gets an instance within that block, then that would allow them access to whatever these resources are. 185 00:17:10,680 --> 00:17:14,740 Another thing we see is EBS volumes that don't have encryption enabled. 186 00:17:14,740 --> 00:17:23,620 So if the storage mechanism for the EBS volume becomes compromised, if it's not encrypted, the data is also compromised. 187 00:17:23,880 --> 00:17:27,120 If it's encrypted, it should be safe. 188 00:17:27,700 --> 00:17:31,460 So another thing we see is all ports that are open to all. 189 00:17:31,740 --> 00:17:34,240 This does not follow the principle of least privilege. 190 00:17:34,240 --> 00:17:40,180 We want to see specific ports open for services that you intend to have exposed. 191 00:17:40,180 --> 00:17:47,020 And then also we see secrets in the instance metadata user data. 192 00:17:47,020 --> 00:17:54,240 So if an instance is set up using a script, it essentially gets recorded like bash history. 193 00:17:54,240 --> 00:18:07,600 So if there are hard-coded passwords in that script or anything that points to sensitive data, that would be exposed if somebody goes to the user metadata on the instance. 194 00:18:08,600 --> 00:18:12,320 So the next service we want to look at is the S3 service. 195 00:18:12,900 --> 00:18:17,780 That is simple storage service, and it deals with object storage. 196 00:18:17,780 --> 00:18:20,520 You may be familiar with the term buckets. 197 00:18:22,280 --> 00:18:26,760 So the first thing we want to do is get a listing of the buckets on the account. 198 00:18:26,760 --> 00:18:31,460 So we'll run this query, which will dump out a listing of the bucket names. 199 00:18:32,440 --> 00:18:36,500 So we see here we've got a bucket named devraven. 200 00:18:37,340 --> 00:18:40,160 Let's go ahead and take that for our next queries. 201 00:18:42,360 --> 00:18:48,620 So we want to look and see if the bucket is world-listable or world-writable. 202 00:18:48,640 --> 00:18:55,860 So can people browse and see that bucket, or can they write data to the bucket? 203 00:18:56,020 --> 00:19:00,740 So we'll take the devraven bucket name, throw it into this command. 204 00:19:00,740 --> 00:19:02,950 Get some output here. 205 00:19:03,340 --> 00:19:08,030 We scroll through and we see that the group global all users. 206 00:19:08,400 --> 00:19:14,140 If you're looking in the web UI of AWS, you'll see this listed as everybody. 207 00:19:14,540 --> 00:19:19,900 We can see that that has read and write permissions on this bucket. 208 00:19:20,080 --> 00:19:23,680 So it is world-listable and it is world-writable. 209 00:19:24,500 --> 00:19:28,440 So next thing we want to look at is objects within that bucket. 210 00:19:28,440 --> 00:19:31,660 Are they world-readable and world-writable? 211 00:19:32,020 --> 00:19:36,900 So from the output before, we've got a bucket named test. 212 00:19:36,900 --> 00:19:39,840 So we'll query that with this command. 213 00:19:39,860 --> 00:19:52,820 And we can see that this bucket policy for test allows wildcard for principles, so all principles, any users, to do S3 get object and S3 put object. 214 00:19:52,820 --> 00:20:00,100 So it is world-readable and world-writable for any bucket objects or objects within this bucket. 215 00:20:01,300 --> 00:20:05,500 Next thing we want to look at is versioning for the buckets. 216 00:20:06,660 --> 00:20:11,240 Versioning allows you to keep a record of changes that occur on a bucket. 217 00:20:11,240 --> 00:20:16,120 So if somebody deletes data, you should be able to recover it if you have versioning enabled. 218 00:20:16,520 --> 00:20:21,720 So we'll run this command against devraven and we see a status of enabled. 219 00:20:21,720 --> 00:20:24,960 So versioning is enabled for this bucket. 220 00:20:25,120 --> 00:20:30,020 If you did not have versioning enabled, you would just get no data back from the query. 221 00:20:31,040 --> 00:20:34,620 So next thing we want to look at is access logging for the buckets. 222 00:20:34,620 --> 00:20:41,440 So seeing what type of access requests are coming in for the buckets and for the data. 223 00:20:41,540 --> 00:20:45,080 So we'll again query devraven using this command. 224 00:20:45,080 --> 00:20:57,140 And we can see here that not only is a logging enabled in the output, but we also get the bucket that the logs are going to and a directory in that bucket. 225 00:20:57,140 --> 00:20:59,060 So logging is enabled. 226 00:20:59,360 --> 00:21:04,380 If you did not have logging enabled, you would just get no data back from the query. 227 00:21:05,280 --> 00:21:11,940 So some other common issues that we see with S3 version buckets that don't have MFA delete. 228 00:21:11,940 --> 00:21:17,960 So this is a second step before buckets or data can be deleted. 229 00:21:19,480 --> 00:21:24,280 Another thing we see is buckets that don't have the default encryption enabled. 230 00:21:24,280 --> 00:21:29,300 This is very similar to the EBS that we spoke about before. 231 00:21:30,180 --> 00:21:35,640 Data at rest, if it's encrypted, should be safe if the storage mechanism is compromised. 232 00:21:36,060 --> 00:21:40,860 Another thing we see is buckets that allow clear text or HTTP communication. 233 00:21:40,860 --> 00:21:55,640 So one of the issues that you could see here is if this bucket is serving software updates to clients, anybody with a suitable position between that user and the bucket could intercept the communication. 234 00:21:55,640 --> 00:21:58,160 They could modify the packages as they're coming through. 235 00:21:58,160 --> 00:22:00,980 And then your user may actually be infected with malware. 236 00:22:00,980 --> 00:22:05,100 So we like to see secure communication enabled for buckets. 237 00:22:06,200 --> 00:22:09,320 All right, so now we're going to look at Microsoft Azure. 238 00:22:10,460 --> 00:22:16,060 Azure is software-as-a-service, platform-as-a-service, infrastructure-as-a-service. 239 00:22:16,060 --> 00:22:17,820 It's also available and scalable. 240 00:22:17,820 --> 00:22:19,560 Very similar to AWS. 241 00:22:19,640 --> 00:22:23,040 However, people see it more as a platform-as-a-service. 242 00:22:23,040 --> 00:22:31,420 So they kind of handle the OS updates and other things that you would be responsible for within AWS. 243 00:22:31,420 --> 00:22:34,300 They kind of manage the behind-the-scenes stuff. 244 00:22:36,060 --> 00:22:48,500 So some of the tools that we're going to use for querying Azure is Azure CLI, which is developed by Microsoft for doing very similar functions as we saw in AWS. 245 00:22:48,820 --> 00:22:54,560 Scout Suite, which is developed by NCC Group, and also the CIS Benchmarks. 246 00:22:55,480 --> 00:22:59,160 So account setup within Azure is a little bit different from AWS. 247 00:22:59,160 --> 00:23:01,380 They use role-based access control. 248 00:23:01,380 --> 00:23:07,660 We like to see at least read access on any of the resources that you intend on auditing. 249 00:23:07,940 --> 00:23:10,640 And Security Reader is a good role to use. 250 00:23:13,140 --> 00:23:18,580 So credentials, they handle it quite different from AWS. 251 00:23:19,740 --> 00:23:24,080 The login flow, you use the az login command. 252 00:23:24,080 --> 00:23:28,060 It will then throw up a prompt in your browser, your default browser. 253 00:23:28,060 --> 00:23:31,160 You will log in using your Microsoft ID. 254 00:23:31,200 --> 00:23:38,260 And then a token will get passed to the Azure CLI client that will then get used for any of your queries. 255 00:23:38,860 --> 00:23:42,340 So we'll log in using that az login command. 256 00:23:43,620 --> 00:23:51,300 And there's also a legacy option to use a device code rather than logging in through the web UI. 257 00:23:51,660 --> 00:23:53,720 You'll get a bunch of output here. 258 00:23:53,720 --> 00:23:56,100 Azure is very noisy with its output. 259 00:23:56,100 --> 00:24:03,440 You'll get the cloud name that you've just logged into as well as the Microsoft ID that you've used. 260 00:24:04,160 --> 00:24:08,700 And the user type that you have. 261 00:24:08,700 --> 00:24:16,280 And we can see here our audit account, pentester, at sharklasercorp3742.onmicrosoft.com. 262 00:24:17,120 --> 00:24:26,040 So similar to AWS, first thing we want to do is grab the account ID, make sure that we're hitting the right account, and then we can use that for any of our reporting. 263 00:24:26,100 --> 00:24:30,220 So we'll run this command and we get the account ID. 264 00:24:31,780 --> 00:24:34,640 So we'll use that for any of our findings. 265 00:24:35,240 --> 00:24:39,880 The first service that we're going to look at is Azure AD or Active Directory. 266 00:24:40,040 --> 00:24:43,700 Azure AD is quite a bit different from on-prem AD. 267 00:24:43,700 --> 00:24:47,020 They handle a lot of things very different from it. 268 00:24:47,020 --> 00:24:51,620 So if you're familiar with on-prem AD, this is a different beast. 269 00:24:52,480 --> 00:24:57,540 The first thing we want to do is get a list of the users in Active Directory. 270 00:24:57,760 --> 00:25:02,940 So we'll run this command, which will get the user name and then their job titles. 271 00:25:04,000 --> 00:25:08,440 So we see here we've got a System Administrator 3, probably a good account to audit. 272 00:25:09,420 --> 00:25:11,080 And their ID is A. 273 00:25:11,080 --> 00:25:13,040 Adams at the same company. 274 00:25:15,220 --> 00:25:20,620 So first thing we want to do once we've got a username that we want to audit, we want to get some additional information about the user. 275 00:25:20,620 --> 00:25:24,240 So we'll run this command, specifying the user ID. 276 00:25:24,500 --> 00:25:26,960 And we get a bunch more output. 277 00:25:27,380 --> 00:25:31,340 And we can see that the user's name is Arthur Adams. 278 00:25:31,340 --> 00:25:34,740 Arthur works in the Information Technology Department. 279 00:25:34,820 --> 00:25:39,660 And Arthur's account was created in March of this year. 280 00:25:39,660 --> 00:25:41,340 So, pretty new user. 281 00:25:43,220 --> 00:25:47,660 Next thing we want to do is see what groups this user is associated with. 282 00:25:47,660 --> 00:25:51,320 So we'll run this command, again specifying the user ID. 283 00:25:51,640 --> 00:25:55,500 And we can see that Arthur is part of InfoTech and SysAdmins. 284 00:25:55,500 --> 00:25:58,600 Not surprising, Arthur is a technology worker. 285 00:25:59,380 --> 00:26:03,860 And we've got the object IDs also for those groups. 286 00:26:05,140 --> 00:26:08,340 Another thing we want to look for is guest users in the account. 287 00:26:08,340 --> 00:26:12,400 So these are not managed by your organization. 288 00:26:13,460 --> 00:26:17,640 They have been added with permissions to be able to do things on your account. 289 00:26:18,220 --> 00:26:19,600 So we run this command. 290 00:26:19,600 --> 00:26:26,080 We see that TammyRogers256bq8 with a tag of ext. 291 00:26:26,140 --> 00:26:28,940 So it shows you that it's an external user. 292 00:26:29,180 --> 00:26:31,020 Has been added to the account. 293 00:26:33,140 --> 00:26:37,560 Like I kind of alluded to before, these are users that you don't manage. 294 00:26:38,100 --> 00:26:47,040 So any problems with their account, if they have a weak password, it makes it much harder for you to make sure that they are secure. 295 00:26:47,040 --> 00:26:53,700 So we like to see specific AD accounts created for anybody who needs access to your environment. 296 00:26:54,660 --> 00:26:57,780 And if you didn't have any guest users, you would get an empty set. 297 00:26:59,000 --> 00:27:02,620 So the next service we want to look at in Azure is the Key Vault. 298 00:27:03,960 --> 00:27:05,460 So we will run this command. 299 00:27:05,460 --> 00:27:08,640 We'll get a list of the Key Vaults that are on the account. 300 00:27:09,440 --> 00:27:10,960 So we scroll through. 301 00:27:10,960 --> 00:27:14,520 We see we've got this vault name. 302 00:27:14,520 --> 00:27:20,660 You also get the location of it and the ID within Azure. 303 00:27:21,800 --> 00:27:28,600 So we'll take that ID and we'll look and see if this vault is recoverable. 304 00:27:28,600 --> 00:27:32,840 So if the vault is deleted, can we revert that? 305 00:27:33,460 --> 00:27:41,240 And we're going to look for the Enable Purge Protection or the Enable Soft Delete in the output. 306 00:27:41,740 --> 00:27:44,660 And so we'll specify that ID from before. 307 00:27:45,780 --> 00:27:48,060 And we see we don't actually get data back. 308 00:27:48,060 --> 00:27:49,960 So this vault is not recoverable. 309 00:27:49,960 --> 00:27:51,840 If it's deleted, it's gone. 310 00:27:53,240 --> 00:27:57,460 So the next thing we want to look at is the keys within the Key Vault. 311 00:27:57,480 --> 00:28:00,020 Do they have an expiration date set? 312 00:28:00,020 --> 00:28:01,640 So we'll run this command. 313 00:28:01,640 --> 00:28:06,230 It's looking for the Attributes Enabled and Attributes Expired. 314 00:28:07,140 --> 00:28:10,580 So we see a key here. 315 00:28:10,580 --> 00:28:15,080 We notice that it expires January 1st of 2020. 316 00:28:15,080 --> 00:28:16,340 So that's good. 317 00:28:16,340 --> 00:28:18,380 It does have an expiration date. 318 00:28:19,160 --> 00:28:22,100 Next thing we want to look at is the secrets in the vault. 319 00:28:22,100 --> 00:28:24,260 Do those also have an expiration date? 320 00:28:24,260 --> 00:28:26,780 So we get similar output here. 321 00:28:26,780 --> 00:28:32,400 We see that this secret also expires January 1st, 2020. 322 00:28:33,620 --> 00:28:37,200 So next service that we're going to look at is Logging and Monitoring. 323 00:28:38,400 --> 00:28:41,540 These commands are going to be much longer. 324 00:28:41,860 --> 00:28:50,360 You'll see a slide with just the command on it, and then the next slide will actually have the output just due to how we have to query this service. 325 00:28:51,120 --> 00:28:58,740 So the first thing we're going to look at is Activity Logging Alerts for creating or updating Network Security Groups. 326 00:28:58,820 --> 00:29:06,820 And we are going to look for the operation name of Microsoft Network, Network Security Groups, right action. 327 00:29:07,260 --> 00:29:09,060 And we get some output here. 328 00:29:09,060 --> 00:29:11,320 We see that it's set to global. 329 00:29:11,400 --> 00:29:14,180 The scope is properly set for the subscription. 330 00:29:14,180 --> 00:29:17,260 And enabled is true. 331 00:29:17,300 --> 00:29:23,080 So Activity Logging Alerts is enabled for creating and updating Network Security Groups. 332 00:29:24,000 --> 00:29:31,220 So let's look and see if Logging Alerts are also enabled for Delete Network Security Group. 333 00:29:31,220 --> 00:29:37,520 Very similar command, but the action is going to be Microsoft Network, Network Security Groups, Delete. 334 00:29:37,520 --> 00:29:39,360 So we get some output here. 335 00:29:39,360 --> 00:29:41,760 We see this is also set to global. 336 00:29:41,840 --> 00:29:45,780 The subscription is properly set, and enabled is true. 337 00:29:45,980 --> 00:29:50,640 So Logging Alerts are enabled for deleting Network Security Groups. 338 00:29:51,540 --> 00:29:57,120 Next thing we want to look at is creating and updating Network Security Rules. 339 00:29:57,120 --> 00:29:59,680 So these are the rules associated with those groups. 340 00:30:00,100 --> 00:30:04,140 Very similar command, but we're looking at the Security Rules, right action. 341 00:30:04,620 --> 00:30:05,980 We get some output here. 342 00:30:05,980 --> 00:30:07,680 We see that it's set to global. 343 00:30:07,940 --> 00:30:12,120 The subscription is properly set on the account, and enabled is true. 344 00:30:13,240 --> 00:30:14,980 Same thing for Delete. 345 00:30:16,420 --> 00:30:21,100 Run a very similar command, but with the Security Rules, Delete action. 346 00:30:21,500 --> 00:30:22,520 We get some output here. 347 00:30:22,520 --> 00:30:25,400 We see that the location is also set to global. 348 00:30:26,420 --> 00:30:30,020 Subscription is properly set on the account, and enabled is true. 349 00:30:30,760 --> 00:30:36,980 So this next query is going to look for any actions for SQL Server Firewall Rules. 350 00:30:37,200 --> 00:30:42,640 Similar command, but we're looking at Microsoft SQL Server's Firewall Rules, right. 351 00:30:43,100 --> 00:30:45,360 So we get more output here. 352 00:30:45,360 --> 00:30:47,080 The location is set to global. 353 00:30:47,080 --> 00:30:50,500 Subscription is properly set, and enabled is true. 354 00:30:50,600 --> 00:30:54,420 So Alert Logs are also set on this action. 355 00:30:55,380 --> 00:31:03,720 So for updating a security policy, very similar command, but we're looking at the Microsoft Security Policies, right action. 356 00:31:04,400 --> 00:31:06,180 We get some output here. 357 00:31:06,180 --> 00:31:07,420 We see global. 358 00:31:08,280 --> 00:31:13,040 Subscription is also set properly on the account, and enabled is true. 359 00:31:13,040 --> 00:31:14,820 So we have logs there as well. 360 00:31:15,380 --> 00:31:18,280 Next service we want to look at is networking. 361 00:31:19,900 --> 00:31:22,580 First thing we want to look for is RDP. 362 00:31:22,580 --> 00:31:23,940 Is that exposed to the internet? 363 00:31:24,420 --> 00:31:33,500 So we'll run this command that will get a list of network security groups, and then it will print out the name as well as the rules associated. 364 00:31:34,020 --> 00:31:35,960 So we get a bunch of output here. 365 00:31:35,960 --> 00:31:43,560 We look through and we see that there is an allow rule for inbound connections to port 3389. 366 00:31:44,040 --> 00:31:48,080 And the source address is wildcard. 367 00:31:48,080 --> 00:31:51,040 So any source address can connect to the service. 368 00:31:51,540 --> 00:31:53,580 So it is open to the internet. 369 00:31:54,420 --> 00:31:56,520 Next thing we want to look at is SSH. 370 00:31:56,520 --> 00:31:58,760 Is SSH also open to the internet? 371 00:31:59,900 --> 00:32:01,820 Same command, same output. 372 00:32:01,820 --> 00:32:02,920 We're going to scroll through. 373 00:32:02,920 --> 00:32:12,020 We see that access is allowed for inbound connections on port 22 for any source address again. 374 00:32:12,020 --> 00:32:14,520 So SSH is also open to the internet. 375 00:32:16,860 --> 00:32:20,100 So the next thing we want to look at is network watchers. 376 00:32:20,100 --> 00:32:29,200 These enable flow logging or insight into network actions that are occurring. 377 00:32:29,200 --> 00:32:35,360 So this command will output a list of the network watchers on the account. 378 00:32:35,740 --> 00:32:39,300 We're looking for the provisioning state succeeded. 379 00:32:39,340 --> 00:32:44,480 And if you didn't have any network watchers enabled, you would have an empty set like this. 380 00:32:45,860 --> 00:32:52,480 So flow log retention period, is this sufficient for any of the flow logs? 381 00:32:52,640 --> 00:32:58,340 So we'll run this command specifying a resource group and a network security group. 382 00:32:58,340 --> 00:33:01,760 And we're going to look for the retention policy attribute. 383 00:33:02,140 --> 00:33:05,480 In this case, we've got one that has days set to 30. 384 00:33:05,480 --> 00:33:08,260 We like to see this at at least 90 days. 385 00:33:10,320 --> 00:33:12,640 So NCC Group Scout Suite. 386 00:33:12,640 --> 00:33:16,180 This is a tool we spoke about in the beginning of the presentation. 387 00:33:17,600 --> 00:33:23,160 Scout Suite is an automated tool that does a lot of this stuff in mere minutes. 388 00:33:23,460 --> 00:33:26,960 So a lot of those commands were pretty long. 389 00:33:27,460 --> 00:33:29,860 And I hope they didn't make your eyes bleed. 390 00:33:29,860 --> 00:33:31,220 This should be a lot better. 391 00:33:31,220 --> 00:33:33,180 Multicloud. 392 00:33:33,180 --> 00:33:38,680 So right now it supports Amazon's AWS, Microsoft Azure, Google Cloud Platform. 393 00:33:38,780 --> 00:33:46,340 And we recently released updates that include Alibaba Cloud and Oracle Cloud Infrastructure. 394 00:33:47,000 --> 00:33:50,500 So using Scout Suite against AWS. 395 00:33:50,780 --> 00:33:56,940 When you run Scout Suite against an AWS account, you will get a very similar interface to this. 396 00:33:56,940 --> 00:33:58,320 You'll get the account number. 397 00:33:58,320 --> 00:34:03,460 You'll see the services that Scout Suite looked at. 398 00:34:03,460 --> 00:34:09,400 And we've got some drop down menus up top that allow you to get to different dashboards. 399 00:34:09,740 --> 00:34:12,240 Here we're looking at the IAM dashboard. 400 00:34:12,980 --> 00:34:16,720 So you see all of the findings that were associated with IAM. 401 00:34:17,580 --> 00:34:22,520 And here we've got a finding for password expiration disabled. 402 00:34:22,520 --> 00:34:24,600 So we'll click on this. 403 00:34:24,720 --> 00:34:27,800 We get a nice output of that password policy. 404 00:34:27,800 --> 00:34:32,560 And we can see that Scout Suite has identified that password expiration is false. 405 00:34:32,560 --> 00:34:33,800 And it's highlighted that. 406 00:34:33,800 --> 00:34:39,960 So you can very quickly go through and see what things are enabled or not enabled on your account. 407 00:34:40,640 --> 00:34:44,020 We can go to the S3 dashboard. 408 00:34:44,020 --> 00:34:46,980 And we see some more findings here for S3. 409 00:34:47,420 --> 00:34:51,780 And we see a finding for get actions authorized to all principles. 410 00:34:52,520 --> 00:34:55,940 So this is the readable to everyone. 411 00:34:56,000 --> 00:34:57,180 So we click on that. 412 00:34:57,180 --> 00:35:02,440 We actually get the listing of the bucket. 413 00:35:02,560 --> 00:35:05,120 And then the configuration data. 414 00:35:05,120 --> 00:35:09,500 And you can actually see down in the bottom right corner, there's a little details button. 415 00:35:09,500 --> 00:35:13,940 So you can get the details of the policy itself for that bucket. 416 00:35:14,940 --> 00:35:17,660 Alright, running Scout Suite against Azure. 417 00:35:17,660 --> 00:35:20,760 Very familiar web page. 418 00:35:21,340 --> 00:35:31,940 Here we have fewer services because Azure's API is not as mature as AWS, but they are adding features. 419 00:35:32,260 --> 00:35:35,680 So here we've got five different services. 420 00:35:35,720 --> 00:35:40,780 Key Vault, Network, Security Center, SQL Database, and Storage Accounts. 421 00:35:40,780 --> 00:35:45,060 So we'll go up here to the Storage Accounts dashboard. 422 00:35:45,240 --> 00:35:48,580 And we see a finding for access keys not rotated. 423 00:35:48,580 --> 00:35:58,540 So if we click the little plus sign over there, it drops down and you get some details on why Scout Suite identified that. 424 00:35:58,740 --> 00:36:04,680 So the keys were rotated greater than 90 days from today. 425 00:36:04,680 --> 00:36:08,460 And there's also a reference to the CIS benchmarks. 426 00:36:08,460 --> 00:36:11,400 So CIS benchmarks, what are these? 427 00:36:11,400 --> 00:36:15,880 They are developed by the Center for Internet Security. 428 00:36:15,880 --> 00:36:22,040 They are best practice guides that provide step-by-step audit queries. 429 00:36:22,100 --> 00:36:27,900 And they also provide step-by-step fixes once you've identified some issues. 430 00:36:27,900 --> 00:36:31,760 And they're available for almost any technology you can think of. 431 00:36:31,860 --> 00:36:39,260 Red Hat, Server 2016, any kind of technology, they probably have a benchmark for it. 432 00:36:39,320 --> 00:36:47,500 And the ones that we used for this presentation were the Amazon Web Services Foundations and the Microsoft Azure Foundations. 433 00:36:47,500 --> 00:36:50,260 These are the cover pages for the PDFs. 434 00:36:50,260 --> 00:36:56,680 And they provide a table of contents that is... you can navigate through it. 435 00:36:56,680 --> 00:36:59,960 You can click on whatever findings you're wanting to look at. 436 00:37:00,880 --> 00:37:10,240 And they provide a step-by-step... on the left here you see the audit for using the AWS CLI. 437 00:37:10,340 --> 00:37:15,520 But they also provide steps if you're going through the UI or the API. 438 00:37:15,520 --> 00:37:22,880 And then they also provide some references as to why those findings were identified. 439 00:37:23,160 --> 00:37:29,140 And on the right here you see a remediation for going through the Azure web console. 440 00:37:29,140 --> 00:37:31,460 And also some references. 441 00:37:31,940 --> 00:37:33,400 And that's it.