Securing Severless: Defend or Attack?Securing Severless: Defend or Attack?
The best way to protect your cloud infrastructure is to pay attention to the fundamentals of application security, identity access management roles, and follow configuration best-practices.
October 25, 2018
Part one of a two-part series. Click here to read Ory Segal’s Securing Serverless: Attacking an AWS Account via a Lambda Function
Lambdashell started as a debate between myself and a friend. His questions were, How do I secure serverless? What vendors can solve this? On the other hand, I took a different perspective and my questions were, Is serverless a security problem? Do you need to secure serverless? What is the actual risk? What are the actual attacks against serverless?
To settle this debate I decided to create www.lambdashell.com, which is a serverless function that is a security nightmare. The function takes a command and goes straight to a command shell. It is remote command execution right into an AWS infrastructure and could be considered the worst security move anyone could make. I then placed a bounty of $1,000 to be able to find an issue in Lambda. Pointed the Internet to it and sat back and watched it play out.
The attacks came in fast and furious — various methods were attempted to break out of lambda or access something outside of the very contained environment. The only issues that came up were "denial of wallet" attacks , where you can write millions of logs, or execute the function millions of times to cause cost of usage to rise. This, by far, became the biggest headache: putting in preventative controls to ensure that the functionality and purpose of the project were not impaired while also maintaining cost control.
As the project ran, no attackers were unable to do anything of real interest. At this point I started going in and adding more real world scenarios and settings. I added a command history to the page to show what commands attackers were using. This required adding a database and multiple other lambda functions. I changed default permissions to be more permissive, allowing full access to S3 buckets and other execution permissions. I ensured that input for the commands were unfiltered so that injection attacks against the database were possible. At this point I was trying my hardest to enable an attacker to take over my account.
After making these changes and after having my site posted on hackernews , I finally started seeing some real attacks. The most fascinating were attempts at running cryptominers — even though the execution was limited to a three seconds before the process was killed. Attackers would continually run jobs in these three-second increments to mine crypto.
My next attack was against loose permissions on AWS logfiles. The attacks started filling up logs and attempting to overwrite existing logs. The one attack that finally succeeded was by Ory Segal, CTO and co-founder at Puresec, who identified that the lambda function had full permission to the S3 bucket that the site ran on. I had hoped that someone would find this and embed something fun in the main page of the site such as a crypto miner. Unfortunately, they ended up deleting the site completely.
At this point the issue was found, so I restored the site, removed the full write permission, and logged it as the first real finding since putting this out there.
What I learned from this experience re-enforces my feeling about security. Everything is about the fundamentals. At the end of the day, a strong defense is not merely about the newest tech. It's the basic plumbing and wiring around that tech that gives you your biggest bang for the buck. Pay attention to IAM (identity and access management) roles and configuration. If these are done correctly, it sets up a great blast container so even if something horrific happens, (such as remote command execution in your lambda function) the attacker has a very hard time going anywhere else. And even if they can — they will make a lot of noise doing it.
Black Hat Europe returns to London Dec 3-6 2018 with hands-on technical Trainings, cutting-edge Briefings, Arsenal open-source tool demonstrations, top-tier security solutions and service providers in the Business Hall. Click for information on the conference and to register.
About the Author(s)
Hacking Your Digital Identity: How Cybercriminals Can and Will Get Around Your Authentication MethodsOct 26, 2023
Modern Supply Chain Security: Integrated, Interconnected, and Context-DrivenNov 06, 2023
How to Combat the Latest Cloud Security ThreatsNov 06, 2023
Reducing Cyber Risk in Enterprise Email Systems: It's Not Just Spam and PhishingNov 01, 2023
SecOps & DevSecOps in the CloudNov 06, 2023
How to Use Threat Intelligence to Mitigate Third-Party Risk
Concerns Mount Over Ransomware, Zero-Day Bugs, and AI-Enabled Malware
Everything You Need to Know About DNS Attacks
Securing the Remote Worker: How to Mitigate Off-Site Cyberattacks
How Enterprises Are Managing Application Security Risks in a Heightened Threat Environment