logo svg
logo

February 12, 2025

From Email Reuse to Org Takeover: How a JWT Flaw Exposed Multiple Subdomains

A real-world penetration testing case study showing how weak JWT validation, missing email verification, and subdomain misconfigurations led to full organizational compromise.

Ahmed M. Arafat

Ahmed M. Arafat

Featured Image

A SaaS platform exposed itself to full organizational compromise due to insecure JWT validation (based on email), a lack of email verification, and a spoofable Source header used for tenant routing. This allowed attackers to reuse tokens across subdomains and escalate to admin control. Learn how we exploited this flaw in a real-world red team engagement, how to fix it, and how to future-proof your architecture.

"JWT token being reused across subdomains in a multi-tenant SaaS platform, leading to full admin compromise."

In this case study, we break down a real vulnerability found during a red team engagement that started with a duplicated email registration and ended in a full admin takeover.

The target? A SaaS provider that assumed the following were safe:

These assumptions led to a silent, yet critical architectural security flaw. This walkthrough documents exactly how we exploited the flaw, which tools we used, and how teams can design better safeguards from the start.

SaaS Architecture Overview

The application structure was multi-tenant, segmented by subdomain:

Both routed to a central API:

json
api.target.com

A custom HTTP header handled tenant separation:

json
Source: B-One

No cryptographic binding existed between the token and the tenant. No access control validation occurred on the server side to verify that a token issued to B-Two was being used on B-One. This was the Achilles' heel.

Discovery: Duplicate Emails, Duplicate Tokens

We registered the same email twice on different subdomains:

  1. Signup on B-One:
json
POST /users/sign-up
Host: api.target.com
Source: B-One
{
  "email": "[email protected]",
  "password": "P@ssWord123"
}
  1. Signup on B-Two:
json
POST /users/sign-up
Host: api.target.com
Source: B-Two
{
  "email": "[email protected]",
  "password": "P@ssWord123"
}

Both registrations succeeded. Each one returned a different JWT, yet both shared the same username (email):

json
{
  "iat": 1704719426,
  "exp": 1704723026,
  "username": "[email protected]",
  "id": "960912"
}

This revealed that the application logic was identifying users via username, not sub or a unique ID. JWT trust was based entirely on an email string.

Exploitation: Cross-Tenant Identity Injection

Armed with a JWT from B-Two, we made a request to B-One:

json
GET /user/me
Host: api.target.com
Authorization: JWT <B-Two token>
Source: B-One

The API returned the profile of the B-One user with the matching email. The token wasn't scoped to the tenant, and the backend trusted the Source header as-is.

What should have been isolated access per tenant became cross-tenant access based on email reuse.

"Simulated admin dashboard access after exploiting JWT and email registration flaws across tenants."

Escalation: From Email to Admin Dashboard

After successful user impersonation, we escalated further:

Result? Full admin access across the platform. We could:

Tools We Used

Why This Happened

1. JWT Validation by Email

Tokens were validated using the username field instead of a secure sub (subject) or ID. Emails can be duplicated or spoofed across tenants.

2. No Email Verification

Anyone could register any email address. This removed the ownership validation layer entirely.

3. No Tenant-Bound Claims

Tokens lacked any tenant_id, aud, or scope to restrict where they could be used.

4. Trusted Source Header

The backend used a client-controlled Source header to segregate tenants. Without cryptographic enforcement, this became a trivial bypass vector.

How to Fix It (The Right Way)

Identity & Claims

Token Management

Access Controls

Timeline of Events

Frequently Asked Questions (FAQ)

Q: Could this happen with Firebase/Auth0?
Yes. If the platform relies on email claims and lacks tenant-bound scopes or keys, it's vulnerable to similar exploits.

Q: Should I use 'email' in a JWT?
Only as a reference field. Never use it for access control or session validation. Always use sub or a UUID.

Q: Can I trust custom headers?
Not unless you're cryptographically verifying them. Headers can be spoofed by anyone with access to curl/Postman/Burp.

Q: What’s the best practice for multi-tenant tokenization?
Use separate keys, enforce tenant claims in access checks, and ensure backend logic maps tokens to the correct tenant context.

References

What to Do Now

Get the Checklist & Visual Flowchart

Download our JWT Security Checklist PDF and subscribe for the upcoming exploit flowchart.

Let DeepStrike Find the Flaws Before Attackers Do

If you're building a SaaS or multi-tenant platform, DeepStrike’s red team can help uncover flaws that slip past standard code reviews. Our team combines attacker mindset with architecture insight.

Book an engagement → DeepStrike.io

Stay sharp. Stay secure.