Securing Cloud-Native Applications
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:
Input Validation and Output Encoding
The single most effective defense against injection.
# 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.
Secrets Management
Secrets β API keys, DB passwords, certs, encryption keys β are the keys to the kingdom. Treat them carefully.
The right way
Container and Runtime Security
For containerized SaaS:
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.
Network Security in Cloud-Native
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.
Audit logs should be:
- Immutable β write-only. Append to S3 with object lock, or stream to a SIEM.
- Tamper-evident β even admins canβt silently modify audit history.
- Retained for the required compliance window (e.g., 1 year, 7 years for some regulations).
Recap
- Defense in depth: multiple independent layers, so one failure doesnβt cascade.
- Know the OWASP Top 10. Especially A01 (access control) and A03 (injection) β most common, most impactful.
- Validate input at the boundary; encode output for the destination. Prevents injection.
- Supply chain: SBOMs, vulnerability scanning, lock files, signed artifacts.
- Secrets: centralized store (Vault, Secrets Manager), automatic rotation, no long-lived credentials.
- Containers: scan images, minimal base, non-root user, read-only FS, Pod Security Standards.
- Zero trust: identity everywhere, least privilege, audit everything.
- Security headers reduce attack surface for free.
- Audit logs: immutable, tamper-evident, retained for compliance.