AI pentesting guides / By tech stack

Serverless APIs

Serverless API security testing

Serverless API security testing checks each function as its own entry point: on Lambda, Cloud Functions, Azure Functions, Vercel, Netlify or Cloudflare Workers, every function can have its own trigger, URL and permission set, so authorisation that one function enforces says nothing about the next.

The platform handles patching the runtime and the servers. What stays with you is the code, the triggers and the identity each function runs as, and a compromise of the function hands the attacker that identity.

Entry points without auth

  • Lambda function URLs with auth type NONE are public HTTPS endpoints, often created for a quick integration.
  • Functions behind an API gateway that are also reachable through a direct URL.
  • Background functions triggered by HTTP for testing and never locked down.
  • Per-function auth helpers that drift: one handler validates the JWT audience, another only decodes it.

What a compromised function exposes

On Lambda, temporary credentials for the function's role are provided through environment variables. Any bug that reads the process environment, such as a file read of /proc/self/environ or an error page that dumps env, leaks credentials scoped to that role. SSRF in a function that fetches URLs can reach internal services. Over-privileged roles turn a small bug into account-level access, which is why least privilege per function matters.

Event injection and cost abuse

  • Data arriving from queues, storage events or webhooks is attacker-influenced; a file name or message body can carry injection payloads.
  • Unbounded concurrency lets an attacker run up your bill (denial of wallet) by hammering expensive functions, such as ones that call paid AI APIs.
  • Long timeouts with slow downstream calls amplify both cost and availability issues.
  • Verbose errors from runtimes reveal function names, paths and versions.

Edge functions and middleware

Edge runtimes such as Cloudflare Workers, Vercel Edge Functions and Netlify Edge Functions often run authentication or routing logic in front of origin functions. If the origin can be reached directly, or if the edge layer can be skipped by a header or path variant, that logic is bypassed. The Next.js middleware bypass of 2025 (CVE-2025-29927) is a well-known example of this class.

With Pentest-Swarm

Testing serverless APIs with Pentest-Swarm

Pentest-Swarm tests the HTTP surface of your serverless API: gateway routes, function URLs and edge functions.

  • Include every function URL and gateway hostname in --scope so it can compare behaviour across entry points.
  • Run the api-security playbook with test tokens for different roles to test authorisation per function.
  • Use --verify for SSRF so findings are confirmed with an out-of-band callback rather than inferred.
  • Cap throughput-heavy tests on paid endpoints and set a model budget with --budget to keep the test itself affordable.

Where it falls short

Non-HTTP triggers such as queues and storage events are outside a black-box HTTP test, and IAM permissions are invisible from outside. Use cloud configuration tools for roles and triggers; Pentest-Swarm's arsenal includes prowler, scoutsuite and cloudsplaining for that separate cloud review. Code-level review covers event handlers.

Questions

Is serverless more secure than containers?

It removes server patching from your list. Application-level flaws and over-privileged identities remain, and each function adds an entry point.

What is denial of wallet?

An attack that drives up your cloud bill by invoking pay-per-use resources at scale. Concurrency limits, rate limits and authentication on expensive functions reduce it.

Can I test functions with non-HTTP triggers?

Not with an HTTP-based black-box test. Test the handlers with unit tests that use malicious event payloads, and review their permissions.