Securing Cloud-Native Applications

12 min read Β· Updated 2026-09-30

Securing a cloud-native application is fundamentally different from securing a server-room monolith. The attack surface is larger, the dependencies are deeper, the credentials are everywhere, and the perimeter is fluid. Modern application security is defense in depth at every layer.

This lesson covers the security concerns specific to cloud-native SaaS: application-level attacks, supply chain, secrets, runtime, and the zero-trust model that ties it all together.

Defense in Depth

The principle: multiple layers of independent security, so a single failure doesn’t cascade.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Edge:  WAF, DDoS protection, rate limiting              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Network:  TLS, mTLS between services, network policies  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Identity:  OAuth/OIDC, MFA, RBAC, tenant isolation      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Application:  Input validation, SQL injection preventionβ”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Data:  Encryption at rest, key management, RLS          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Audit:  Access logs, anomaly detection, IDR             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Each layer catches what others miss. Strong identity doesn’t help if SQL injection lets attackers bypass the app entirely. Encryption at rest doesn’t help if logs leak plaintext PII. Apply security at every level.

Capital One in 2019 exposed about 100 million customer records through a misconfigured web application firewall; fines and remediation were reported around $300 million. SolarWinds in 2020 was a build-pipeline compromise that reached about 18,000 customers, including government agencies. Repeated Okta incidents spread through every customer that trusted that identity plane. The failing control was edge configuration, the software supply chain, or the identity provider.

Kubernetes, subnet, and privilege defaults

Pod Security Standards replace Pod Security Policies and ship three profiles. Privileged allows the full container API. Baseline blocks the sharpest defaults. Restricted is the production profile: no privilege escalation, a non-root user, and a limited set of volume types.

Kubernetes otherwise allows every pod to talk to every other pod. A default-deny policy selects all pods and lists both Ingress and Egress, and explicit allow policies name the paths you intended. A service mesh (Istio or Linkerd) then adds mutual TLS on those paths. The mesh’s operating cost is usually justified once a platform is past roughly 10-15 services.

On AWS, a security group is stateful and can name another security group instead of a CIDR, so the rule survives when instances change address. Application servers and databases belong in private subnets. Public subnets hold load balancers and NAT gateways.

Least privilege is an operating loop, not only a role name. Elevation is just-in-time and expires. Someone reviews who still holds each powerful role. Closing the account or the ticket removes the binding automatically. A change to a binding raises an alert. MFA strength follows the same ordering: SMS can be redirected by a SIM swap, a TOTP authenticator is stronger, and a FIDO2 or WebAuthn hardware key is the strongest of the three.

OWASP Top 10

The industry-standard list of most-impactful web application security risks. Worth knowing every one:

A01: Broken Access Control
Users can access data or functions they shouldn't. The most common and impactful issue. Often: forgetting to check tenant or user ownership in queries.
A02: Cryptographic Failures
Sensitive data not properly encrypted. Plaintext storage, weak algorithms, hardcoded keys, leaking via logs.
A03: Injection
SQL injection, command injection, LDAP, NoSQL. Any case where user input becomes code. Use parameterized queries everywhere.
A04: Insecure Design
Missing security at the architectural level. Missing rate limiting, no MFA option, no audit logging.
A05: Security Misconfiguration
Default credentials, verbose errors leaking internals, unprotected admin endpoints, S3 buckets open to the world.
A06: Vulnerable Components
Using libraries with known CVEs. Use SBOMs, scanners (Snyk, Dependabot), keep dependencies current.
A07: Identification and Authentication Failures
Weak password policies, no MFA, predictable session IDs, password recovery vulnerabilities.
A08: Software and Data Integrity Failures
Malicious dependencies, unsigned updates, untrusted CI/CD pipelines.
A09: Security Logging and Monitoring Failures
No audit logs, no anomaly detection, no alerting. Breaches go undetected for months.
A10: Server-Side Request Forgery (SSRF)
Server fetches a user-supplied URL β†’ can be tricked into hitting internal resources (cloud metadata services, internal admin pages).

Input Validation and Output Encoding

The single most effective defense against injection.

Validate input
At the boundary
Every external input β€” API request body, query string, headers, file uploads β€” validated for type, length, allowed values. Reject what doesn't match.
Encode output
For the destination
Data going into HTML β†’ escape for HTML. Going into SQL β†’ parameterized queries. Going into shell β†’ escape shell. Different destinations, different escaping.
# Wrong β€” SQL injection vulnerable
query = f"SELECT * FROM users WHERE id = {user_id}"

# Right β€” parameterized
query = "SELECT * FROM users WHERE id = %s"
cursor.execute(query, (user_id,))

# Wrong β€” XSS vulnerable
return f"<div>Hello {name}</div>"

# Right β€” escape HTML
return f"<div>Hello {html.escape(name)}</div>"

Supply Chain Security

Modern apps have hundreds or thousands of transitive dependencies. Each is a potential vulnerability.

SBOM β€” Software Bill of Materials
A complete inventory of dependencies. SPDX or CycloneDX format. Generated by tools like Syft.
Vulnerability scanning
Continuously check dependencies against CVE databases. Snyk, Dependabot, Trivy. Run in CI; fail builds on high-severity issues.
Lock files + integrity
Pin exact versions (package-lock.json, requirements.txt with hashes). Catches "someone replaced this version with malicious code."
Sign and verify
Cosign, Sigstore for container images. Verify signatures before deployment.
Trusted registries
Pull only from verified registries. Mirror public registries internally to catch tampering.
Reproducible builds
Same source code β†’ same binary. Catches build-time tampering.

Secrets Management

Secrets β€” API keys, DB passwords, certs, encryption keys β€” are the keys to the kingdom. Treat them carefully.

The right way

Centralized secret store
AWS Secrets Manager, HashiCorp Vault, GCP Secret Manager. Encrypted at rest, audited access, rotation support.
Per-service identity
Each service has its own identity (IAM role, service account). Permissions to specific secrets only.
Automatic rotation
Rotate credentials regularly. Modern secret stores can rotate database passwords automatically.
No long-lived credentials
AWS IAM roles for EC2/EKS, Workload Identity in GCP, Pod Identity in Kubernetes. Short-lived tokens minted on demand.
Audit access
Every secret access logged. Anomaly detection on unusual access patterns.
Detection in CI
git-secrets, gitleaks, TruffleHog scan commits and PRs for accidentally committed secrets.

Container and Runtime Security

For containerized SaaS:

Image scanning
Scan container images for vulnerabilities (Trivy, Snyk, Grype). Block deploys on critical CVEs.
Minimal base images
Distroless, Alpine, scratch. Smaller attack surface. No shell, no package manager β€” fewer ways to escalate.
Run as non-root
Containers running as UID 0 are way more dangerous if escaped. Use non-root user explicitly.
Read-only root filesystem
Make container filesystem immutable. Attackers can't plant payloads or modify binaries.
Pod Security Standards
Kubernetes enforces baseline / restricted profiles cluster-wide. No privileged pods, no host network, no raw capabilities.
Runtime detection
Falco, Sysdig Secure. Detect malicious behavior at runtime β€” unexpected processes, network connections, file access.

Zero Trust

The traditional security model assumed inside-the-network = trusted. Cloud-native and remote work broke that assumption. Zero trust says: verify everything, regardless of network position.

Strong identity
Every actor (user or service) has cryptographic identity. mTLS, signed JWTs, service accounts.
Continuous authentication
Not just at login. Re-verify on sensitive operations. Risk-based scoring (unfamiliar device, IP, time β†’ re-auth).
Least privilege
Every actor has the minimum permissions needed. No "admin role for everyone." Fine-grained permissions, time-bound elevations.
Audit everything
Every access logged. Centralized logging with anomaly detection. Comprehensive audit trail for forensics.

Network Security in Cloud-Native

TLS everywhere
Public traffic, intra-cluster traffic. mTLS for service-to-service in service meshes.
Network segmentation
VPCs, subnets, security groups (AWS), NetworkPolicies (K8s). Default-deny; explicitly allow traffic that should flow.
WAF
Web Application Firewall. Filters common attacks (OWASP Top 10) at the edge. AWS WAF, Cloudflare, Imperva.
Private connectivity
PrivateLink, VPC peering, VPN. Don't expose internal services to the internet.

Security Headers

A few HTTP headers that meaningfully reduce attack surface:

Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-...'
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: geolocation=(), microphone=(), camera=()

These headers prevent classes of attacks (clickjacking, MIME sniffing, mixed content). Set them at the edge or framework level.

Audit Logging

Every privileged action should be logged with enough context to reconstruct it later.

Who
Authenticated identity. User ID, service account, IP address.
What
Action taken β€” created order, deleted user, accessed sensitive data.
When
Precise timestamp. Time zone consistency.
Result
Success or failure. Failure reason. Resource affected.

Audit logs should be:

Recap