Join our Newsletter — 33% off our NHI Course

How should security teams design serverless architectures when functions need to handle sensitive data and third-party dependencies?

Teams should treat serverless as an architecture choice, not a default. If a workload needs strong visibility, tight control, or complex handling of sensitive data and external dependencies, serverless may be the wrong fit. The safer approach is to limit serverless to workloads that match its operating model, then enforce least privilege, minimal code, and strong dependency review.

Serverless only works when the workload fits the operating model

Serverless is strongest when you want rapid scaling, event-driven execution, and minimal infrastructure management. It is weakest when the workload needs persistent visibility, careful inspection of sensitive data flows, or tight control over every dependency hop. The design question is not “can serverless run this?”, but “can this workload tolerate the control trade-offs that serverless introduces?”

For sensitive-data workloads, the architecture should assume that function code will be short-lived, stateless, and dependent on external services for most nontrivial work. That means the sensitive-data handling boundary must be explicit: decide where data is decrypted, transformed, logged, cached, and forwarded, and keep those steps as narrow as possible.

When third-party dependencies are part of the path, the function runtime becomes only one trust boundary in a larger chain. A small function can still create outsized exposure if it calls an external package, API, or integration that expands the blast radius of the original request.

Design the data path and dependency path together

Security teams should design serverless flows so that sensitive data only reaches functions that truly need it, and only in the smallest usable form. That usually means avoiding broad event payloads, avoiding unnecessary fan-out, and keeping secrets and private data out of logs, metrics, and dead-letter paths unless there is a documented need.

Dependency design matters just as much. Third-party libraries and managed integrations should be reviewed for update cadence, provenance, privilege requirements, and failure behavior before they are admitted into a function. A function that depends on a risky package or OAuth integration is not just an application risk, it is also an access-path risk because those dependencies can become the easiest route to data exposure.

At the architecture level, the safer pattern is to separate duties: one function can validate or route, another can handle the sensitive operation, and a third can interact with external systems under a different permission set. That separation makes it easier to bound trust, review code, and replace a dependency without redesigning the whole workflow.

Least privilege is necessary, but not sufficient

Serverless functions should have the minimum permissions needed for the exact operation they perform, and no shared role should become the default for an entire application. But least privilege alone does not solve poor data shaping or uncontrolled dependencies. A narrowly permissioned function can still leak data if it receives too much input, retries blindly, or delegates to an untrusted integration.

Teams should also treat credentials, tokens, and API keys as highly scoped, short-lived material that is rotated and isolated per function or per environment when possible. If a function must reach a third-party service, the credential should be valid only for that use case and should fail closed if its surrounding environment changes.

For this reason, serverless security should be designed around both permission boundaries and trust boundaries. The first limits what the function may do. The second limits what the function may see, call, or inherit from its dependencies.

Risk and Threat Considerations

Serverless becomes risky when teams assume the platform removes the need for architecture discipline. The common failure mode is overexposure: too much data in the event payload, too much privilege in the execution role, or too much trust in a third-party package or integration. Once that happens, a compromise in one function can turn into a much broader data or access problem.

Failure mechanism: Sensitive data can leak through logs, retries, temporary storage, or an over-privileged dependency chain, while an attacker who compromises a package, token, or integration can reuse the function’s trust path to reach downstream systems.

Impact: The result can be data disclosure, unauthorized API access, hard-to-trace lateral movement through managed services, and incident response complexity because the execution environment is ephemeral and distributed.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-02 — Secret Leakage Sensitive serverless flows can expose tokens and keys through logs or dependencies.
NHI-03 — Vulnerable Third-Party NHI Third-party integrations and tokens can become the weakest link in serverless flows.
NHI-05 — Overprivileged NHI Serverless functions should not carry broad permissions for sensitive operations.
Recommendation — Keep secrets out of logs, payloads, and shared runtime paths. Review third-party dependency trust and revoke risky integrations quickly. Scope each function to the minimum permissions required for its exact task.
NIST SP 800-53 Rev 5 IA-5 — Authenticator Management Serverless often relies on tokens, API keys, and short-lived credentials.
AC-6 — Least Privilege Least privilege is central to reducing the blast radius of serverless execution roles.
CM-8 — System Component Inventory Dependency review depends on knowing which packages and integrations the function uses.
Recommendation — Rotate and scope function credentials to the specific use case and lifetime. Assign each function only the permissions needed for the exact operation. Maintain an inventory of runtime dependencies and external integrations.

Practitioner Guidance

What to prioritise: Classify each serverless workload by data sensitivity, dependency trust, and observability needs before deciding to use it. If the workload cannot tolerate limited runtime visibility or requires broad third-party reach, treat serverless as a candidate to reject rather than a default to accept.

What to verify: Confirm that every function has a clearly bounded input contract, a narrowly scoped execution role, and a dependency inventory that is reviewed for provenance and update hygiene. Also verify where sensitive data can appear outside the function body, especially in logs, traces, and shared queues.

Practitioner takeaway: The key decision is whether the workload can stay small, observable, and tightly bounded under serverless constraints. If it cannot, the secure answer is usually a different architecture, not a more aggressive serverless control set.