Huntress Acquires Inside Agent: A New Era for Identity ProtectionFree Trial
Back to Blog
Cloud Security

Securing Serverless: Lambda Attack Surfaces Most Teams Overlook

Serverless does not mean secure. I have lost count of the number of times a client has told me "we moved to Lambda so we don't have to worry about server security." That is only partly true. You no lo…

30 Mar 20264 min read0 views

Introduction

Serverless does not mean secure. I have lost count of the number of times a client has told me "we moved to Lambda so we don't have to worry about server security." That is only partly true. You no longer patch operating systems, but the attack surface has shifted — not disappeared.

The Expanded Attack Surface

A typical serverless application involves Lambda functions, API Gateway, DynamoDB, S3, SQS, SNS, Step Functions, and a dozen IAM roles stitching it all together. Each of those services has its own configuration surface, and the interaction between them creates emergent risks that do not exist in monolithic applications.

The three biggest serverless vulnerabilities I encounter:

Event injection. Lambda functions are triggered by events — HTTP requests, S3 uploads, SQS messages, DynamoDB streams. If your function processes event data without validation, attackers can inject malicious payloads through any of those triggers. I have seen SQL injection through S3 object keys, command injection through SNS message bodies, and SSRF through API Gateway query parameters.

Over-permissive execution roles. Every Lambda function assumes an IAM role. In most environments I audit, that role has far more permissions than the function needs. One common pattern: a function that reads from a single DynamoDB table has dynamodb:* on Resource: *. The fix is tedious but straightforward — scope every permission to the exact resource ARN.

Dependency vulnerabilities. Lambda deployment packages include all your dependencies. A vulnerable npm package or Python library in your deployment package is just as dangerous in Lambda as it is on a traditional server. Run npm audit or pip-audit in your CI pipeline and fail the build on critical findings.

Securing the Invocation Chain

Lambda functions rarely work in isolation. A typical serverless workflow chains multiple functions through SQS queues, Step Functions, or EventBridge. Each hop in that chain is an opportunity for an attacker to inject, intercept, or redirect execution. The invocation chain is only as secure as its weakest link.

Validate input at every function boundary, not just at the API Gateway entry point. An S3 event that triggers a Lambda function should validate the bucket name, object key, and event type before processing. A function triggered by SQS should validate the message schema and reject anything unexpected. Treat every event source as untrusted, even internal ones — if an attacker compromises one function in the chain, they should not be able to pivot freely through downstream functions by crafting malicious events.

Use resource-based policies on Lambda functions to restrict who can invoke them. By default, any service in your account can invoke any function. Lock this down with aws:SourceArn conditions that restrict invocation to specific API Gateway stages, specific SQS queues, or specific EventBridge rules. This limits the blast radius when one component is compromised.

Cold Start Security Implications

Lambda cold starts are not just a performance concern — they have security implications too. During a cold start, your function initialization code runs before the handler. Secrets fetched during init (from Secrets Manager, SSM Parameter Store, or environment variables) are cached in the execution environment and persist across warm invocations. If an attacker gains code execution in a warm function, those cached secrets are available in memory.

Use short-lived credentials wherever possible. If your function accesses AWS services, rely on the execution role rather than fetching and caching long-lived API keys. For third-party API credentials, fetch them on each invocation rather than caching in global scope — the latency cost of a Secrets Manager call is a few milliseconds, which is negligible compared to the risk of credential exposure in a warm environment.

Monitoring Blind Spots

Traditional APM tools struggle with serverless because there are no long-running processes to instrument. Enable CloudWatch Logs for every function, but more importantly, enable CloudTrail data events for Lambda. Without data events, you will not see Invoke calls — which means you will not know who called your functions or with what payload.

AWS X-Ray gives you distributed tracing across services, which is essential for understanding the blast radius when something goes wrong. Lambda Powertools (for Python or TypeScript) adds structured logging and tracing with minimal code changes.

Set up CloudWatch Alarms for abnormal invocation patterns — sudden spikes in invocation count, unusual error rates, or functions being invoked from unexpected regions. These anomalies often indicate that an attacker is testing access or exfiltrating data through your serverless infrastructure.

Serverless is a powerful paradigm, but it demands a different security mindset. The infrastructure is abstracted, but the application logic and data flows are still yours to protect.

Comments

Keep Reading

Explore Related Topics and Insights

Insider Threat Detection Without Becoming Big Brother
EMERGING THREATS

Insider Threat Detection Without Becoming Big Brother

Insider threat programs have a PR problem. Announce that you are monitoring employee behavior and you will get pushback from HR, legal, works councils, and the employees themselves. And they are not w…

S

Spakto Team

30 Mar 2026
Read article →
Cloud Security Posture Management: Choosing and Deploying CSPM
CLOUD SECURITY

Cloud Security Posture Management: Choosing and Deploying CSPM

When I ran a cloud security assessment for a logistics company last year, we found 847 misconfigurations across their AWS and Azure environments. Seventeen of them were critical — including an S3 buck…

S

Spakto Team

30 Mar 2026
Read article →
Secure Code Review: What Senior Engineers Actually Look For
APPLICATION SECURITY

Secure Code Review: What Senior Engineers Actually Look For

Automated tools find about 40% of security vulnerabilities in code. The other 60% — business logic flaws, race conditions, authorization bypasses, and subtle injection vectors — require human eyes. Af…

S

Spakto Team

30 Mar 2026
Read article →
Threat Hunting: Moving From Reactive to Proactive Security
THREAT INTELLIGENCE

Threat Hunting: Moving From Reactive to Proactive Security

Your SIEM generates alerts. Your EDR generates alerts. Your firewall generates alerts. You triage them, you respond to them, you close them. And then one day you discover that an attacker has been in…

S

Spakto Team

30 Mar 2026
Read article →
Securing the Software Build Pipeline: From Code to Production
APPLICATION SECURITY

Securing the Software Build Pipeline: From Code to Production

Your CI/CD pipeline is the most privileged system in your organization. It has access to source code, secrets, production credentials, cloud provider APIs, and the ability to deploy code that your use…

S

Spakto Team

30 Mar 2026
Read article →
Building a Security Culture That Outlasts Your CISO
EMERGING THREATS

Building a Security Culture That Outlasts Your CISO

I have seen security programs thrive under one CISO and collapse under their successor. I have seen organizations where security is everyone's responsibility and organizations where it is "the securit…

S

Spakto Team

30 Mar 2026
Read article →
Zero-Day Markets: The Economics of Vulnerability Trading
EMERGING THREATS

Zero-Day Markets: The Economics of Vulnerability Trading

A zero-day exploit for iOS full-chain remote code execution with persistence is worth between $1 million and $2.5 million on the private market. An Android equivalent fetches $2 to $2.5 million. A Chr…

S

Spakto Team

30 Mar 2026
Read article →
OT/ICS Security: Bridging the IT-OT Divide
EMERGING THREATS

OT/ICS Security: Bridging the IT-OT Divide

I spent the first half of my career in IT security and the last decade increasingly focused on operational technology. The cultural divide between IT and OT is wider than the technical one, and until…

S

Spakto Team

30 Mar 2026
Read article →