1 00:00:00,000 --> 00:00:00,440 All right. 2 00:00:00,440 --> 00:00:01,060 Thanks a lot. 3 00:00:01,060 --> 00:00:04,420 And thank you all for filling this arguably a little bit small room. 4 00:00:04,420 --> 00:00:05,280 But it's cool. 5 00:00:05,280 --> 00:00:08,280 I'll tell everyone the room was full and not how many people were in it. 6 00:00:08,400 --> 00:00:09,960 So thank you for coming. 7 00:00:09,960 --> 00:00:11,160 I work at DirectSupply. 8 00:00:11,160 --> 00:00:13,600 I'm a technical fellow and chief software architect. 9 00:00:14,400 --> 00:00:17,860 And I'm here to talk to you about scaling security in the cloud today. 10 00:00:17,880 --> 00:00:23,720 Our company, DirectSupply, we do services and solutions for the long‑term care industry. 11 00:00:23,720 --> 00:00:36,700 So things for nursing homes, assisted living, apps where they can do maintenance on their equipment, all the way through e‑commerce sites where they can buy products and food for the residents. 12 00:00:38,680 --> 00:00:43,460 So we've been undergoing a journey to migrate into the cloud for about the past two years. 13 00:00:43,460 --> 00:00:48,160 I've been interested in going in that direction for longer than that. 14 00:00:48,160 --> 00:00:51,660 But it was only about two years ago when we decided to do this. 15 00:00:51,660 --> 00:01:10,760 And a big part of the talk today is kind of around how we've migrated somewhat from a traditional infrastructure and software culture, you know, two different silos, to the DevOps mode where development teams are owning their own deployments and how we're starting to scale the security amongst those DevOps teams. 16 00:01:13,690 --> 00:01:15,350 Now, I do have a lot to talk about. 17 00:01:15,350 --> 00:01:17,830 I will stay out in the hall for questions afterwards. 18 00:01:17,830 --> 00:01:19,670 So if you would just hold them to the end, that would be great. 19 00:01:19,670 --> 00:01:23,170 I have some slides I was going to maybe have to skip over, but hopefully I won't have to. 20 00:01:23,450 --> 00:01:29,110 But I wanted to talk about first our company's cloud vision and strategy that I was part of putting together. 21 00:01:29,290 --> 00:01:35,430 When we decided to migrate into the cloud, we wanted to make sure that we took advantage of a lot of the things that the cloud was going to get us. 22 00:01:35,430 --> 00:01:42,490 We didn't want to just take our applications as they were running and then shift them to run on EC2 instances in AWS. 23 00:01:42,870 --> 00:01:46,190 An argument you might hear is that, well, you don't own the infrastructure. 24 00:01:46,190 --> 00:01:46,870 And that's true. 25 00:01:46,870 --> 00:01:51,610 We don't own the infrastructure, but we can architect for not owning the infrastructure. 26 00:01:52,030 --> 00:01:56,390 So part of the strategy included things like immutable servers. 27 00:01:56,390 --> 00:02:00,970 If you've heard of this, this is the idea that once you run a server, you're not going to change it. 28 00:02:00,970 --> 00:02:06,750 If you want to change it, you will tear that server down and relaunch from a new image that you've built. 29 00:02:08,270 --> 00:02:11,190 We wanted to embrace infrastructure as code. 30 00:02:11,210 --> 00:02:24,970 We had limited scripting in our old infrastructure world and part of the programmability of the cloud is that you can take advantage of all of the things that software development teams have been able to take advantage of for a very long time. 31 00:02:24,970 --> 00:02:30,430 Like version control, peer review, automated deployments and automated testing. 32 00:02:30,910 --> 00:02:33,090 Which takes me to automated deployments. 33 00:02:33,150 --> 00:02:38,870 We wanted to make sure that our deployments as we ran them in different accounts and in different environments were the same. 34 00:02:38,930 --> 00:02:41,290 And the best way to do that is through automation. 35 00:02:41,290 --> 00:02:47,910 You can write a very long document with step by step pros of what to do, but if somebody's doing it, they're going to do something slightly different each time. 36 00:02:49,610 --> 00:03:00,790 A big part of what I'll be talking about today is we wanted to encourage defaults to be secure so that as development teams started rolling infrastructure, they would get secure defaults. 37 00:03:00,790 --> 00:03:12,550 And maybe they weren't even consciously getting them, but we were trying to take some of those decisions away from them so that when they just ran the thing the easiest way that we provided for them to do it, it would be secure. 38 00:03:13,470 --> 00:03:24,710 And finally, and this is a bit more of a migration over the next couple years, but I will touch on this later as we're starting to provide a platform as a service for our software delivery teams. 39 00:03:24,950 --> 00:03:40,210 And the idea here is that now that we've scaled infrastructure out and ownership out to across all of our software development teams, now we want to provide more abstractions for them to use to run their applications in the cloud. 40 00:03:42,960 --> 00:03:49,500 So I want to start by just talking about the programmability of the cloud and some of the things that it can get you. 41 00:03:49,500 --> 00:03:56,260 And it kind of hit me that there's pretty much four layers of making use of programmability with your infrastructure. 42 00:03:56,420 --> 00:03:58,660 The first is you have no automation. 43 00:03:58,660 --> 00:04:03,020 You do things by hand and you have people that really like doing things by hand. 44 00:04:05,200 --> 00:04:08,200 Eventually you start to script up some of your work. 45 00:04:08,200 --> 00:04:15,000 If you've worked against a traditional infrastructure like a VMware, some of those have been a lot more difficult to automate. 46 00:04:15,200 --> 00:04:21,360 And part of the programmability of the cloud, it makes that a lot easier and a lot more reproducible. 47 00:04:21,400 --> 00:04:25,920 As you begin to progress, you'll get into DevOps and continuous delivery. 48 00:04:26,140 --> 00:04:30,560 And again, now we're fully taking advantage of the cloud for our deployment reasons. 49 00:04:30,560 --> 00:04:36,900 But the final level of taking advantage of cloud programmability is using it for evil. 50 00:04:39,160 --> 00:04:41,000 So I'm going to hit with just one quick thing. 51 00:04:41,000 --> 00:04:45,160 We had an accidental commit to GitHub of some AWS access keys. 52 00:04:47,540 --> 00:04:51,820 And I don't know if anyone's experienced that, but what do you think happened? 53 00:04:54,320 --> 00:04:56,400 GitHub, it was public. 54 00:04:56,960 --> 00:04:59,280 You don't get to answer because you know what happened. 55 00:05:00,880 --> 00:05:14,120 We might talk about this in threat modeling and your threat might, like your impact could go all the way up to someone could potentially like encrypt all of your data or delete or destroy all of your data in that account. 56 00:05:14,120 --> 00:05:15,920 Destroy all of your infrastructure. 57 00:05:16,440 --> 00:05:26,480 But because of the automated nature of the programmability of the cloud, what happened was a bot found that on GitHub and then just started launching instances to mine cryptocurrency. 58 00:05:27,060 --> 00:05:28,980 So there was really no damages. 59 00:05:30,420 --> 00:05:33,260 There weren't any damages to our infrastructure. 60 00:05:33,460 --> 00:05:38,740 Amazon noticed this within a few minutes and disabled the account and it was a development account. 61 00:05:38,820 --> 00:05:41,180 So it wasn't our production account that was disabled. 62 00:05:42,400 --> 00:05:49,240 But it's kind of that idea that if you're not ruthless enough in attacking someone else is going to take that place. 63 00:05:49,240 --> 00:05:53,440 And there was a very small window of opportunity where somebody could do damage. 64 00:05:53,460 --> 00:06:09,060 And it seemed like the lowest, like if you talk about like electricity is going to follow the path of least resistance, the attack was one of convenience and it cost I think about $800 when it was done because we got stuff shut down really quick. 65 00:06:09,060 --> 00:06:11,020 So in the end it wasn't that bad. 66 00:06:11,600 --> 00:06:16,880 But I just wanted to point out that you can use the same programmability of the cloud for both good and evil. 67 00:06:19,020 --> 00:06:26,980 So as we're migrating into this mode of DevOps, we started trying to figure out how are we going to be able to do more with less. 68 00:06:27,020 --> 00:06:30,440 And I don't mean do more, like do less security. 69 00:06:30,440 --> 00:06:32,220 We wanted to do more security. 70 00:06:32,220 --> 00:06:41,340 But since things are now spread out across development teams without hiring teams and teams of individuals focused on security, we weren't going to be able to keep up with development. 71 00:06:41,580 --> 00:06:45,960 So we have to start spreading some of that out across the teams. 72 00:06:49,550 --> 00:06:57,830 I'm going to talk now about a few of the open source things that we use to both help with that issue we had with the GitHub push of the keys. 73 00:06:58,030 --> 00:07:04,570 And also solve a number of our other security issues in the cloud. 74 00:07:04,570 --> 00:07:07,030 And the first is a product from HashiCorp called Vault. 75 00:07:07,030 --> 00:07:07,990 I don't work for them. 76 00:07:07,990 --> 00:07:13,770 I'm a huge fan and their open source product gets you a lot of things you wouldn't even expect. 77 00:07:13,770 --> 00:07:20,930 Like companies that do open source sometimes will save the LDAP integration or the UI for the commercial versions. 78 00:07:20,930 --> 00:07:24,090 But they've got so much in their open source that it's almost unbelievable. 79 00:07:24,750 --> 00:07:40,190 But what Vault is, and this is right from their website, it's a product to secure, store and tightly control access tokens or access to tokens, passwords, certificates, encryption keys for protecting secrets and other sensitive data using a UI, CLI or an HTTP API. 80 00:07:40,770 --> 00:07:42,570 So it does a lot of stuff. 81 00:07:42,570 --> 00:07:45,670 And they kind of flag it as security as a service. 82 00:07:45,670 --> 00:07:49,830 You've got this very secure box that does all these things for you. 83 00:07:50,290 --> 00:07:52,670 We're not using it for all of its uses. 84 00:07:52,830 --> 00:07:56,470 We are using it, uh, for these use cases. 85 00:07:56,490 --> 00:07:58,730 We're using it to store static secrets. 86 00:07:58,730 --> 00:08:01,950 Things using its key value secrets engine. 87 00:08:02,030 --> 00:08:05,150 And these would be things like passwords to back end services. 88 00:08:05,150 --> 00:08:09,130 If we had like access to a third party API and we needed to store some sort of key. 89 00:08:09,230 --> 00:08:11,810 Um, that's a piece of information that does not change. 90 00:08:11,810 --> 00:08:14,350 We need to store and access that securely. 91 00:08:17,790 --> 00:08:20,790 Vault also has the potential to deal with dynamic secrets. 92 00:08:20,790 --> 00:08:22,650 And these are things that can change. 93 00:08:22,950 --> 00:08:28,770 And the idea of them changing is interesting because it allows you to lease them for a certain amount of time. 94 00:08:29,930 --> 00:08:35,330 First that we, the first, uh, dynamic secret engine that we use is one for Postgres. 95 00:08:35,850 --> 00:08:49,230 Um, historically, when we were on prem, the vast majority of our databases were running Microsoft SQL server and we had them on our domain and we used integrated Windows authentication between applications in the database. 96 00:08:49,490 --> 00:08:55,910 And then when users needed to get access to those databases, we granted, you know, put them in roles based on their domain account. 97 00:08:55,950 --> 00:09:02,470 We wanted something similar, but with the dynamic nature of the cloud and things coming up and down all the time, we didn't want that coupling to a domain. 98 00:09:02,470 --> 00:09:09,110 So we've not made any attempt as we started to move into Postgres to get those onto our domain or to do LDAP authentication. 99 00:09:09,330 --> 00:09:20,650 Uh, but one thing that Vault can do is it can dynamically generate me, if I'm a developer, a username and password to access that Postgres server that's good for an hour. 100 00:09:20,750 --> 00:09:30,350 So Vault will authenticate me on our domain and then I have access to a policy that lets me generate a username and password for a specific Postgres instance. 101 00:09:30,350 --> 00:09:32,510 And it's good for a certain amount of time. 102 00:09:33,110 --> 00:09:37,210 So it gets us effectively the same thing without the database having to be tied to our domain. 103 00:09:38,010 --> 00:09:45,890 Uh, the second thing is that after our incident with the GitHub push of the access keys is we don't issue access keys to anybody anymore. 104 00:09:46,850 --> 00:09:58,250 Vault has an AWS secrets engine where me as a developer, I can authenticate to Vault using my domain credentials and then I can request a key pair that's good for a certain amount of time. 105 00:09:58,250 --> 00:09:59,290 And there's a maximum. 106 00:09:59,290 --> 00:10:01,170 I have an example of how we do this. 107 00:10:01,450 --> 00:10:07,850 Um, but then if that key got leaked, that would further limit the usefulness of the how, what you could do with it. 108 00:10:08,790 --> 00:10:15,290 Um, and the third thing that we're using it for right now is one time password to log into EC2 instances. 109 00:10:15,510 --> 00:10:20,550 It can do the same thing for, uh, Linux servers that it can do for like Postgres. 110 00:10:20,550 --> 00:10:24,870 It can generate a username and password that you can use to log in and it's only good for so long. 111 00:10:27,350 --> 00:10:32,730 Okay, so authentication to Vault, um, all of the components to Vault are pluggable. 112 00:10:32,730 --> 00:10:34,590 So you can authenticate to it different ways. 113 00:10:34,590 --> 00:10:41,730 We use LDAP for our user accounts and then with systems that are running in AWS, they'll use IAM to authenticate. 114 00:10:41,970 --> 00:10:46,570 Um, you can also use username and password or GitHub or any other mechanism, but it's all pluggable. 115 00:10:47,170 --> 00:10:53,930 Um, but I wanted to show really quick from the CLI how, I hope this is visible in the back, how we authenticate to Vault. 116 00:10:53,930 --> 00:11:03,630 We set our Vault adder environment variable to point at our Vault server and then we just issue a Vault login method LDAP and username equals whatever my LDAP username is. 117 00:11:03,750 --> 00:11:05,330 In a few seconds, it comes back. 118 00:11:05,330 --> 00:11:06,690 It issues me a token. 119 00:11:06,970 --> 00:11:10,130 That's good for, according to the output, 60 minutes. 120 00:11:12,310 --> 00:11:15,870 And at the bottom, you can see the policies that I have access to. 121 00:11:15,870 --> 00:11:22,290 This is in our development tier, so in this tier, I'm effectively an admin and you can see I have access to three policies. 122 00:11:22,290 --> 00:11:32,650 One is AWS API engineer, meaning that I'm an engineer that's going to use the CLI or the SDK to access AWS and that's what lets me generate access keys for AWS. 123 00:11:32,650 --> 00:11:39,710 Uh, there's the EC2 user OTP for one time passwords to let me generate one time passwords. 124 00:11:39,710 --> 00:11:43,230 Uh, this is the admin level, so this would be to any EC2 instance. 125 00:11:43,950 --> 00:11:48,950 And secrets read write allows me to get access to the key value store. 126 00:11:49,210 --> 00:11:55,590 You can make these policies as granular as you wish and they can be specific to just one path involved. 127 00:11:55,590 --> 00:12:08,990 So you might have an application secrets at slash secrets slash my application and if you have a team that operates just that application, you can define your policies so that they can just get access to secrets under that path. 128 00:12:09,650 --> 00:12:16,430 Uh, but these policies are pretty broad, uh, since I am an admin on this, uh, tier. 129 00:12:17,730 --> 00:12:22,870 Uh, the next piece is just an example of how you interact with the key value secrets engine. 130 00:12:24,290 --> 00:12:28,470 In this case, I'm issuing a vault KV get command. 131 00:12:28,470 --> 00:12:33,270 I'm asking for a specific field because what we store at those keys are JSON documents. 132 00:12:33,270 --> 00:12:37,530 So you can have any number of, uh, key values within that one document. 133 00:12:37,550 --> 00:12:46,090 Um, I'm asking for a field called gossip encryption key and it's at the path secrets slash console, which is another product we're working to roll out. 134 00:12:46,350 --> 00:12:49,010 Um, and then the output is simply the secret. 135 00:12:49,010 --> 00:13:00,350 So what would happen is the application that needs access to this secret would have an IAM policy defined that would get them access to a vault policy which says I can read this secret. 136 00:13:00,350 --> 00:13:12,570 And then when those instances run, when they start up, part of their bootstrap script will be to authenticate the vault using IAM and get this information and most likely, uh, plop it into an environment variable for the process. 137 00:13:14,610 --> 00:13:18,030 So at no point do we need to build these secrets into our images. 138 00:13:18,030 --> 00:13:23,650 We request them at runtime or at start time and then they become part of the environment for whatever process needs them. 139 00:13:25,530 --> 00:13:30,030 A quick example of how we generate secrets for Postgres. 140 00:13:31,650 --> 00:13:38,210 This look, the syntax is a little bit different, but in this case we have a databases secrets engine for a specific database . 141 00:13:38,210 --> 00:13:40,690 So it would be databases slash myDB. 142 00:13:40,930 --> 00:13:47,250 And then when you configure it, you define policies within there for like read only or read write. 143 00:13:47,250 --> 00:13:52,410 And then that ties back to the permissions that the Postgres users have on your underlying database. 144 00:13:52,430 --> 00:14:06,890 But if I issue a vault read databases myDB slash cred slash read only, you'll see it issues me a lease for one hour and it gives me a username and a password which I can then use to go attach to that Postgres instance. 145 00:14:06,910 --> 00:14:09,730 After an hour, it's expired and does not work anymore. 146 00:14:12,190 --> 00:14:24,910 Likewise for AWS, for as a developer, when I need access to a key pair to use, I will issue a vault write to AWS slash STS slash in this case engineer. 147 00:14:25,250 --> 00:14:30,490 And the way this manifests is then I will assume an engineer role within AWS. 148 00:14:30,490 --> 00:14:43,070 We define a role and if you've ever used federation or done any type of role assumption, you're not logging in with an IAM user, you're logging in, you're authenticating some other way and then you're assuming a role within IAM. 149 00:14:43,390 --> 00:14:51,750 So when I issue this vault write and when I put this together, I asked for a TTL of 600 minutes just to see what would happen because I didn't know. 150 00:14:52,130 --> 00:14:56,310 And it did issue me a one hour, it was maxed at one hour lease. 151 00:14:56,430 --> 00:15:03,370 So the token I got back was good for one hour and then I get an access key, a secret key and a token which I can use to run AWS configure. 152 00:15:04,170 --> 00:15:12,310 I did have to abridge part of this security token but the access key and secret key were actual keys for our accounts but I'm confident that they are no good anymore. 153 00:15:12,410 --> 00:15:13,990 So I'm showing them at DEF CON. 154 00:15:14,590 --> 00:15:15,950 Get a picture. 155 00:15:18,280 --> 00:15:19,940 It will be in the slides. 156 00:15:20,100 --> 00:15:41,340 For one time passwords, I want to connect as an operations person to an EC2 instance and the way I do that is by issuing another vault write to SSH slash creds, that's the secrets engine for a read user OTP, this is read only access to an EC2 server and I give it the IP address. 157 00:15:41,400 --> 00:15:50,240 It again has a lease duration of one hour and it outputs the username to use, read user and the key which is the password. 158 00:15:50,740 --> 00:15:55,800 So then you can just do a regular username password SSH onto that EC2 box. 159 00:15:56,860 --> 00:15:58,780 Nothing to clean up after an hour. 160 00:15:59,800 --> 00:16:02,200 So that's kind of a lot of what we're doing with vault. 161 00:16:02,820 --> 00:16:12,220 The next thing I want to talk about is something that we've deployed in order to enforce policies against our AWS configuration itself. 162 00:16:12,380 --> 00:16:20,920 Everyone's seen the news, company releases a public S3 bucket and someone finds a bunch of data or something else is misconfigured and there's a big data leak. 163 00:16:21,460 --> 00:16:29,560 But with teams owning their own infrastructure, we have deployed a product from Capital One, that's open source called Cloud Custodian. 164 00:16:35,960 --> 00:16:36,800 Yeah. 165 00:16:36,940 --> 00:16:38,060 Right. 166 00:16:38,160 --> 00:16:39,060 Well, maybe they do. 167 00:16:39,060 --> 00:16:41,260 Maybe they don't have their policies defined correctly. 168 00:16:42,560 --> 00:16:46,480 But what we're getting from Cloud Custodian is the configuration governance. 169 00:16:46,480 --> 00:16:49,040 Again, it's policy as code. 170 00:16:49,100 --> 00:16:53,560 We get automated checking and enforcement of infrastructure that gets deployed. 171 00:16:53,560 --> 00:16:55,740 And we're running multiple AWS accounts. 172 00:16:55,740 --> 00:17:04,800 So even though this is a reactive thing, the infrastructure gets built and then Custodian notices it doesn't fit the policy and then it does something. 173 00:17:04,960 --> 00:17:10,200 But that happens in our development account, which is before it would get up to production, theoretically. 174 00:17:11,740 --> 00:17:13,600 It does get us policy as code. 175 00:17:13,600 --> 00:17:16,700 So again, we have automated deployments of our policy. 176 00:17:16,700 --> 00:17:20,340 We have peer review of our policy and we have version control. 177 00:17:21,100 --> 00:17:27,140 And it also supports notifications for notifying owners of systems. 178 00:17:27,300 --> 00:17:32,740 Again, if you're operating in a DevOps mode, teams are owning their own systems and infrastructure. 179 00:17:33,000 --> 00:17:36,940 So we have been tagging resources in AWS with who owns what. 180 00:17:37,300 --> 00:17:48,800 So as part of that, since we have an email or an SNS topic as a tag on our resources in Amazon, Custodian can look at those tags in order to figure out how to deliver a notification that it did something. 181 00:17:50,240 --> 00:17:56,760 So one of the key pieces of Custodian when we looked at it for us was that it does have the ability to take action. 182 00:17:57,320 --> 00:18:03,600 And what I was trying to not do and something that in my mind does not scale well is to just have a tool that gives you a list of work to do. 183 00:18:03,660 --> 00:18:07,460 If you just get a list of all the problems, then you have to go do all that work. 184 00:18:07,480 --> 00:18:14,940 And it would be much more preferable if you could instead have it automatically take some action where it makes sense. 185 00:18:15,860 --> 00:18:22,380 And I want to show you what one of the example policies would look like before I talk too much more about that. 186 00:18:22,820 --> 00:18:25,360 But they're all defined with YAML. 187 00:18:25,360 --> 00:18:26,640 There's quite a lot on here. 188 00:18:26,980 --> 00:18:32,840 But effectively, this is a policy that we have written for unencrypted S3 buckets. 189 00:18:32,980 --> 00:18:38,260 We wanted to just encrypt everything so we didn't have to deal with figuring out what type of data was in there. 190 00:18:38,360 --> 00:18:41,360 So we wanted to make sure that buckets were encrypted. 191 00:18:41,600 --> 00:18:48,020 So there's a resource type, which is AWS S3, ensure that S3 buckets are encrypted. 192 00:18:48,400 --> 00:18:50,240 And then there's a mode. 193 00:18:50,240 --> 00:18:55,580 And what's interesting about Custodian is when you deploy it, you can run it several different ways. 194 00:18:55,580 --> 00:18:58,240 You can run it as a batch job from a CLI. 195 00:18:58,240 --> 00:19:02,480 It's just a Python module that can be run as a batch task. 196 00:19:02,480 --> 00:19:10,020 It can deploy automatically into AWS Lambda to run scheduled Lambdas or Lambdas that are triggered by CloudTrail events. 197 00:19:10,120 --> 00:19:15,040 Or it can generate CloudTrail rules inside of AWS. 198 00:19:15,540 --> 00:19:21,720 The method that we're using for most things is to do periodic scheduled Lambdas, hence the rate of five minutes. 199 00:19:21,780 --> 00:19:23,320 So this will run every five minutes. 200 00:19:23,320 --> 00:19:24,500 So again, it's reactionary. 201 00:19:24,500 --> 00:19:33,980 Within five minutes, though, in our development tier, what it's going to do then, if it finds, you notice in the filters it says bucket encryption state false. 202 00:19:34,100 --> 00:19:38,320 Any buckets that are not encrypted, it's going to execute the actions for. 203 00:19:38,560 --> 00:19:42,600 And in this case, the action we have is type set bucket encryption. 204 00:19:43,060 --> 00:19:49,060 So while we could take a more heavy handed approach and delete the bucket, we are trying our best to take a less heavy handed approach. 205 00:19:49,060 --> 00:19:55,420 And if we can just make it okay and then let the person know that we made it okay, or the owners know that we made it okay, we're trying to do that. 206 00:19:55,420 --> 00:20:00,020 So in this case, it will get encrypted and then owners will get notified. 207 00:20:00,860 --> 00:20:07,160 So how the notification works, it has a mailer component that is part of it. 208 00:20:07,700 --> 00:20:14,020 And the mailer component, you give it a little template for like an email message. 209 00:20:14,020 --> 00:20:20,360 I think it can integrate with some other services, too, because really what it does is it fires off a message into an SQS queue. 210 00:20:20,500 --> 00:20:23,820 So you could consume that and do whatever you wanted with it. 211 00:20:23,820 --> 00:20:31,060 We're simply using it for an email notification, but with SQS you could go notify pager duty or some other type of end point. 212 00:20:32,280 --> 00:20:45,060 So what it does is it looks at, um, the, uh, the resource owner in the two, that's defined as part of our mailer configuration. 213 00:20:45,060 --> 00:20:49,980 And what we defined in our mailer configuration was to look for a certain number of tags. 214 00:20:49,980 --> 00:20:55,440 And we use owner email as a tag and we also use owner SNS topic as a tag. 215 00:20:55,440 --> 00:21:07,140 So if either of those tags are defined, it's either going to send an email to the email address that's under owner email, or it's going to notify an SNS topic that's listed in the owner SNS topic tag. 216 00:21:08,120 --> 00:21:11,100 And then there's a little template for the message that they get. 217 00:21:11,100 --> 00:21:15,000 So it'll say an S3 bucket that is unencrypted has been detected. 218 00:21:15,000 --> 00:21:16,720 The bucket has been encrypted. 219 00:21:17,520 --> 00:21:21,300 Uh, so we're using custodian for a ton of things. 220 00:21:21,460 --> 00:21:35,860 We're using it for, um, deregistering old AMIs that aren't being used, for whitelisting AWS services, adding security groups, patching, and adding security group to patching for running or to running EC2 instances. 221 00:21:37,280 --> 00:21:52,320 Let's talk a little bit now about, uh, scanning and some of the things we've had to do because we are running immutable servers or servers as cattle where we don't want to fix them, we don't want to patch them, we want to patch the image and then destroy them and have them come back from a new image. 222 00:21:53,340 --> 00:22:01,380 So one of the issues that this caused for us is that if we defined a bunch of scans that had instances running, those instances might not be around for very long. 223 00:22:01,420 --> 00:22:06,300 Uh, so when they went away, we'd have to go back and update all of our scans. 224 00:22:06,780 --> 00:22:10,740 So we wanted to eliminate any manual effort to update our scan configurations. 225 00:22:11,120 --> 00:22:22,680 We decided to group instances logically by owner, so the host doesn't matter, the IP doesn't matter, what we, what matters is who owns the instance that's running at this point in time. 226 00:22:22,680 --> 00:22:26,020 And we wanted to support custom scans based on tags. 227 00:22:27,500 --> 00:22:33,320 So really we have two approaches to this and each of them relied on a lambda. 228 00:22:33,760 --> 00:22:50,740 Um, in the first case, we are using, we are integrated with tenable IO for scanning instances and there is a method of scanning where you scan from your scanner and you have a scanner running which is in the lower left and again we're running that in an auto scaling group of one so that might go away at any given time. 229 00:22:50,840 --> 00:22:56,980 So what we have to do is we run a lambda every so often to update the scanner on the scans that are defined. 230 00:22:57,280 --> 00:23:05,980 So when this gets destroyed and comes back as a new host, we'll then go update it on any scans that it was supposed to be defined on and that's all based off of tags. 231 00:23:06,500 --> 00:23:13,660 Likewise with EC2 instances, we have another lambda that based on tags will add them to appropriate scans. 232 00:23:13,660 --> 00:23:20,360 So if we want to do an agent based scan, or sorry, a scanner based scan, um, we can do that. 233 00:23:20,780 --> 00:23:22,640 And we don't have to maintain it. 234 00:23:22,640 --> 00:23:25,660 The lambda runs every so often and then the scan gets updated. 235 00:23:26,000 --> 00:23:30,180 Um, and then you see that little, that red box is a security group that's around those instances. 236 00:23:30,180 --> 00:23:34,660 We have a custodian policy that adds the rule so that the scanner can get in. 237 00:23:34,960 --> 00:23:36,420 Uh, so that's one scenario. 238 00:23:36,940 --> 00:23:39,840 Uh, another scenario is agent based scanning. 239 00:23:39,840 --> 00:23:48,720 We've updated all of our base images to include a tenable agent so that when new systems get launched, they'll automatically have the tenable agent installed. 240 00:23:48,720 --> 00:23:51,360 So when they come up, they'll register, they'll show up as an agent in tenable. 241 00:23:51,720 --> 00:23:59,800 Um, but we can't add them to a group or add them directly to a scan because if they get destroyed, it's going to go away and then they would have to be manually updated. 242 00:24:00,260 --> 00:24:05,040 So we did another thing based off of that owner email tag where we grouped them logically. 243 00:24:05,040 --> 00:24:11,260 We created, we created agent groups inside of tenable for each owned group of servers. 244 00:24:11,880 --> 00:24:17,960 And we have a lambda that runs that adds the agents to the relevant groups. 245 00:24:17,960 --> 00:24:24,300 When agents go offline, they automatically get cleaned up after a day or two based on the tenable configuration. 246 00:24:24,560 --> 00:24:31,420 Um, but for any instances that came back after having been destroyed, the lambda runs and then they get added to the groups. 247 00:24:31,420 --> 00:24:38,120 So we're able to define scans to scan machines that are in agent groups and we don't have to do any maintenance for when those machines go away. 248 00:24:41,810 --> 00:24:51,030 Uh, two other quick things I'm going to touch on are just how we're using two other products from HashiCorp, Packer for building images and Terraform for launching our infrastructure. 249 00:24:51,310 --> 00:24:53,910 And these are in the vein of that secure by default. 250 00:24:54,170 --> 00:25:02,650 Uh, so this is sort of the start of our platform as a service mentality where we're providing things for people to consume so that it's easy for them. 251 00:25:02,730 --> 00:25:10,770 Um, this is a, a sample Packer build template that we have for, uh, Amazon Linux and this is our base template that all the teams use. 252 00:25:10,770 --> 00:25:12,610 And then they just pass variables into it. 253 00:25:12,610 --> 00:25:17,370 So as a cloud development team, we created this initially and then all the teams started using it. 254 00:25:17,370 --> 00:25:26,390 And a, a few of the security features I have highlighted that went into the initial version so that any team that consumed this just got those and they didn't even have to think about what to set them to. 255 00:25:26,390 --> 00:25:34,690 Uh, the first is that when they select a source AMI based off of a filter, it restricts it to just instances or images that are owned by our accounts. 256 00:25:35,290 --> 00:25:40,790 Um, we're also encrypting the boot volume by default and applying a tagging policy. 257 00:25:42,990 --> 00:25:51,690 Uh, with Terraform, we've started, you know, Terraform could be a talk all by itself, um, but just a one shot here of some of the things we're doing. 258 00:25:51,690 --> 00:25:57,330 With Terraform , you deploy resources and then any group of Terraform code can be used as a module. 259 00:25:57,330 --> 00:25:59,990 So we've defined reusable modules for a lot of things. 260 00:25:59,990 --> 00:26:17,410 One of them, this is an example of us, uh, using our web farm module where a consumer of this just has to specify some information like which VPC, their service port, min and max size, um, what their health check path is and then if they want an auto scaling notification, 261 00:26:17,410 --> 00:26:18,810 they can pass an ARN. 262 00:26:19,110 --> 00:26:25,570 Um, but what they get from this is all the infrastructure designed as we saw fit to architect it without having to launch a load balancer. 263 00:26:25,570 --> 00:26:28,450 Make sure it was in the public subnet if they were internet facing. 264 00:26:28,530 --> 00:26:30,970 Do all, make sure all their instances are in the private subnet. 265 00:26:30,970 --> 00:26:33,050 Get everything registered with DNS properly. 266 00:26:33,050 --> 00:26:34,550 So it does all that for them. 267 00:26:36,350 --> 00:26:39,750 Um, I have some stuff of what, what went not, not so well. 268 00:26:39,750 --> 00:26:48,190 I'm running out of time so I will, I'll, I'll leave this up here for a second and then we can take any questions out into the hallway. 269 00:26:48,430 --> 00:26:53,470 Um, but really it was our pace that made us kind of be, start playing catch up from the beginning. 270 00:26:53,490 --> 00:26:56,910 Um, so we started doing a lot of work before we had custodian deployed. 271 00:26:57,050 --> 00:27:01,010 Teams started rolling their own Terraform before we had modules for everything. 272 00:27:01,450 --> 00:27:02,710 Um, so it's stuff like that. 273 00:27:02,710 --> 00:27:11,910 We have a lot of work we still want to do and one of the cool things about DEF CON is I'm sure everyone has great ideas for me, uh, on how we can take this further or alternative ideas. 274 00:27:11,910 --> 00:27:15,210 So if we could chat about that in the hall, uh, that would be great. 275 00:27:15,210 --> 00:27:17,830 I will hang around for as long as people want to talk. 276 00:27:19,470 --> 00:27:20,490 Thank you. 277 00:27:23,490 --> 00:27:24,210 All right. 278 00:27:24,210 --> 00:27:25,470 We got five more. 279 00:27:26,210 --> 00:27:26,850 Okay. 280 00:27:31,370 --> 00:27:32,690 All right. 281 00:27:32,750 --> 00:27:34,190 Thought he was waving me off. 282 00:27:34,190 --> 00:27:35,570 So all right in the back. 283 00:27:41,670 --> 00:27:42,270 Yeah. 284 00:27:42,270 --> 00:27:46,530 So when we, we automate, we use Chef to build images with Packer. 285 00:27:46,570 --> 00:27:53,090 Uh, Packer builds the image and you can, you do VMware or EBS on Amazon or several other formats. 286 00:27:53,090 --> 00:27:54,490 And then there's different provisioners. 287 00:27:54,490 --> 00:27:55,330 So we use Chef. 288 00:27:55,490 --> 00:27:59,150 Um, as part of our Chef, we use InSpec to run, uh, tests. 289 00:27:59,170 --> 00:28:03,770 So as part of our image build pipeline, we'll run all of our tests before they get merged back to master. 290 00:28:03,870 --> 00:28:06,690 And then that'll build us our real AMIs. 291 00:28:06,890 --> 00:28:14,370 Um, with Terraform, we've had with the modules, what we'd like to do is run a quick smoke test to stand up an instance of that module. 292 00:28:14,370 --> 00:28:20,910 So a web farm, or, um, we have another one for like, uh, an RDS, uh, Postgres instance. 293 00:28:20,950 --> 00:28:24,270 So we'll have a test to stand that up and then tear it down. 294 00:28:24,270 --> 00:28:26,530 There's a lot more that we could be doing with some of that. 295 00:28:26,530 --> 00:28:28,310 Um, but that's just what we've done so far. 296 00:28:29,270 --> 00:28:30,070 Yeah. 297 00:28:31,010 --> 00:28:32,070 In the hat. 298 00:28:38,800 --> 00:28:39,500 The tags. 299 00:28:39,500 --> 00:28:42,420 So our tagging structure, I think, is fairly standard. 300 00:28:42,560 --> 00:28:48,860 We use tags, application for which application it's part of, environment, which environment it's running in. 301 00:28:49,360 --> 00:28:55,860 Um, because in some accounts, we might have more than one environment running, like QA or integration testing on like a middle tier. 302 00:28:56,020 --> 00:28:57,580 Um, and then we have role. 303 00:28:57,580 --> 00:29:02,940 So the role within that application and environment, like database or web server. 304 00:29:03,080 --> 00:29:06,660 Uh, so those are the primary tags we use for grouping things. 305 00:29:06,660 --> 00:29:14,140 Um, and then as far as ownership goes, we use those owner email tags or SNS topics to keep track of who owns what. 306 00:29:14,620 --> 00:29:16,820 Um, yeah. 307 00:29:19,600 --> 00:29:20,300 Yeah. 308 00:29:23,500 --> 00:29:24,920 You would think so. 309 00:29:26,340 --> 00:29:30,080 Um, I have more details out there. 310 00:29:30,080 --> 00:29:40,520 It's, it's kind of a long discussion, but, um, they kind of force us into a mode where we weren't able to take advantage of some of the stuff like AWS organizations and control tower and some of that stuff they have. 311 00:29:41,640 --> 00:29:42,460 It is. 312 00:29:42,460 --> 00:29:46,060 It didn't exist when we, uh, when we first started working with them. 313 00:29:46,060 --> 00:29:49,000 And then they, we just haven't evolved it around. 314 00:29:49,000 --> 00:29:51,940 I don't even know if they support it yet, but we have to work with them on that. 315 00:29:53,580 --> 00:29:54,300 Uh, not yet. 316 00:29:54,300 --> 00:29:55,840 I got about a minute. 317 00:30:03,260 --> 00:30:04,220 Oh yeah. 318 00:30:09,080 --> 00:30:18,600 Well, when teams update the code, if they violate the policy, they're going to, that action is going to run, which may be turn on encryption if it's not there, but it may be destroy the resource. 319 00:30:19,260 --> 00:30:31,300 And we have had some race conditions with things like, um, if you deploy a load balancer, we wanted to make sure that you had an HTTPS listener so that you weren't just rolling an unencrypted web service. 320 00:30:31,440 --> 00:30:35,320 So the, but the problem is the load balancer gets deployed before the listeners. 321 00:30:35,320 --> 00:30:38,960 And then the policy was catching that and destroying things before the whole thing was done. 322 00:30:39,080 --> 00:30:45,720 Uh, likewise with tagging on instances, if we wanted to make sure things were tagged, uh, tagging is a separate operation. 323 00:30:45,720 --> 00:30:48,580 That's when Terraform stands up, uh, an EC2 instance. 324 00:30:48,580 --> 00:30:55,380 And that might be because of the AWS API, uh, but it'll create the instance and then subsequently apply the tag. 325 00:30:55,380 --> 00:30:58,300 So if custodian runs in between those two, it's going to say, you don't have tags. 326 00:30:58,300 --> 00:31:00,180 I'm going to destroy you. 327 00:31:00,600 --> 00:31:01,880 Yeah, we can go out in the hall. 328 00:31:01,880 --> 00:31:02,280 Yeah.