AWS Bites Podcast

29. Is serverless more secure?

Eoin and Luciano take you through the ways serverless can give you more security out of the box. We cover the tradeoffs between having more security control and the responsibility that comes with this power. There are always new security challenges so we cover some of the common pitfalls with serverless and AWS security in general. Finally, we share some tips to make your serverless deployments more secure.

In this episode we mentioned the following resources:

Let's talk!

Do you agree with our opinions? Do you have interesting AWS questions you'd like us to chat about? Leave a comment on YouTube or connect with us on:

Eoin
00:21:55

Yeah it's a very difficult balance I don't think there's an ideal solution there so if you talk about okay I want to put my Lambda function in VPC so that I can access an RDS database and that's fine you can just ensure that you've got access to that RDS database and they're in the same VPC and there's no additional routing outside that like there's no internet gateway no NAT gateway so they can't exfiltrate data outside that network but at the same time you might have an existing on-prem system so you might have a VPC that allows you to route through to the company's corporate network so that it can access all of their existing on-prem systems and systems running in other clouds or whatever it is but you can imagine that in order to give network access to one of those systems you may have to give access to the corporate network in general and then think it becomes a little bit more onerous trying to restrict it down to a single IP address or a single host or set of hosts because giving an attacker through Lambda or through EC2 access to your full corporate network is seriously risky and usually your corporate network then access has access to the internet and you might have an intrusion detection system or intrusion monitoring system but suddenly your blast radius is seems quite large so it seems like I always kind of believed you know don't try and avoid VPCs unless you have to because you know you don't have to worry about the that level of that level of access and it's also a little bit more complexity and you suddenly have to think about network security seems less serverless once you start bringing in VPCs but like you say if you don't have a VPC you can't control data exfiltration very carefully because you'll have access to the internet so people can access their own hosts and take your secrets take any data they can pull from your S3 bucket and upload it to their host wherever it is on the internet there was a solution to this at one time which I know you've encountered Luciano called Function Shield but it looks kind of at least I know the company who developed a PureSec were acquired by Panao Total Networks so I think it's not maintained anymore it's been absorbed into some sort of commercial offering the idea behind that was that you could inject it into your lambda functions no matter what language you were using and it would make it harder to do disk access or network access or do other command execution in your lambda environment but yeah I'm not sure there anymore but so I don't think there's a valid alternative I'd be interested to hear if anybody else has a creative way of solving that problem of network access internet access from a lambda

Luciano
00:25:36

Yeah no there are an interesting few cases that some of them I've even encountered myself but I suppose that the point is that because you have units of computers that just spin up themselves and they can speed up in the order of thousands very very quickly there are a lot of situations where that might go against I suppose your benefits and for instance they can let's say it's an attack what can happen for instance that if you have somebody triggering a DDoS attack that DDoS attack might spin up a lot of lambdas for you and maybe you don't really see a negative effect in your infrastructure because the infrastructure can actually scale and take that attack but you might see a negative effect in your building because suddenly you are running I don't know maybe an order of magnitude more many lambdas that you generally run so probably your bill will increase proportionally to that so that that can be a dangerous side effect of serverless that should be taken under consideration even though it might not be strictly related to security. Another case that I had myself and this is also related to VPC and configuring your own VPC I had a case where I actually did configure very badly a VPC because I started to put lambdas in a subnet where there were also other services I think it was Elasticsearch an Elasticsearch cluster and living in the same subnet at some point there was a bug in the code where many lambdas were retrying because of a bug in a processing logic so it was failing and it was retrying and suddenly that generated a huge number of lambdas trying to compete to address that event that would never be fixed because there was a bug in the code so I basically saturated the subnet with lambdas trying to do something that I would never be able to do and that stopped Elasticsearch from scaling up because the Elasticsearch nodes couldn't be spun up because they couldn't get an IP address in that subnet so that was an interesting thing that very convoluted set of events but again the reason is that if you don't do your network security correctly network configuration correctly and you don't consider that lambda can scale massively in a very short amount of time then you might have this interesting side effects where lambda is actually competing with all your resources and it might have an impact on them not being able to scale as much as you expect so of course then we needed to fix the bug in the code we also changed the network configuration to isolate the lambdas in their own subnet rather than keeping them in a shared subnet and we fixed it that way but it was not something obvious it was not something we anticipated before we we actually encountered the problem so yeah I suppose that the we could probably finish this episode by summarizing what serverless doesn't really protect you against what do you think good idea yeah so yeah first of all we say you don't get protection from injections meaning that yeah it will be probably a little bit more complicated to inject arbitrary commands or I don't know SQL injection XML injection all sorts of injections you can think of it will be maybe a little bit harder because you you have one additional level of indirection because you have some sort of input that gets converted to one event and then your input is encapsulated in that event that will go into lambda but that doesn't really give you any security or perfect guarantee that people cannot perform injection attacks then you are still receiving external input the way you process that external input can lead to injection attacks and we also discussed about dependency poisoning so you are using third-party dependencies so those might be poisoned and those might create side effect and security vulnerabilities if you are not careful so one suggestion that is to use dependency scanners like SNCC is probably one of the most famous but there are a bunch of alternatives make sure you have a process as part of your CI CD or your deployment process to always keep your dependencies under control and make sure at least you scan them to to find commonly vulnerable dependencies and update them another risk is data tampering or data destruction again if code is executed in your environment malicious attacker can do all sorts of different things they can try to aspitrate data they can try to compromise data so that's you don't get many guarantees from serverless that that's not gonna happen to you maybe it's again a little bit harder but it can still happen and you need to put boundaries in place and yeah remote code execution is absolutely related to that because at that point an attacker can try to do anything not just as filtrate data but they can run any code they want so you might try to limit the exposure of a lambda but if you don't limit that correctly an attacker still can have a very big surface to use and yeah I think that that's all I have I think we we can put a bunch of links for more in-depth material for instance there is a good OWASP paper that gives you the top 10 vulnerabilities in kind of in a more serverless way so that they reconsider the top 10 OWASP from a serverless perspective and I think you will find some common points with what we discussed today but probably there is a lot more material there and then there is an interesting blog article from AWS that gives you a bunch of additional tips on how you can architect secure serverless applications so we'll put the link for that in the show notes as well. Okay anything else you want to add, Eoin?

Help us to make this transcription better! If you find an error, please submit a PR with your corrections.