Authorization becomes inconsistent. The app may log the user in successfully, but Firestore rules, Storage rules, and other Firebase services can point at a different identity namespace, which creates access drift, broken data isolation, or overbroad document access.
Why This Matters for Security Teams
When an external subject does not match the Firebase UID, the problem is not just a broken lookup. It is an identity boundary failure. Authentication may succeed, but authorization logic, Firestore pathing, and Storage rules can all evaluate a different namespace, which creates access drift and makes least privilege unreliable. NHI Management Group has documented how identity mismatches and exposed credentials can compound quickly, as seen in the Google Firebase misconfiguration breach and the Ultimate Guide to Non-Human Identities.
For security teams, the practical risk is that the app can appear to work while enforcing the wrong trust decision underneath. That often means one user can read another user’s documents, a service account can inherit broader access than intended, or security rules become impossible to reason about during incident response. This is especially dangerous in systems that mix human users, service accounts, and application-level identities without a single canonical subject identifier. The issue maps cleanly to identity assurance and access control concerns in the NIST Cybersecurity Framework 2.0, where identity consistency is foundational to trustworthy enforcement. In practice, many teams only discover the mismatch after a data exposure, not during deliberate access testing.
How It Works in Practice
Firebase security works best when the external subject, the Firebase UID, and the authorization model all refer to the same canonical identity. If the external identity provider issues a subject value that differs from the UID used in Firestore rules or document ownership checks, the system can authenticate one entity while authorizing another. That split is where drift begins: rules may compare against stale profile data, derived claims, or a user record that does not correspond to the token subject.
In practice, teams should make the UID the stable binding point and treat external identity attributes as inputs, not the authority itself. Common patterns include:
- Mapping the external subject to a single immutable Firebase UID at account creation.
- Storing the canonical subject in custom claims or a dedicated identity registry.
- Evaluating Firestore and Storage access against that canonical identifier, not display names or mutable email fields.
- Revoking and reissuing tokens when the upstream subject changes, merges, or is re-provisioned.
- Using explicit account-linking logic when the same person may sign in through multiple identity providers.
This is closely aligned with least privilege and access governance guidance in NIST Cybersecurity Framework 2.0, because authorization should be deterministic, auditable, and tied to a single source of truth. The NHIMG Ultimate Guide to Non-Human Identities is useful here because the same pattern appears with service accounts: once identity namespaces diverge, offboarding, rotation, and access review all become unreliable. These controls tend to break down when legacy apps reuse multiple identity namespaces in the same token path because the rule engine cannot tell which subject is authoritative.
Common Variations and Edge Cases
Tighter identity binding often increases integration overhead, requiring organisations to balance clean authorization semantics against migration cost and user lifecycle complexity. That tradeoff becomes visible when external IdPs, Firebase Auth, and legacy application accounts all coexist.
There is no universal standard for this yet, but current guidance suggests treating mismatched identity as a design defect, not a harmless mapping issue. A few edge cases deserve attention:
-
Account linking flows can create temporary duplication if the system allows two external subjects to map to one app user without a clear canonical rule.
-
Anonymous or guest sessions may not have a stable external subject, so the application should isolate them from persistent user data until binding is complete.
-
Tenant migrations can invalidate old subject values, which means rules should rely on durable internal IDs rather than provider-specific claims that may change.
-
Shared devices and delegated admin roles can obscure who the real subject is, especially when the app inherits the wrong token after session handoff.
The practical lesson is simple: if the external subject and Firebase UID do not match, authorization cannot be trusted to stay consistent. The safest response is to make identity binding explicit, test it continuously, and reject any flow where the app cannot prove which subject is actually being authorized.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Identity mismatch creates ambiguous ownership and weak subject binding. |
| OWASP Agentic AI Top 10 | A-03 | Wrong subject binding is a core authorization failure in autonomous systems. |
| CSA MAESTRO | ID-1 | MAESTRO emphasizes strong identity governance for machine actors and workflows. |
| NIST AI RMF | GOVERN | AI governance requires traceable identity and accountability for access decisions. |
| NIST CSF 2.0 | PR.AC-1 | Access control depends on verified identities matching the authorization subject. |
Bind every workload or app identity to one canonical subject and reject drift across systems.
Related resources from NHI Mgmt Group
- What breaks when sandbox validation does not match actual execution in agent systems?
- What breaks when an app relies on a hidden token broker for external data access?
- What breaks when every document is synced to an external authorization system?
- What breaks when identity programmes cannot map access back to a real subject?