Monitoring platform for keeping systems up and running at all times.
Full stack visibility across the entire stack.
Detect and resolve any incident in record time.
Conform to industry best practices.
We’ve seen time and again how serverless architecture can benefit your application; graceful scaling, cost efficiency, and a fast production time are just some of the things you think of when talking about serverless. But what about serverless security? What do I need to do to ensure my application is not prone to attacks?
One of the many companies that do serverless security, Protego, came up with an analogy I really like.
“It’s a bit like riding in an Uber vs. taking your own car. Sure, the drivers are probably more professional and perhaps better trained. And the flexibility of paying for a car only when you need it is great. At the same time, you don’t get to choose which safety features the car has or how many airbags you’ll have around you.”
From a developer perspective serverless architecture, switching to serverless is a great move as it allows them to focus on the product itself. At the same time, the platform on which the code executes is run by the province provider. What this means for security is that the patches themselves are being applied on time every time, which is one of the biggest “challenges” for traditional servers. Basically, the people responsible for the security updates either forget or just ignore said updates, leaving you and your data at great risk.
While the architecture has some clear advantages over its traditional counterpart, serverless has some security disadvantages. I’ll quickly go over a few, but you can read our Serverless Security article based on AWS Well-Architected Framework if you want to go into details.
Especially the last point, insufficient logging can lead to huge issues later. How do you know everything is going well if you can’t see what’s going on?
Having critical logs will help us, for example, understand which serverless security flaws attackers explored and how to fix them, or build a block list of IP addresses, or identify compromised customer accounts. Even though we can help ourselves without logs in some cases, they’ll buy us precious time and provide valuable insights that may save our business a lot of money – and, most importantly, our hard-earned reputation!
Remember: we are always at a disadvantage against an attacker. They planned everything and have been studying our app for some time. We receive no warning and know nothing about who we’re fighting against. Every bit of information helps us level the playing field.
Below are some examples of information we could classify as critical for logging in to a serverless app. It’s not an exhaustive list but will give us a good head start.
When analyzing or acting on a possible security breach, it’s helpful to retrace the attacker’s steps. Since the very start, we’ve got to log the inputs received by every function. You will lean towards logging only inputs from external sources, but logging every function invocation event would be beneficial.
Say you receive a request from an external source, which triggers a chain of processing steps involving multiple internal functions (not publicly facing). Even though you may have input validations on the publicly exposed function, parts of the input will probably make their way to the internal functions. The input could trigger unexpected behavior or unwanted side effects. In this case, it would be interesting to know what exactly reached the internal functions and what the results were in order to act accordingly in securing your app.
Similar to invocation inputs, logging response payloads is also helpful to analyze and mitigate security breaches. In the worst-case scenario of not stopping an attack, we will at least want to know what information is now in possession of the attackers.
A positive side effect of having response payloads inside logs is identifying possible bugs or unexpected behavior in our application by comparing expected and actual responses.
If our app starts suffering from bad performance in traditional server infrastructure, users might get mad, but we won’t be surprised by scary bills. Costs are usually variable in a serverless stack: the more we use, the more we pay.
If we plan that a function would run on average for three seconds and start taking thirty seconds, we need to act quickly not to burn our precious resources for nothing.
Knowing in which cases our app performs badly will help us improve our code and avoid financial headaches. What exactly you should be logging for this purpose will depend heavily on the use case and context, but in any case, it’s vital to have this in mind when planning the application critical logs.
Services like Dashbird not only make logging and debugging a breeze but also monitors your functions’ performance. Having every bit of information in one place will certainly save you time and money. A service like that can easily pay for itself; it’s really worth checking it out.
If our app has a protected area, it’s critical to log authentication requests, especially the failed ones. Make sure you also log everything you possibly can from the request, such as the IP address.
Look for odd requests or patterns. For example, you might see a spike in failed requests and find out that many of the usernames or email addresses aren’t even in your customer base. That could be someone scanning a list of leaked credentials to check potentially vulnerable accounts in your app. Since it’s fairly common for people to reuse passwords, they will likely find honey in our beehive. Take care of your bees; you’ve grown them with hard work.
Authentication logging can alert that someone is scouting our app for weak spots. It will allow us to take proactive measures to prevent unauthorized account access. Sources like Have I Been Pwned could be very helpful. In our example, knowing the usernames/emails in the attacker’s possession would help identify which leaked credentials list(s) they’re scanning. We can then search which of our customers had credentials exposed and preventively block their accounts, asking for a password reset.
Despite the little hassle, our customers will love to receive a preventive serverless security alert. Much better than “We’re sorry, but your account has – already – been violated, and we couldn’t do a thing to prevent it“!
Dashbird provides you with the number of occurrences of a given error over time. And it can alert by email and/or Slack. Imagine receiving a proactive alert: “34,985 authentication errors”. It can’t smell good and deserves attention, right?
In the scenario of a paid service, possibly exposed through an API, it’s good to log service usage indicators.
Consider we carefully planned our costs and pricing structures so that our business has a fair chance of financial success. Customers start doing the so much expected, magical thing: entering credit cards and using our app! Cheers! Sometime later, we get an invoice from our cloud provider, and the number isn’t what we expected.
How could we spend so much if we had half of it in revenue during the same period? Did we make a mistake dimensioning our costs and pricing? Maybe someone found a way to bypass our access authorization logic and is free-riding on our backs? What happened exactly?
In a scenario like that, it would be terrific to have detailed logs so that we can:
Based on the OWASP Logging Cheat Sheet recommendations, we should be logging: When, Where, Who, and What in every function invocation. That applies to all items we discussed above and any other logging scenario in our serverless app.
Dashbird gives you the observability you lack in your serverless environment while providing monitoring and alerting to help you get the most of your new serverless application.
We discussed only what we should include in our logs, but we also need to consider what should be excluded.
Hey, hey, not so fast logging the entire user object, buddy!
User-related information, in many cases, will contain personal or sensitive data that should never go into our logs. Make sure you filter this data out; otherwise, we might have problems with the European data privacy lords or worse! Wait, are there worse? Well, you get the point.
This article was inspired by The 6 Categories of Critical Log Information; you might want to check it out as well.
Further reading:
Log-based monitoring for AWS Lambda
AWS Lambda metrics that you should be monitoring
How Dashbird works
In this guide, we’ll talk about common problems developers face with serverless applications on AWS and share some practical strategies to help you monitor and manage your applications more effectively.
Today we are announcing a new, updated pricing model and the end of free tier for Dashbird.
In this article, we’re covering 4 tips for AWS Lambda optimization for production. Covering error handling, memory provisioning, monitoring, performance, and more.
Dashbird was born out of our own need for an enhanced serverless debugging and monitoring tool, and we take pride in being developers.
Dashbird gives us a simple and easy to use tool to have peace of mind and know that all of our Serverless functions are running correctly. We are instantly aware now if there’s a problem. We love the fact that we have enough information in the Slack notification itself to take appropriate action immediately and know exactly where the issue occurred.
Thanks to Dashbird the time to discover the occurrence of an issue reduced from 2-4 hours to a matter of seconds or minutes. It also means that hundreds of dollars are saved every month.
Great onboarding: it takes just a couple of minutes to connect an AWS account to an organization in Dashbird. The UI is clean and gives a good overview of what is happening with the Lambdas and API Gateways in the account.
I mean, it is just extremely time-saving. It’s so efficient! I don’t think it’s an exaggeration or dramatic to say that Dashbird has been a lifesaver for us.
Dashbird provides an easier interface to monitor and debug problems with our Lambdas. Relevant logs are simple to find and view. Dashbird’s support has been good, and they take product suggestions with grace.
Great UI. Easy to navigate through CloudWatch logs. Simple setup.
Dashbird helped us refine the size of our Lambdas, resulting in significantly reduced costs. We have Dashbird alert us in seconds via email when any of our functions behaves abnormally. Their app immediately makes the cause and severity of errors obvious.