> For the complete documentation index, see [llms.txt](https://martian1337.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/application-platform-security-reference/serverless-application-security-reference.md). Agents can also search and read this documentation through its [MCP server](https://martian1337.gitbook.io/notes/~gitbook/mcp).

# Serverless Application Security Reference

Serverless platforms run your code in response to events and operate the servers, operating system, and managed language runtime for you. The result is fewer hosts to patch and many more small pieces of code, each with its own entry points, identity, and configuration. This page is the defender's reference for function-as-a-service and event-driven applications (AWS Lambda, Azure Functions, and Google Cloud Run functions are the examples used): where the trust boundaries sit, which controls matter most, and how to review and test them. The architecture, trust boundaries, and design rules are durable. Product names, defaults, option names, limits, and quotas vary by provider and change often, so treat provider details here as examples and confirm them in current vendor documentation. Managed container platforms and clusters are covered in [Container Security](https://martian1337.gitbook.io/notes/security-engineering/cloud-platform-and-endpoint-security/container-security.md) and [Kubernetes Workload Security](https://martian1337.gitbook.io/notes/security-engineering/cloud-platform-and-endpoint-security/container-security/kubernetes-workload-security.md).

Relevant weaknesses are CWE-77 (command injection), CWE-78 (OS command injection), and CWE-94 (code injection) for event data that reaches an interpreter, CWE-250 (execution with unnecessary privileges) and CWE-269 (improper privilege management) for excess function permissions, CWE-798 (use of hard-coded credentials) and CWE-522 (insufficiently protected credentials) for secrets, CWE-770 (allocation of resources without limits or throttling) and CWE-400 (uncontrolled resource consumption) for scaling abuse, CWE-441 (unintended proxy or intermediary, the confused deputy) for service-to-service invocation without source conditions, CWE-526 (cleartext storage of sensitive information in an environment variable; confirm the current title) for secrets held in environment variables, and CWE-668 (exposure of resource to wrong sphere) for functions and data reachable by callers they were never meant for. No single OWASP Top 10:2025 category fits; findings land in Injection, Broken Access Control, Security Misconfiguration, and the supply chain categories (confirm the current mapping). The OWASP Serverless Top 10 was published in 2018 and may be out of date, so use it as a prompt list and not as a current standard. For APIs in front of functions, API4:2023 Unrestricted Resource Consumption matches denial of wallet.

## 1. What changes

| Concern                                        | Provider usually owns                                               | You own                                                                                          |
| ---------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| Hosts, hypervisor, isolation between customers | Yes                                                                 | Account and region structure, and whether the provider's isolation model fits your risk          |
| Managed runtime patching                       | Patches supported runtime versions, unless you pin or defer updates | Leaving a runtime version before end of support, after which provider patches stop               |
| Code and dependencies                          | No                                                                  | Everything in the package, including layers, shared libraries, and container base images         |
| Identity, invocation, and event sources        | The mechanisms                                                      | Every execution role, invoker permission, trust policy, public endpoint, and who can send events |
| Configuration and secrets                      | Storage                                                             | What goes in them and who can read them                                                          |
| Logs and audit                                 | Platform and control-plane records                                  | Application logging, retention, alerting                                                         |

* **Many small functions mean many entry points and many identities.** The unit of review shrinks while the count grows, so inventory functions, owners, roles, triggers, and runtimes, and review through templates and policy as code instead of by hand.
* **Ephemeral compute.** There is no host agent to install, no disk to image, and often no shell. Controls have to live in the platform (identity, configuration, network, logs), and evidence has to be emitted before the environment disappears. See [Cloud Forensics and Forensic Readiness Reference](https://martian1337.gitbook.io/notes/security-engineering/security-operations-detection-and-response/digital-forensics-and-malware-analysis/cloud-forensics-and-forensic-readiness-reference.md).
* **Event chains.** Data moves through gateways, queues, topics, buckets, and streams, and each hop is a trust boundary. Threat model event flows, not hosts. See [Threat Modeling](https://martian1337.gitbook.io/notes/appsec/product-security-engineering/threat-modeling.md). Isolation between customers is the provider's job; isolation between callers inside your function is yours (section 6).

## 2. Every event source is an input

| Event source                                       | Attacker-influenced content                                                                                      | Typical mistake                                                                                                                                                                                                                 |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| API gateway or function URL                        | Path, query, headers, body, and any identity fields forwarded in the event                                       | Injection; trusting forwarded claims when something other than the gateway can invoke the function                                                                                                                              |
| Object storage notification                        | Object key, metadata, content type, size, and the object body                                                    | Key used as a file path or in a shell command; parsing untrusted files in-process; keys that arrive URL-encoded on some platforms (S3 notifications encode the key, with spaces as plus signs) and are decoded wrongly or twice |
| Queue, topic, or stream message                    | The full body and attributes; producers include other services, other accounts, and anything relaying user input | Deserialization, SQL built from fields, fetching a URL taken from the message                                                                                                                                                   |
| Database change stream                             | Row content that users wrote earlier                                                                             | Second-order injection                                                                                                                                                                                                          |
| Email, webhook, chat, or log-subscription trigger  | Headers, bodies, attachments, sender addresses, log lines containing attacker-supplied strings                   | Parser abuse, header and log injection, trusting a sender address                                                                                                                                                               |
| Direct invocation by SDK, CLI, or another function | The whole event, including fields normally set by the gateway                                                    | A forged authorizer or identity context accepted as real                                                                                                                                                                        |

* **"Internal" is not "trusted".** A queue message is user input that traveled through a queue. Who may write to the queue, topic, or bucket is part of the trust boundary, so restrict producers with resource policies. Schedule triggers have fixed payloads, but anyone who can edit the rule controls the input.
* **Authenticate the sender, not only the payload.** For webhooks and public topics, verify a signature over the raw body (constant-time comparison, a timestamp, and rejection of stale or replayed deliveries), and for notification services that sign their messages verify the signature and the certificate origin. A sender address or source IP alone is not authentication.
* **Validate at function entry with a schema.** Reject unknown fields, wrong types, oversized and deeply nested bodies, then decode, then validate again at the field level. Validation libraries and parser utilities exist for most runtimes (Powertools for AWS Lambda is one example family).
* **Avoid shells and unsafe deserialization.** Do not build command strings from event data, and do not use `eval`-style calls or native object deserialization on event content. Pass argument vectors and use data-only formats. See [Insecure Deserialization Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/vulnerability-class-reference/insecure-deserialization-reference.md), [SQL and NoSQL Injection Prevention Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/vulnerability-class-reference/sql-and-nosql-injection-prevention-reference.md), [Path Traversal and File Inclusion Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/vulnerability-class-reference/path-traversal-and-file-inclusion-reference.md), and [Injection Classes Reference: XXE, SSTI, LDAP, XPath, and Header/Log Injection](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/application-security-and-secure-sdlc/injection-classes-reference-xxe-ssti-ldap-xpath-and-header-log-injection.md).
* **Outbound requests built from event data are SSRF.** Inside a function the targets worth reaching include the local credential endpoint (section 4). See [SSRF and URL Handling Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/vulnerability-class-reference/ssrf-and-url-handling-reference.md). Treat output as the next consumer's input, and do not write results back into the trigger source (section 7).

## 3. Identity, invocation, and least privilege

* **One execution identity per function**, with actions and resources scoped to what that function does: no shared broad role used by every function in a repository, and no wildcard resources where an identifier is known. Make the least-privilege role the default output of your deployment template. See [Workload Identity](https://martian1337.gitbook.io/notes/security-engineering/identity-and-access-management/identity-and-access-management/workload-identity-reference.md).
* **The deployment unit is the privilege boundary, and configuration is an escalation path.** Where several functions share one deployment unit, they share its identity: an Azure function app has one managed identity, one set of app settings, and shared host keys, so split functions with different needs into separate apps, set built-in authentication to require authentication (not merely enabled), and prefer identity-based host storage connections over the storage connection string kept in app settings (where supported). Whoever can change function code, configuration (layers, environment variables, startup wrapper settings), or the attached identity can run code as that identity, so keep deploy permissions separate from runtime permissions and restrict which roles a deployer may attach (for example `iam:PassRole` on AWS and the Service Account User role on Google Cloud).
* **Control who can invoke.** Examples by platform:

| Platform                   | Invocation controls                                                                                                             | Notes                                                                                                                                                                                                                                                                                       |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AWS Lambda                 | Function resource-based policy; function URL auth type `AWS_IAM` or `NONE`; API Gateway authorizers                             | A function URL with `NONE` is public once its resource policy permits it, and has no per-client throttling or direct WAF association (front it with a CDN and WAF, or use `AWS_IAM`; confirm current limits)                                                                                |
| Azure Functions            | HTTP trigger authorization level (`anonymous`, `function`, `admin`) with keys; built-in authentication; API Management in front | Keys are shared secrets, not user identity                                                                                                                                                                                                                                                  |
| Google Cloud Run functions | IAM invoker role (`roles/run.invoker`); ingress settings                                                                        | Granting the role to `allUsers` or `allAuthenticatedUsers` makes the service reachable by anyone (the latter by any Google account), and a service setting that disables the invoker IAM check has the same effect (confirm in current documentation); internal ingress limits reachability |

* **Confused deputy for service-to-service invocation.** When a storage, queue, topic, or scheduler service invokes a function, grant the service principal narrowly: condition on the specific source resource (source ARN style) and the source account, or another account's resource that points at your function may be allowed. See [Cross-Account Trust and the Confused Deputy Problem](https://martian1337.gitbook.io/notes/security-engineering/cloud-platform-and-endpoint-security/cloud-security-baselines/cross-account-trust-and-the-confused-deputy-problem.md).
* **Gateway claims are only trustworthy if only the gateway can invoke.** If a function reads identity fields from the event, restrict invocation to the gateway or verify the token inside the function. Function keys, API keys, and shared secrets are not user authentication: they identify a client or meter usage, are hard to rotate per caller, and leak into URLs and logs. Authenticate users with a token or IAM at the gateway, then authorize the object in the function, because the gateway cannot know who owns which record. See [Token Security: JWT and OAuth 2.0](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/api-security/token-security-jwt-and-oauth-2.0.md) and [API Security Checklist (OWASP API Top 10 2023)](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/api-security/api-security-checklist-owasp-api-top-10-2023.md).
* **Authorizer caching.** Verify signature, issuer, audience, expiry, and scope per route. Some gateways cache the authorizer's returned policy (on AWS API Gateway REST APIs the default is 300 seconds, keyed on the configured identity sources; verify for your gateway and authorizer type). Key the cache on every input the decision depends on, include the route and method in the identity sources where the authorizer type allows it, or set the cache time to live to zero when decisions differ per route. Do not return a wildcard resource policy to get around cache-related 403 errors: that turns one route's allow into an allow for all of them.
* **Do not accept default identities.** On some platforms a function gets a default service account that can be over-privileged (the Compute Engine default service account historically held a broad project-level editor role; newer organizations changed that default, so verify). Always set an explicit identity.

## 4. Credentials and secrets in the runtime

* **The function's own credentials are reachable from its code.** Some platforms deliver temporary credentials through environment variables (AWS Lambda uses `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN`); others expose a local metadata or managed-identity token endpoint. Code execution, an arbitrary file read of the process environment, or SSRF to the local endpoint hands over everything the role can do until the credentials expire. This is why least privilege matters at least as much as any perimeter control: the role is the blast radius.
* **Limit where stolen credentials work.** Credentials taken from a function can be replayed from anywhere unless policy says otherwise. Where the platform supports it, add network conditions on the resources the role reaches (for example source VPC or VPC endpoint conditions in AWS bucket and key policies, with endpoint policies on the endpoints) so replay from outside your network fails; this generally requires the function to be attached to that network, so test before enforcing.
* **Do not put long-lived secrets in plain environment variables.** They appear in configuration APIs, consoles, templates, and state files, and anyone who can read function configuration reads them. Platform encryption at rest protects the stored copy, but principals who can read function configuration (and, depending on platform and key settings, use the key) can still see the values. Prefer identity-based access to data services (IAM or managed-identity authentication) so no secret exists, and otherwise use a secret manager (AWS Secrets Manager or Parameter Store, Azure Key Vault, Google Secret Manager).
* **Fetch at initialization and cache with a time limit.** Calling the secret store per invocation costs latency and hits throttles; caching forever breaks rotation. Refresh on authentication failure. Vendor caching extensions exist (the AWS Parameters and Secrets Lambda Extension is one example). Do not log the environment or the full event: error handlers that dump environment variables or SDK debug output are a common leak. See [Secrets Management](https://martian1337.gitbook.io/notes/security-engineering/cryptography-and-trust-infrastructure/secrets-management.md).

## 5. Dependencies and packaging

* **The whole dependency tree ships with every function**, and each function pins its own, so versions drift. Generate a software bill of materials per deployed artifact, scan in CI, and update on a schedule. See [Supply Chain and Third-Party Risk](https://martian1337.gitbook.io/notes/security-engineering/security-governance-risk-and-compliance/supply-chain-and-third-party-risk.md) and [Dependency Confusion and Malicious Package Defense](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/ci-cd-security/dependency-confusion-and-malicious-package-defense.md).
* **Layers and shared packages are supply chain.** A layer or extension runs in the function's process or environment with the function's role. Treat third-party layers, including layers shared from other accounts, as untrusted code: pin an exact version, verify the publisher, copy reviewed code into your own account, and restrict who can publish or share new versions.
* **Code signing and images.** Platform features can reject unsigned or untrusted artifacts (AWS Lambda code signing configurations, which have applied to zip packages and layers but not container images, are checked at deploy or update time, and can be set to warn instead of enforce; Binary Authorization on Cloud Run, which applies to container images, so confirm whether source-deployed functions are covered; verify both in current documentation). Use the enforcing mode, and restrict who can sign. Container-image functions make the base image yours: pin by digest, keep it minimal, rebuild on base updates, and scan. See [Container Security](https://martian1337.gitbook.io/notes/security-engineering/cloud-platform-and-endpoint-security/container-security.md). Deprecated managed runtimes stop receiving provider patches, and platforms eventually block updates to functions that use them. Pinning a runtime version or switching to manual runtime updates (Lambda offers both) is a patching exception that needs an owner and an expiry.
* **Protect the deployment path.** The pipeline is the main write path to production code. Deny direct code upload outside the pipeline identity, deploy immutable published versions behind aliases, delete unused functions and old versions (on some platforms old versions stay invocable), and alert on out-of-band changes. See [CI/CD Security](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/ci-cd-security.md).

## 6. Execution environment reuse

* **Environments are reused across invocations**, possibly by different callers or tenants. Module-level variables, in-memory caches, singleton clients, the writable temporary directory (`/tmp` on Lambda), background threads, and open handles can all persist. Some platforms also process several requests concurrently in one instance (Cloud Run services, Cloud Run functions when configured for it, and the Azure Functions host are examples; a standard Lambda environment handles one request at a time, but confirm for newer compute options), so globals are shared between simultaneous requests, not only sequential ones.
* **Rules.** Keep no caller or tenant data in globals, caches, or temp files unless the key includes the caller or tenant and a cleanup step exists. Never build a shared client or auth context from one caller's credentials and reuse it. Use unique temp file names and delete after use. Do not cache an authorization decision across callers. Do not depend on reuse or on its absence, and test both cold and warm paths (section 10).
* **Initialization-time state persists.** A secret fetched at init lives as long as the environment does. Snapshot-based start features capture the initialized state and restore it into many environments, so values generated at init (random seeds, tokens, connection identifiers) are not unique, and a secret fetched at init can outlive a rotation; fetch secrets after restore or on first use there, and confirm the provider's guidance. For tenant context, per-tenant caches, and when to give a tenant its own function or account, see [Multi-Tenant Application Isolation Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/application-platform-security-reference/multi-tenant-application-isolation-reference.md).

## 7. Scaling as an attack surface

| Risk                           | What happens                                                                                                                    | Controls                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Denial of wallet (CWE-770)     | Autoscaling turns unauthenticated or abusive traffic, or a bug, into invocation, duration, and downstream cost                  | Authenticate before invoking; gateway throttling and per-client quotas (a bare function URL has neither); WAF rate rules at a CDN or gateway; reserved or maximum concurrency and maximum instances; short timeouts; right-sized memory; budget alerts and spend anomaly detection. Limiter design: [Rate Limiting, Quotas and Resource Consumption Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/api-security/rate-limiting-quotas-and-resource-consumption-reference.md) |
| Downstream exhaustion          | Functions scale faster than databases, connection limits, or third-party APIs                                                   | Concurrency caps matched to downstream capacity; connection proxies or pooling; backoff                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Retries and duplicate delivery | Asynchronous invocations and queue or stream consumers retry on error and can deliver more than once; defaults vary by platform | Idempotency keys with conditional writes, deduplication on message id or business key, bounded retries. See [Business Logic Flaws and Race Conditions Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/vulnerability-class-reference/business-logic-flaws-and-race-conditions-reference.md)                                                                                                                                                                                   |
| Poison messages                | One malformed message fails repeatedly and can block a stream shard or FIFO group until it expires or is skipped                | Dead-letter queues or failure destinations, maximum receive counts, partial batch failure reporting, alarm on queue depth; dead-letter queues hold user data, so encrypt and restrict them                                                                                                                                                                                                                                                                                                                           |
| Recursive trigger loops        | A function writes to its own trigger source, or two functions trigger each other                                                | Separate input and output buckets (prefixes only with non-overlapping event filters), event filters, concurrency cap as a circuit breaker, budget alarms; platforms may detect some loops, do not rely on it                                                                                                                                                                                                                                                                                                         |
| Oversized or expensive input   | Large payloads and pathological parsing burn duration                                                                           | Request size and schema validation at the gateway and again in code. See [Regular Expression and Parser Denial of Service Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/vulnerability-class-reference/regular-expression-and-parser-denial-of-service-reference.md) and [DDoS Response Plan Checklist](https://martian1337.gitbook.io/notes/security-engineering/network-and-communications-security/network-security/ddos-response-plan-checklist.md)                     |

## 8. Network and egress

* **Defaults favor reachability.** On most platforms a function can make outbound internet calls by default, so code execution can exfiltrate data and reach credential endpoints directly. **Attaching to a private network (VPC, VNet integration, direct VPC egress) is needed for private databases, but does not by itself restrict egress.** On AWS a VPC-attached function loses default internet access unless you add a NAT path. On Azure Functions VNet integration and Cloud Run VPC egress, the default has typically been to route only private-range traffic through the attached network, so public destinations bypass your firewall unless the route-all or all-traffic setting is enabled (confirm current defaults). For functions that handle sensitive data, add egress rules, a proxy or firewall with a destination allowlist, and DNS controls.
* **Use private endpoints for data services** and pair them with resource or endpoint policies that name the allowed network path. Not every function needs a VPC attachment, and network placement does not replace identity-based authorization. **Restrict ingress:** internal-only functions should have no public endpoint (internal ingress settings, private API endpoints, a WAF in front of public ones). See [Cloud Network Security](https://martian1337.gitbook.io/notes/security-engineering/cloud-platform-and-endpoint-security/cloud-security-baselines/cloud-network-security-and-segmentation.md).

## 9. Logging, tracing, and audit

* **Structured logs with a correlation id**, function name and version, caller or tenant id, and outcome. Propagate trace context through queues and events so a chain can be reconstructed. Log an allowlist of fields, never event bodies, tokens, or secrets, and encode untrusted values. Set retention explicitly, ship logs to a separate account or project, and do not give the function permission to delete or alter its log destination.
* **Audit the control plane.** Provider audit logs (AWS CloudTrail, Azure Activity Log, Google Cloud Audit Logs) record code updates, configuration changes, permission grants, public endpoint creation, role attachment, and alias moves. Invocation-level (data plane) logging is often optional and billed separately, so decide deliberately. Keep the digest or version of what ran, so a deployed artifact can be compared with the build record and an investigation can recover a function that no longer exists. See [Logging and Monitoring](https://martian1337.gitbook.io/notes/security-engineering/security-operations-detection-and-response/logging-and-monitoring.md).

## 10. Review and testing

* **Infrastructure-as-code review.** Flag wildcard actions and resources, one role shared by many functions, public invocation (no-auth function URL, anonymous trigger level, `allUsers` or `allAuthenticatedUsers` invoker, a resource policy with a wildcard principal and no condition), secret-like environment variables, missing timeouts, concurrency limits, and dead-letter queues, layers from unknown accounts, deprecated runtimes, and ingress set to all. Policy-as-code and IaC scanners (for example Checkov, CloudFormation Guard, and Open Policy Agent; cfn-lint is a template linter with some relevant rules such as deprecated runtime checks) can run in CI; confirm rule coverage for your provider. Also flag service-principal permissions without a source resource and source account condition, and code signing set to warn.
* **Permission analysis from observed activity.** Generate or tighten policies from audit logs (AWS IAM Access Analyzer policy generation, Google IAM Recommender; confirm availability), exercise every code path in a non-production account first, and review unused-permission reports.
* **Local and unit invocation with malformed events.** Call the handler directly or through provider tooling (AWS SAM CLI, Azure Functions Core Tools, Google Functions Framework) with missing fields, wrong types, oversized and deeply nested bodies, unusual encodings, special characters in storage keys, and identity fields that do not match. Assert rejection with no side effects.
* **Authorizer and invocation tests.** Expired, wrong-audience, and missing-scope tokens; a cached decision reused across routes; direct invocation that bypasses the gateway with a forged identity context. In a test account, exercise the real trigger path (put an object, send a message), not only HTTP.
* **Cold versus warm state tests.** Invoke as two different callers, sequentially and concurrently, and assert nothing from the first appears for the second; check temp file cleanup; force fresh environments (on Lambda, update the function code or configuration, for example a dummy environment variable, or invoke a newly published version; confirm for your platform) and repeat.
* **Static analysis with event data as the taint source.** Add the handler's event parameter as a source if the tool does not model it. See [CodeQL for Beginners](https://martian1337.gitbook.io/notes/appsec/product-security-engineering/sast-sca/codeql-for-beginners.md), [Software Security Testing and Fuzzing Checklist](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/application-security-and-secure-sdlc/software-security-testing-and-fuzzing-checklist.md), and [Access Control Testing Checklist](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/application-security-and-secure-sdlc/access-control-testing-checklist.md) for object-level checks.

## 11. Detection

* **Invocation, duration, throttle, error, and concurrency spikes per function**, tied to spend alarms, plus dead-letter queue growth, repeated retries, and loop patterns. See [Detection Engineering Catalog](https://martian1337.gitbook.io/notes/security-engineering/security-operations-detection-and-response/detection-engineering-catalog.md).
* **Control-plane changes outside the pipeline identity:** code or configuration updates, new permissions, new public endpoints, role attachments, new layer versions, alias moves.
* **Credential misuse:** a function role calling services it never uses, bursts of access-denied errors from the role (permission probing after compromise), or use from outside the platform's network (provider threat-detection services may flag this; confirm coverage).
* **Injection and parser abuse signals:** validation failures, unexpected child processes (where visible), and outbound connections to destinations not on the allowlist (egress and DNS logs).
* **Containment.** Cut the invocation path first (remove the public endpoint or the resource policy statement, or set reserved or maximum concurrency to zero where the platform supports it), then attach an explicit deny policy to the execution role and revoke its active sessions, rotate every secret the function could read, and preserve the deployed artifact, version, configuration, and logs before redeploying. Credentials already copied out of the function stay valid until they expire or are revoked, so session revocation matters as much as stopping the function. See [Cloud Forensics and Forensic Readiness Reference](https://martian1337.gitbook.io/notes/security-engineering/security-operations-detection-and-response/digital-forensics-and-malware-analysis/cloud-forensics-and-forensic-readiness-reference.md).

## 12. Checklist

* [ ] Every function (or deployment unit, where functions share one) has its own execution identity scoped to specific actions and resources, with no shared broad roles or default identities, and code, configuration, and role-attach permissions are restricted to the pipeline.
* [ ] Every event source is treated as untrusted input and validated against a schema at function entry; no shell command strings, `eval`-style calls, or native deserialization process event data.
* [ ] Invocation is restricted (resource policy, invoker role, or authorizer), service principals are scoped by source resource and account, and no function is public unless intended.
* [ ] Users are authenticated with tokens or IAM at the gateway and objects are authorized in the function; function keys and API keys are not used as user authentication.
* [ ] Long-lived secrets live in a secret manager, not plain environment variables, and the environment and full events are never logged.
* [ ] Dependencies, layers, and base images are pinned, scanned, and sourced from reviewed publishers; runtimes are supported versions (any pinning has an owner and expiry); production code deploys only through the pipeline as immutable versions.
* [ ] No caller or tenant data persists in globals, caches, or temp files without a key and cleanup.
* [ ] Concurrency limits, timeouts, gateway throttles, and budget alerts exist; handlers are idempotent; dead-letter queues exist; trigger loops are ruled out.
* [ ] Egress is restricted for sensitive functions, data services use private endpoints, and internal functions have no public endpoint.
* [ ] Structured logs carry correlation ids without sensitive bodies, control-plane audit logs are retained, and alerts exist on function, permission, and endpoint changes.
* [ ] A containment runbook exists for a compromised function: cut invocation, deny and revoke the role, rotate secrets, preserve the artifact and logs.
* [ ] CI runs IaC policy checks and malformed-event, authorizer, and cold-versus-warm tests.

## Related

* [Application Security and Secure SDLC](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/application-security-and-secure-sdlc.md): the class overview and the Secure SDLC checklist.
* [Cloud Security Baselines](https://martian1337.gitbook.io/notes/security-engineering/cloud-platform-and-endpoint-security/cloud-security-baselines.md) and [AWS Security Baseline](https://martian1337.gitbook.io/notes/security-engineering/cloud-platform-and-endpoint-security/cloud-security-baselines/aws-security-baseline.md): account-level controls around functions.
* [Workload Identity](https://martian1337.gitbook.io/notes/security-engineering/identity-and-access-management/identity-and-access-management/workload-identity-reference.md) and [Cross-Account Trust and the Confused Deputy Problem](https://martian1337.gitbook.io/notes/security-engineering/cloud-platform-and-endpoint-security/cloud-security-baselines/cross-account-trust-and-the-confused-deputy-problem.md): execution roles and invoker trust.
* [Multi-Tenant Application Isolation Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/application-platform-security-reference/multi-tenant-application-isolation-reference.md): tenant context and shared-environment state.
* [Weakness Taxonomy Reference](https://martian1337.gitbook.io/notes/appsec/application-and-product-security/application-security-and-secure-sdlc/weakness-taxonomy-reference.md): the CWE vocabulary.

## References

* [OWASP Serverless Top 10 project (2018, dated; confirm the page location is current)](https://owasp.org/www-project-serverless-top-10/)
* [AWS Lambda, Security in AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/lambda-security.html)
* [AWS Well-Architected, Serverless Applications Lens](https://docs.aws.amazon.com/wellarchitected/latest/serverless-applications-lens/welcome.html)
* [Microsoft, Securing Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/security-concepts)
* [Google Cloud, Cloud Run functions documentation, including its security pages (renamed from Cloud Functions, so confirm the current page titles)](https://cloud.google.com/functions/docs)
* [OWASP API Security Top 10 (2023), API4 Unrestricted Resource Consumption](https://owasp.org/API-Security/editions/2023/en/0xa4-unrestricted-resource-consumption/)
* [CWE-94](https://cwe.mitre.org/data/definitions/94.html)
* [CWE-250](https://cwe.mitre.org/data/definitions/250.html)
* [CWE-770](https://cwe.mitre.org/data/definitions/770.html)

## Sources

* [OWASP Top 10:2025](https://owasp.org/Top10/2025/)
* [OWASP ASVS](https://owasp.org/www-project-application-security-verification-standard/)
* [OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/)
* [MITRE CWE](https://cwe.mitre.org/)
