Skip to content

Auth emulator: signUp can set validSince one second after auth_time, so Admin SDK rejects the fresh ID token as revoked #11413

Closed

Description

@elinesaetre

Environment

  • firebase-tools 15.29.0 (code unchanged in 15.34.2)
  • firebase-admin 13.10.0, Node.js

What happens

Rarely, an ID token returned by accounts:signUp in the Auth emulator is rejected by the Admin SDK right away with auth/id-token-revoked, even though nothing revoked it. The emulator's own token check accepts the same token.

Cause

In lib/emulator/auth/operations.js, signUp reads the clock twice:

const timestamp = new Date();                    // used for lastLoginAt -> auth_time
...
updates.validSince = toUnixTimestamp(new Date()).toString();   // second clock read

Both are truncated to whole seconds. If a second boundary passes between the two reads, auth_time = N and validSince = N + 1. Against the emulator, the Admin SDK always checks revocation (checkRevoked || isEmulator in base-auth.js), so verifyIdToken and verifySessionCookie reject the token because auth_time < tokensValidAfterTime. Refreshing the token does not help, since auth_time stays the same; only a new sign-in does.

Repro

Stub Date so the clock moves from x.999 s to x+1.000 s during one signUp call; the resulting token has auth_time one second before validSince, and admin.auth().verifyIdToken(token) throws auth/id-token-revoked.

Suggested fix

Reuse the same timestamp:

updates.validSince = toUnixTimestamp(timestamp).toString();

Impact

Intermittent failures in end-to-end tests that sign up a user and then verify the token server-side.

Activity

  1. aalej commented on Nov 4, 2026

    @aalej
    Contributor

    Thanks for the detailed report, @elinesaetre! I was able to reproduce the issue, and your observations about the two different Date() reads causing the boundary race condition are correct.

    Your suggested fix to reuse the same timestamp (updates.validSince = toUnixTimestamp(timestamp).toString();) is spot on. We'll get a PR open to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions