🔐 HashiCorp Vault + MERN Architecture

Enterprise Zero-Trust Authentication & Dynamic Sidecar Secret Injection on AWS EKS

Enterprise Zero-Trust Architecture Diagram Live EKS VPC Data Plane

Every tier in this architecture eliminates static secrets. Mutual trust is established across three security zones: Ingress, the Amazon EKS cluster mesh, and dedicated HashiCorp Vault security services.

EDGE INGRESS ZONE Client Browser HTTPS / TLS 1.3 AWS NLB / Ingress Port 80 / 443 TLS Terminated via PKI AMAZON EKS CLUSTER (mern-vault namespace) mern-frontend Pod React 19 Dashboard Reverse Proxy /api :3000 mern-backend Pod Express Backend (:3001) Reads In-Memory Secrets 📁 /vault/secrets/config.json Vault Agent Sidecar K8s SA JWT Auth Auto-Renews Lease (1h) mongodb StatefulSet MongoDB Engine (:27017) Ephemeral Users Only v-token-* (Auto-Dropped) EBS Storage Volume Encrypted at Rest (KMS) Zero Passwords on Disk HASHICORP VAULT ZERO-TRUST CORE auth/kubernetes/mern-vault Validates SA JWT via EKS OIDC JWKS Binds: SA="mern-backend" → Policy database/ (Dynamic Secrets Engine) Role: mern-app-role (readWrite) Role: mern-analytics-role (readOnly) Runs: db.createUser() / db.dropUser() pki/ (Automated X.509 & ACME CA) Role: mern-vault-dot-io (Root CA) On-Demand Ephemeral Private Keys Short-Lived (24h) Zero-Outage Renewal

1. Zero Secrets in Git or Environment Variables

No AWS IAM keys, Vault root tokens, or DB passwords are hardcoded in Kubernetes manifests or containers.

2. Cryptographic ServiceAccount Identity

Kubelet projects an RFC 7519 JWT into the pod; Vault validates its signature against the Amazon EKS OIDC provider.

3. Dynamic Ephemeral Database Leases

MongoDB users are generated with 1-hour TTLs on-demand and automatically dropped upon revocation or pod termination.

4. Automated PKI & Microsegmentation

Certificates are signed on-the-fly by Vault's PKI engine, establishing verified TLS without manual cert rotation.

Live Cluster Telemetry & Active Lease Metadata

Loading live telemetry from backend...

Vault Dynamic Database Secrets Engine Zero Static Credentials & Auto-Revocation

Eliminate static database passwords permanently. With the Vault Database Secrets Engine mounted at database/, Vault dynamically creates short-lived, individual MongoDB database users on-the-fly and automatically drops them when leases expire.

1. On-Demand User Generation

When an application or pod requests credentials, Vault connects to MongoDB and executes db.createUser({ user: "v-token-...", roles: ["readWrite"] }).

2. Ephemeral Lease Lifecycles

Credentials are leased for 1 hour (3600s). Vault Agent continually renews the lease while the pod is healthy.

3. Automated User Revocation

When a pod terminates or a lease expires without renewal, Vault immediately executes db.dropUser() in MongoDB.

4. Granular Least-Privilege Roles

Different application tiers request different roles (e.g. mern-app-role for readWrite, mern-analytics-role for readOnly).

⚡ Live Dynamic MongoDB User Generation Console

Select an authorized Vault database role to generate an on-demand ephemeral MongoDB database user:

Zero-Trust Identity Handshake (Kubernetes ServiceAccount → Vault Auth) RFC 7519 / OIDC Trust

Traditional setups force developers to store long-lived cloud credentials or static tokens in Kubernetes secrets. With Vault's Zero-Trust Kubernetes Auth Method, the pod's identity is established dynamically through short-lived cryptographic tokens without a single static secret stored anywhere.

1. Kubelet Token Projection

When the pod boots, Kubelet mounts an RFC 7519 ServiceAccount JWT at /var/run/secrets/kubernetes.io/serviceaccount/token signed by EKS OIDC.

2. Cryptographic TokenReview

Vault receives the JWT and verifies its RS256 signature against the Amazon EKS cluster's public JWKS endpoint (no shared secrets needed).

3. Strict Metadata & Namespace Binding

Vault enforces that the request originated from the authorized namespace (mern-vault) and service account (mern-backend).

4. Least-Privilege Ephemeral Token

Vault returns an in-memory client token bound strictly to required ACL policies (mern-vault-database-read, pki-issue-mern-vault).

⚡ Live Cryptographic Auth Handshake Simulation

Trigger a live token projection & OIDC signature verification cycle to inspect the underlying JWT claims, role binding, and execution trace:

Vault Agent Sidecar & Consul Template Engine (Zero Code Refactor) In-Memory emptyDir / Zero SDK

Developers never need to import HashiCorp Vault SDKs or rewrite backend application logic. The Vault Agent Mutating Webhook injects a lightweight sidecar that renders secrets directly into in-memory files in whichever format your application expects.

1. Zero SDK Overhead in App Code

Applications read local files like fs.readFileSync('/vault/secrets/config.json') or native environment files without Vault SDK imports.

2. In-Memory Security Isolation

Secrets exist strictly in RAM on an emptyDir { medium: "Memory" } volume. Zero credentials touch the host worker node disk.

3. Dynamic Format Transformation

Consul Template allows transforming any Vault secret into JSON, .env files, YAML, or Java Spring Boot property files.

4. Automatic File Watcher & SIGHUP

When Vault rotates a database secret or renews a lease, Vault Agent overwrites the file and can trigger graceful application reloads.

⚡ Live In-Memory Template Transformer Playground

Select an output format to see how the Vault Agent Consul Template transforms dynamic database credentials into native configuration files:

HashiCorp Vault PKI Secrets Engine & End-to-End mTLS Zero-Trust Encryption Mutual TLS & ACME / Let's Encrypt

Instead of manual certificate provisioning or static private keys sitting in Kubernetes secrets, HashiCorp Vault operates as a high-velocity, automated Certificate Authority. Workloads dynamically request short-lived certificates signed by Vault Root & Let's Encrypt intermediates with automated rotation and mutual TLS enforcement.

1. Vault Root CA & ACME Role

Mount path pki/ configured with 10-year root key and dynamic issue role mern-vault-dot-io supporting ACME DNS-01/HTTP-01 validation.

2. Ephemeral Private Keys

Private keys are generated on demand inside memory and never written to Git, ConfigMaps, or long-term disk.

3. Zero-Outage Auto-Renewal

Short lease TTLs (24h) eliminate stale certificates; Cert-Manager / Vault Agent renews before expiry.

4. End-to-End mTLS Encryption

Service-to-service communication across EKS pods (Frontend ↔ Backend ↔ MongoDB) is cryptographically authenticated via TLS 1.3.

🔒 Live In-Cluster Mutual TLS (mTLS) Handshake Verifier

Test the cryptographic peer-to-peer mTLS handshake between the React Frontend and Express Backend using dynamic certificates issued by Vault PKI:

🌐 Frontend Ingress Security Switcher & Custom Vanity Domain
Port 443 (HTTPS / Let's Encrypt)

Switch between standard Port 80 (HTTP) and secured Port 443 (HTTPS) with an automated Let's Encrypt / Vault PKI signed certificate attached to your custom vanity FQDN:

Ingress Security Mode:
Current Public Endpoint:
https://mern-vault.christian-renaud.sbx.hashidemos.io
Certificate Authority: HashiCorp Vault ACME / Let's Encrypt Intermediate (Valid TLS 1.3)
⚡ Live On-Demand Certificate Signing Console

Generate and sign an X.509 TLS certificate dynamically through Vault's PKI engine:

Verified Data Plane — Zero-Trust End-to-End Live Proof

What are we proving? A real application write to MongoDB where the developer never sees, stores, or manages a single password. Vault dynamically generates a short-lived database user for each running pod, injects the credentials into an in-memory file, and automatically revokes the user when the pod stops — all without any change to the application code.

Real-world relevance: This is the pattern IBM and enterprise customers use to pass SOC2, PCI-DSS, and FedRAMP audits. Every secret access is logged, attributed to a specific pod identity, and expires automatically. A leaked credential is dead within the TTL — no emergency rotation required.

How a Single Write Reaches MongoDB Without a Static Password

Five discrete security checkpoints execute in under 30ms every time the Express backend writes a record:

1
Pod Starts → Vault Agent Sidecar Injects
When Kubernetes schedules the Express pod, the Vault Agent Mutating Webhook injects a sidecar container. The sidecar authenticates to Vault using the pod's projected ServiceAccount JWT (signed by EKS OIDC — no static token).
vault write auth/kubernetes/login role=mern-backend-role jwt=$SA_TOKEN
2
Vault Issues Ephemeral MongoDB User
Vault's Database Secrets Engine connects to MongoDB as the root admin and runs db.createUser() generating a unique username like v-token-mern-app-x4f2 with a random password and a 1-hour TTL. The credentials are never persisted to disk.
vault read database/creds/mern-app-role → {username, password, lease_id, ttl: 3600s}
3
Credentials Rendered to In-Memory File Only
The sidecar renders the credentials into /vault/secrets/config.json on an emptyDir medium: Memory volume — a RAM-backed tmpfs. The file never touches the node disk. The Express app reads it with a single fs.readFileSync() call. No SDK. No environment variables.
{"mongo_username":"v-token-mern-app-x4f2","mongo_password":"dyn-...","mongo_host":"mongodb.mern-vault.svc"}
4
Express Authenticates to MongoDB → Write Executes
The Express backend constructs a MongoDB connection URI from the in-memory credentials and executes the write. MongoDB sees a valid short-lived user. The application code has zero knowledge of the actual credential values.
mongodb://v-token-mern-app-x4f2:<dynamic>@mongodb.mern-vault.svc:27017/merndb
5
Lease Expires → User Auto-Revoked in MongoDB
After 3600 seconds (or when the pod terminates), Vault's lease manager automatically calls db.dropUser("v-token-mern-app-x4f2") in MongoDB. The credential ceases to exist. No rotation script. No on-call alert. No service restart required.
vault lease revoke database/creds/mern-app-role/v-token-mern-app-x4f2 → db.dropUser() executed
0
Static passwords in code, git, or env vars
3600s
Max credential lifetime — auto-revoked at expiry
100%
Writes attributed to pod identity in Vault audit log
0
Lines of Vault SDK code in Express app
⚡ Live Transaction Dispatcher

Submit a write below. The backend will resolve in-memory Vault credentials, authenticate to MongoDB under a short-lived v-token-* user, and return a full execution trace showing every hop in the pipeline.

MongoDB Write Ledger
Every entry was written by an ephemeral Vault user — no entry shares the same credential

    Enterprise Threat Model Comparison & CISO Scorecard Zero-Trust vs. Traditional Kubernetes

    Compare the architectural resilience of HashiCorp Vault against traditional static Kubernetes secrets across real-world attack vectors, breach containment scenarios, and compliance controls.

    Traditional Kubernetes Secrets High Risk (Score: 32/100)
    • Base64 static tokens in plaintext env variables
    • Credentials rarely rotated (avg. 180+ days)
    • Single pod breach exposes entire database cluster
    HashiCorp Vault Zero-Trust Enterprise Hardened (Score: 98/100)
    • Short-lived OIDC ServiceAccount tokens (RFC 7519)
    • Dynamic ephemeral users auto-dropped on lease expiry
    • In-memory RAM volume isolation with full audit logs
    ⚡ Interactive Threat Scenario Simulator

    Select an attack scenario to evaluate containment and blast-radius mitigation:

    Attack Vector / Control Traditional Kubernetes Pattern HashiCorp Vault Zero-Trust Architecture Risk Reduction
    1. Secret Storage & Persistence Base64 encoded plaintext in etcd / environment variables AES-256 encrypted at rest in Vault KV-v2; rendered only to in-memory RAM 95% Risk Drop
    2. Credential Lifecycle Static passwords lasting months or years without rotation Ephemeral dynamic database users generated on-demand with 1h TTL auto-drop Zero Stale Keys
    3. Blast Radius Containment Single pod compromise leaks root credentials for all services Isolated strictly to individual temporary user; auto-revoked upon pod termination Micro-Segmented
    4. Identity Verification Static API tokens or long-lived cloud IAM secret keys EKS OIDC cryptographic JWT handshake with automatic TokenReview Passwordless Trust
    5. Audit Trail & Compliance No audit records when applications read secrets from memory Immutable audit logging for every single secret access linked to pod SA identity 100% Traceable
    6. Transport Security Plaintext in-cluster HTTP or manually managed TLS certificates Automated TLS 1.3 & mTLS certificate lifecycle via Vault PKI / Let's Encrypt CA Automated PKI