Objective 3.1Medium10 min

Serverless and Microservices

Security considerations for serverless computing (Functions as a Service) and microservices architecture. Covers function security, API gateways, service mesh, service-to-service authentication, and distributed system challenges.

Understanding Serverless and Microservices

Serverless computing and microservices represent modern architectural approaches that change how applications are built and secured. Instead of monolithic applications, functionality is distributed across small, independent components.

Serverless (Functions as a Service): • Code runs in response to events • No server management • Provider handles infrastructure • Pay per execution

Microservices: • Application split into small services • Each service has single responsibility • Services communicate via APIs • Independent deployment and scaling

In 2020, a misconfigured AWS Lambda function at a major company exposed customer data because the function had overly permissive IAM permissions—illustrating why least privilege is critical even in serverless environments.

Both architectures introduce new security considerations around service communication, identity, and distributed systems.

Why This Matters for the Exam

Serverless and microservices are tested on SY0-701 as they're increasingly common architectures. Questions cover security implications, API security, and service-to-service communication.

Understanding these architectures helps with modern application security and cloud-native development. Traditional security approaches don't directly apply.

The exam tests awareness of unique security challenges and appropriate controls for these architectures.

Deep Dive

What Are the Security Risks of Serverless Computing?

Serverless Characteristics:

  • Functions execute on demand
  • Short-lived execution (seconds to minutes)
  • Provider manages underlying infrastructure
  • Event-driven (HTTP, queue, schedule triggers)

Security Considerations:

AspectSecurity Implication
No server managementLess OS patching, but less control
Short executionDifficult for persistent threats
Event triggersInput validation critical
Third-party dependenciesVulnerable libraries
Function permissionsLeast privilege essential

Serverless Risks:

  • Overprivileged function roles
  • Insecure function configurations
  • Vulnerable dependencies in packages
  • Event injection attacks
  • Sensitive data in environment variables

Function Security Best Practices:

# BAD - Overprivileged
Role: Admin access to all AWS services

# GOOD - Least privilege
Role: Read access to specific S3 bucket,
      Write access to specific DynamoDB table

How Do You Secure Microservices Communication?

Microservices Architecture
User
API Gateway
Auth
Orders
Payment
Inventory
API Gateway → centralized auth & rate limiting • Services communicate via mTLS

Security Challenges:

ChallengeDescription
Service-to-service authHow services trust each other
API securitySecuring many endpoints
Data consistencyDistributed data management
Attack surfaceMany services = many targets
VisibilityMonitoring distributed calls

Service-to-Service Authentication Methods:

  • Mutual TLS (mTLS)
  • Service tokens (JWT)
  • Service mesh identity
  • API keys (less secure)

What Is an API Gateway and Why Is It Important?

API gateway is the central entry point for all API traffic.

API Gateway Security Functions:

FunctionSecurity Benefit
AuthenticationVerify identity before reaching services
AuthorizationEnforce access policies
Rate limitingPrevent abuse and DDoS
Input validationBlock malformed requests
LoggingCentralized audit trail
SSL terminationEncrypt external traffic

API Gateway Security Controls:

  • Centralized authentication/authorization
  • Request validation and sanitization
  • Throttling and rate limiting
  • TLS for all external communication
  • WAF integration for attack prevention

What Is a Service Mesh and How Does It Secure Microservices?

A service mesh is an infrastructure layer for service-to-service communication.

Service Mesh Components:

  • Sidecar proxies (handle all traffic)
  • Control plane (manages configuration)
  • Data plane (actual traffic flow)

Service Mesh Security Features:

  • Automatic mTLS between services
  • Service identity and authentication
  • Traffic encryption
  • Access policies
  • Observability and monitoring

Popular Service Meshes:

  • Istio
  • Linkerd
  • Consul Connect
  • AWS App Mesh

Service Mesh Benefits:

Without mesh: Each service implements own security
With mesh: Security handled by infrastructure
           - mTLS automatic
           - Identity automatic
           - Policies centralized

What Is mTLS and Why Does It Matter?

Mutual TLS (mTLS):

  • Standard TLS: Only client verifies server
  • Mutual TLS: BOTH sides verify each other

mTLS in Microservices:

  • Every service has a certificate
  • Services authenticate before communicating
  • All traffic encrypted
  • Prevents service impersonation

Zero Trust for Microservices:

  • Never trust, always verify
  • Authenticate every service call
  • Encrypt all traffic
  • Least privilege access
  • Continuous verification

How CompTIA Tests This

Example Analysis

Scenario: A company's microservices application is breached. Attackers compromise one service and use its credentials to access other internal services, eventually reaching the database service and exfiltrating customer data.

Analysis - Microservices Security Failures:

What Happened:

  • 1.Single service compromised (initial access)
  • 2.Service had broad access to other services
  • 3.No service-to-service authentication required
  • 4.Lateral movement to database service
  • 5.Data exfiltration

Security Failures:

FailureImpact
No service isolationCompromise spread easily
No mTLSServices trusted any request
Overprivileged accessCompromised service could reach DB
No segmentationFlat network between services

What Should Have Been Implemented:

Service Mesh / mTLS:

  • Each service has identity
  • Service-to-service encryption
  • Mutual authentication required

Least Privilege:

  • Service A can only talk to Service B
  • Explicit allow policies, default deny

API Gateway:

  • Centralized authentication
  • Rate limiting
  • Anomaly detection

Zero Trust Architecture:

  • No implicit trust between services
  • Every request authenticated
  • Continuous verification

Key insight: Microservices increase attack surface. Without proper service identity and access controls, compromising one service compromises all.

Key Terms

serverless securitymicroservices securityAPI gatewayservice meshLambdafunction securitydistributed architecture

Common Mistakes

Assuming serverless is inherently secure—while OS patching isn't your concern, function permissions, code security, and configurations still are.
Trusting service-to-service traffic—internal traffic between microservices must be authenticated and encrypted (mTLS).
Giving functions excessive permissions—serverless functions should have minimum permissions needed, not admin access.
No centralized API security—API gateway provides authentication, rate limiting, and logging. Don't bypass it.

Exam Tips

When a question describes "no server management" but asks about security responsibility, serverless still requires securing code, permissions, and configurations.
API gateway questions: Look for "centralized authentication" and "rate limiting" as key functions.
If asked what automates mTLS between microservices, the answer is service mesh (Istio, Linkerd).
mTLS = Mutual TLS = BOTH sides authenticate. Regular TLS = only client verifies server.
Microservices + no service-to-service auth + breach = lateral movement. The fix is mTLS and least privilege.
Least privilege for Lambda/functions means permissions scoped to specific resources, not wildcards.

Memory Trick

Think of microservices like a restaurant kitchen:

Without security controls: Every cook can walk into any station, grab any ingredient, and use any equipment. One bad actor, and they can contaminate everything.

With API Gateway: There's a single door into the kitchen with a host checking IDs and limiting how many orders come in (authentication + rate limiting).

With Service Mesh (mTLS): Every cook wears a name badge that other cooks verify before handing over ingredients. No badge, no ingredients.

Serverless is like hiring gig workers: You don't manage their cars or phones (infrastructure), but you're still responsible for what tasks you assign them (permissions) and what information you give them (data).

The "Lambda Rule": Just because you don't see the server doesn't mean you can give admin access. Serverless + overprivileged = breach waiting to happen.

Test Your Knowledge

Q1.A company uses AWS Lambda functions. What security control should be applied to limit what resources each function can access?

Q2.What infrastructure component provides automatic mutual TLS between microservices?

Q3.What is the PRIMARY security function of an API gateway in a microservices architecture?

Want more practice with instant AI feedback?

Continue Learning

Ready for the Exam?

See exactly where you stand on this concept and 182 others.

99% pass rate · Pass guarantee