Attacker initiated verification binds a victim email to the attacker
The email verification endpoint did not check that the person clicking the link was the same account that started the request, so an attacker could add a victim's email address to their own account. After the victim clicked the genuine verification link, the address became a verified channel on the attacker's account and the victim was blocked from linking it to their own.
Originally disclosed on Immunefi
- Disclosed after under an hour
93060 w a low attacker initiated verification binds a victim email to the attacker
Submitted on Sep 14th 2026 at 04:42:24 UTC by @Johnyfwesh for Audit Competition | ENS
- Report ID: #93060
- Report Type: Websites & Apps
- Report severity: Low
- Target: https://github.com/immunefi-team/audit-comp-ens/tree/audit-comp-ready/workers
- Impacts:
- Changing non-sensitive details of other users (including modifying browser local storage) without already-connected wallet interaction and with up to one click of user interaction, such as: Enabling/disabling notifications
Description
Finding Description and Impact
POST /notifications/channels/email is an authenticated channel-creation endpoint that accepts an arbitrary email address and stores the requester’s user_id on both the userChannels row and the channelVerifications record. Completing verification is supposed to prove that the mailbox owner intends to attach that address to that account. The public POST /notifications/channels/email/verify handler does not do that. It has no requireAuth middleware and authorizes exclusively by looking up the emailed token (purpose = 'verify', not expired). The token then points back at the initiator’s channel_id / user_id. Confirming mailbox access therefore binds the address to whichever account started the request.
The verification email and Manager verify page make that confusion practical. Production sendVerificationEmail sends a genuine ENS Notifications message to the submitted address. The link is the real Manager URL (/notifications/channels/email/verify?token=…). The body never names the initiating wallet or user id; the primary call to action is “Verify Email Address.” The page posts only { token } and works while logged out. One recipient click is enough.
After verify, the handler marks the initiator’s channel verified, sends a welcome mail to the victim address, and waitUntils addContactToList(victimEmail, verification.user_id). The victim’s mailbox is then a verified notification channel on the attacker account and a SendGrid broadcast contact tagged with the attacker’s user id. POST /email rejects any later attempt to attach an already-verified address to another user, so the victim cannot link that email to their own account. The attacker keeps lifecycle control of the channel and any associated SendGrid updates.
This is an authorization-binding flaw: possession of a self-issued JWT plus one victim click on a first-party verification link changes a sensitive email association, with no connected-wallet interaction.
Affected code
.post(
'/',
...requireAuth,
injectDb,
vValidator('json', addEmailChannelBodySchema),
async (c) => {
const userId = c.var.user_id
const { email: rawEmail } = c.req.valid('json')
const email = normalizeEmailForRateLimit(rawEmail)
- Authenticated create accepts any syntactically valid email.
userIdis taken from the caller’s JWT, not from mailbox ownership. That is the only identity later written onto the channel and verification rows. workers/api-worker/src/app/routes/notifications/channels/email.ts#L74-L120(userChannels+channelVerificationsinsert)
const channel = await c.var.db
.insert(TABLE.userChannels)
.values({
user_id: userId,
channel: 'email',
status: 'pending',
target: email,
})
// ...
const verification = await c.var.db
.insert(TABLE.channelVerifications)
.values({
user_id: userId,
channel_id: channel.id,
channel: 'email',
purpose: 'verify',
token: generateToken(),
expires_at: new Date(Date.now() + 24 * 60 * 60 * 1000),
attempts: 0,
})
- Both records are keyed to the requester. The emailed token is a capability for this pending channel, not a capability for “whoever owns the mailbox.” An attacker can plant that binding for a victim address before any victim-side action.
workers/api-worker/src/services/email/verification.ts#L9-L36(sendVerificationEmail)
export const sendVerificationEmail = ResultFn(async function* (
apiKey: string,
fromEmail: string,
toEmail: string,
verificationToken: string,
managerAppUrl: string,
) {
const verificationUrl = `${managerAppUrl}/notifications/channels/email/verify?token=${encodeURIComponent(verificationToken)}`
// ...
subject: 'Verify your email address - ENS Notifications',
content: [
{
type: 'text/plain',
value: `Verify your email address - ENS Notifications
Thank you for signing up for ENS notifications! Please verify your email address by clicking the link below.
${verificationUrl}
This verification link will expire in 24 hours. If you didn't request this email, you can safely ignore it.
- The message is a first-party ENS Notifications email to the victim. It never discloses the initiating account (wallet or user id). The only account-binding action offered is following the official Manager verify URL.
apps/manager/src/routes/notifications/channels/email/verify.tsx#L77-L92and#L218-L225(one-click Manager confirm)
const handleVerify = (verificationToken?: string) => {
const tokenToUse = verificationToken || token
if (!tokenToUse) return
verifyEmailMutation.mutate(tokenToUse, {
onSuccess: () => {
toast.success(t`Email verified successfully`)
setTimeout(() => {
navigate({ to: continueTo })
}, 1200)
},
})
}
// ...
<Button
className="w-full text-sm leading-ens-none"
onClick={() => handleVerify()}
size="lg"
variant="blue"
>
<Trans>Verify Email Address</Trans>
</Button>
- The Manager page is a public route. One click posts the query token through
verifyEmailMutationOptions, which sends only{ token }and does not require the visitor to authenticate as the channel owner (channels.ts#L177-L182). workers/api-worker/src/app/routes/notifications/channels/email.ts#L172-L201(POST /email/verify)
.post(
'/verify',
vValidator('json', verifyEmailChannelBodySchema),
injectDb,
async (c) => {
const { token } = c.req.valid('json')
const verification = await c.var.db.query.channelVerifications.findFirst({
where: and(
eq(TABLE.channelVerifications.token, token),
eq(TABLE.channelVerifications.purpose, 'verify'),
gt(TABLE.channelVerifications.expires_at, new Date()),
),
with: {
channel: true,
},
})
// ...
await c.var.db
.update(TABLE.userChannels)
.set({
status: 'verified',
verified_at: new Date(),
})
.where(eq(TABLE.userChannels.id, verification.channel_id))
/verifyis unauthenticated. Lookup is token + purpose + expiry only. Success marksverification.channel_idverified the attacker’s pending row without checking that the caller is, or intends to bind to, that channel’suser_id.workers/api-worker/src/app/routes/notifications/channels/email.ts#L232-L243(addContactToListafter verify)
if (c.env.SENDGRID_BROADCAST_LIST_ID && verification.channel?.target) {
c.executionCtx.waitUntil(
Promise.resolve(
addContactToList(
{
SENDGRID_API_KEY: c.env.SENDGRID_API_KEY,
SENDGRID_BROADCAST_LIST_ID: c.env.SENDGRID_BROADCAST_LIST_ID,
},
verification.channel.target,
verification.user_id,
),
- Broadcast enrollment uses the victim email and the stored initiator
user_id. Completing the token therefore associates the mailbox with the attacker in SendGrid as well as inuserChannels. workers/api-worker/src/services/sendgrid/contacts.ts#L53-L75(addContactToList)
export const addContactToList = ResultFn(async function* (
env: SendGridEnv,
email: string,
userId?: string,
) {
const url = new URL(`${BASE_URL}/v3/marketing/contacts`)
const response = yield* fromPromise(
fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${env.SENDGRID_API_KEY}`,
},
body: JSON.stringify({
list_ids: [env.SENDGRID_BROADCAST_LIST_ID],
contacts: [
{
email,
...(userId && { custom_fields: { user_id: userId } }),
},
],
}),
}),
- Downstream marketing update is caller-supplied
email+userId. After a confused-deputy verify, those values are the victim address and the attacker id. workers/api-worker/src/app/routes/notifications/channels/email.ts#L58-L72(verified-email lockout)
const otherUserChannel = await c.var.db.query.userChannels.findFirst({
where: and(
eq(TABLE.userChannels.channel, 'email'),
eq(TABLE.userChannels.target, email),
eq(TABLE.userChannels.status, 'verified'),
),
})
if (otherUserChannel && otherUserChannel.user_id !== userId) {
return c.json(
{ error: 'This email address is already linked to another account' },
400,
)
}
- After the attacker’s row is
verified, the same uniqueness check that failed to stop the unsolicited start now blocks the mailbox owner from linking the address to their own account. workers/api-worker/src/core/database/schema/notifications.ts#L95-L113(channelVerifications)
export const channelVerifications = pgTable('channel_verifications', {
id: uuid('id').primaryKey().default(randomUUIDv7),
user_id: uuid('user_id')
.notNull()
.references(() => users.id, { onDelete: 'cascade' }),
channel_id: uuid('channel_id')
.references(() => userChannels.id, {
onDelete: 'cascade',
})
.notNull(),
// ...
purpose: text('purpose').notNull(), // 'verify' | 'unsubscribe' | 'link'
token: text('token').notNull(),
- The token row permanently records which account initiated verification.
/verifynever re-binds thatuser_idto the person who clicked.
Impact
Victim email becomes a verified channel on the attacker account
- An ordinary SIWE-authenticated wallet holder posts the victim address to
POST /notifications/channels/email(email.ts#L29-L37). If the recipient follows the official verification link and clicks once,/verifymarks the attacker’suserChannelsrowverified(email.ts#L194-L201). - No victim wallet connection is required. The verify handler ignores JWTs entirely; a logged-in victim session does not retarget the binding.
Sensitive email association and SendGrid enrollment move to the attacker
addContactToListis invoked with the victim email andverification.user_id(attacker) (email.ts#L232-L243). The mailbox is enrolled on the broadcast list under the attacker’s user id.- The attacker owns that channel’s lifecycle (
GET/DELETE/POST …/testauthorize byid + attacker user_id) and can later trigger SendGrid changes for the same address.
Victim is locked out of binding the address to their own account
POST /emailthen returns400 This email address is already linked to another account(email.ts#L67-L71). The victim cannot create their own email channel for that mailbox while the attacker’s verified row remains.
Alignment with Immunefi and ENS program rules
This report is in scope for the ENS Immunefi Audit Competition (Websites and Applications) under the program scope page and the Immunefi Vulnerability Severity Classification System v2.3 (Websites and Apps). The demonstrated behavior matches the following published rules.
In-scope asset. The program lists workers/ specifically workers/api-worker (SIWE, JWT, notifications, SendGrid/Telegram webhooks) and apps/manager. The binding logic lives in the worker (POST /notifications/channels/email, POST /email/verify, addContactToList). The one-click confirm path is the Manager verify page. A fault in these trees, or reachable through them, is in scope.
Immunefi v2.3 / program High: changing another user’s sensitive details. The High impact includes:
Changing sensitive details of other users (including modifying browser local storage) without already-connected wallet interaction and with up to one click, e.g. email/password of the victim
This report matches that rule. The changed detail is the victim’s email-to-account association (the classification’s own example is email). The attacker does not need the victim’s connected wallet. The recipient’s single click on the first-party “Verify Email Address” control is the allowed one-click interaction. This is not phishing: the email and verify page are the real ENS Notifications / Manager surfaces.
First-party worker logic; eligible adversary. The attacker is an ordinary SIWE-authenticated wallet holder using their own JWT not a privileged, local-network, or excluded adversary. The defect is first-party authorization binding.
Demonstrated, single root cause. Create stores the requester identity; verify treats token possession as authority to finalize that stored identity. The PoC drives the real create, mail, verify, and addContactToList clients and shows the lockout.
Recommended mitigation steps
- Separate mailbox proof from account binding:
- Require
/verifyto run underrequireAuthand accept the token only whenc.var.user_id === verification.user_id, or - Issue the token to the mailbox and, on click, create/verify the channel for the currently authenticated user rather than the initiator, or
- Store no
user_idon the pending channel until an authenticated recipient confirms.
- Require
- Make the initiating account visible before the click:
- Put the requester wallet / primary name in the verification email and on the Manager confirm page, and
- Require an explicit “link this email to 0x…” acknowledgement, not a generic “Verify Email Address.”
- Do not let a third-party verified row lock the mailbox owner out:
- At verify time, reject if another user already holds a verified (or pending) row for that
target, and - Prefer a unique constraint on
(channel, target)for email so only one account can claim an address.
- At verify time, reject if another user already holds a verified (or pending) row for that
- Do not enroll SendGrid under the initiator id unless that id is the confirmed account:
- Pass the authenticated verifier’s
user_idintoaddContactToList, or skip broadcast sync until a matching authenticated session exists.
- Pass the authenticated verifier’s
Proof of Concept
PoC Test (runs in workers/api-worker/test/attacker-initiated-email-verification-binds-victim.test.ts) demonstrating attacker-initiated email binding
The PoC drives the real Hono app: POST /email, POST /email/verify, GET /channels, DELETE /channels/:id, plus production sendVerificationEmail, sendWelcomeEmail, addContactToList, searchContact, and deleteContact. JWTs are minted with the test secret (the bug is after a valid session exists; SIWE login is not in the path). fetch is stubbed only at the SendGrid HTTP boundary and throws on any other origin. Postgres is an in-memory store that parses the eq / and / gt trees the handlers emit and throws on an unknown clause. KV is an in-memory map so the 3/hour verification cap is real.
Assertions are HTTP-first: status/body from the handlers, captured SendGrid payloads (including custom_fields.user_id), and GET /channels visibility. The verify helper issues the same request as Manager verifyEmailMutationOptions (POST /notifications/channels/email/verify with { token }). It does not load the Manager page in a browser.
Six cases, split into exploit / lifecycle / uniqueness gap / bounds:
| Case | What it shows |
|---|---|
| Unauthenticated Manager-shaped verify | Attacker create → official mail with no initiator identity → { token } POST with no Authorization → attacker GET /channels lists the victim email as verified → victim GET /channels is empty → victim POST /email is 400 |
Victim JWT on /verify |
Logged-in Manager session is ignored; bind still goes to the attacker |
| Attacker lifecycle | Victim DELETE of the attacker channel is 404. Attacker DELETE succeeds, removes the SendGrid contact (search + delete), and only then can the victim POST /email |
| Both pending tokens | Create uniqueness allows two pending rows. /verify does not re-check uniqueness, so both accounts can end up verified for the same address |
| Late attacker create | If the victim verifies first, attacker POST /email is 400 (attack window is first-claimer) |
| Rate limit | Fourth send to the same address is 429; the bind is not “unlimited mail” |
Relevant Code Flow Diagram
sequenceDiagram
participant Attacker
participant API as API worker
participant DB as userChannels / channelVerifications
participant Mail as SendGrid Mail
participant Victim
participant Mgr as Manager verify page
participant SG as SendGrid Marketing Contacts
Attacker->>API: POST /notifications/channels/email { email: [email protected] }<br/>Authorization: Bearer attacker JWT
API->>DB: Check for a verified channel with target [email protected]
DB-->>API: No verified channel exists
API->>DB: Upsert pending userChannels row<br/>user_id=attacker<br/>[email protected]
API->>DB: Insert channelVerifications row<br/>user_id=attacker<br/>channel_id=attacker channel<br/>purpose=verify<br/>token
API->>Mail: POST /v3/mail/send to [email protected]<br/>with the Manager verification URL
Mail-->>Victim: ENS verification email<br/>(does not identify the attacker)
Victim->>Mgr: Open the Manager URL
Victim->>Mgr: Click Verify Email Address
Mgr->>API: POST /notifications/channels/email/verify { token }
Note over Mgr,API: Public handler: authentication is not required<br/>any supplied JWT is not checked against verification.user_id
API->>DB: Find unexpired verify token and load its channel
DB-->>API: attacker user_id<br/>attacker channel_id<br/>channel [email protected]
API->>DB: Set attacker channel status=verified
API->>DB: Delete consumed verification row
API->>Mail: POST /v3/mail/send welcome email to victim
API->>SG: Register waitUntil(PUT /v3/marketing/contacts)<br/>[email protected]<br/>custom_fields.user_id=attacker
Note over API,SG: Background task when SENDGRID_BROADCAST_LIST_ID is set
API-->>Mgr: 200 Email verified successfully
Mgr-->>Victim: Show verification success
Victim->>API: POST /notifications/channels/email { email: [email protected] }<br/>Authorization: Bearer victim JWT
API->>DB: Find verified channel with target [email protected]
DB-->>API: Attacker-owned verified channel
API-->>Victim: 400 already linked to another account
Note over Victim: Mailbox is verified on the attacker's channel<br/>the victim cannot attach it to their own account
Test file workers/api-worker/test/attacker-initiated-email-verification-binds-victim.test.ts
import { sign } from 'hono/jwt'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { makeMockEnv } from '#test-utils/env.js'
/**
* -----------------------
* Real: Hono app, POST /email, POST /email/verify, GET /channels,
* DELETE /channels/:id, sendVerificationEmail, sendWelcomeEmail,
* addContactToList, searchContact, deleteContact, generateToken,
* requireAuth / verifyJWT, email verification rate limiter.
* The Manager verify page is not loaded in a browser. verifyEmailChannel()
* issues the same request as
* apps/manager/src/features/notifications/data/queries/channels.ts
* verifyEmailMutationOptions: POST /notifications/channels/email/verify
* with JSON `{ token }` and no requirement that the caller is the channel owner.
*/
const harness = vi.hoisted(() => {
type ChannelRow = {
id: string
user_id: string
channel: string
target: string | null
data: unknown
status: string
status_reason: string | null
verified_at: Date | null
last_sent_at: Date | null
last_bounce_at: Date | null
last_verification_sent_at: Date | null
verification_attempts: number
}
type VerificationRow = {
id: string
user_id: string
channel_id: string
channel: string
target: string | null
purpose: string
token: string
created_at: Date
expires_at: Date
consumed_at: Date | null
attempts: number
}
type SendGridContact = {
id: string
email: string
listIds: string[]
userId?: string
}
type RecordedSendGridRequest = {
method: string
pathname: string
searchParams: Record<string, string>
body: unknown
authorization: string | null
}
type RecordedVerifyRequest = {
authorization: string | null
body: { token: string }
}
return {
channels: [] as ChannelRow[],
verifications: [] as VerificationRow[],
contacts: new Map<string, SendGridContact>(),
sendgridRequests: [] as RecordedSendGridRequest[],
verifyRequests: [] as RecordedVerifyRequest[],
getDatabase: vi.fn(),
}
})
vi.mock('#core/database/index.js', async (importOriginal) => {
const actual =
await importOriginal<typeof import('#core/database/index.js')>()
return {
...actual,
getDatabase: harness.getDatabase,
}
})
vi.mock('#utils/logger.js', () => ({
logger: {
info: vi.fn(),
error: vi.fn(),
warn: vi.fn(),
debug: vi.fn(),
trace: vi.fn(),
},
}))
import app from '#app/index.js'
import { TABLE } from '#core/database/index.js'
import { formatEmailVerificationRateLimitError } from '#services/notifications/email-verification-rate-limit.js'
const VICTIM_EMAIL_INPUT = '[email protected]'
const VICTIM_EMAIL = '[email protected]'
const ATTACKER_USER_ID = '11111111-1111-4111-8111-111111111111'
const VICTIM_USER_ID = '22222222-2222-4222-8222-222222222222'
const ATTACKER_ADDRESS = '0xa11ce00000000000000000000000000000000000'
const VICTIM_ADDRESS = '0xb0b0000000000000000000000000000000000000'
const BROADCAST_LIST_ID = 'ens-broadcast-list'
const JWT_SECRET = 'poc-jwt-secret'
const SENDGRID_API_KEY = 'SG.poc'
const SENDGRID_ORIGIN = 'https://api.sendgrid.com'
const MANAGER_APP_URL = 'https://app.ens.dev'
const EMAIL_FROM_ADDRESS = '[email protected]'
const VERIFY_PATH = '/notifications/channels/email/verify'
const CREATE_PATH = '/notifications/channels/email'
const CHANNELS_PATH = '/notifications/channels'
type Predicate = {
column: string
op: string
value: unknown
}
const UNSET = Symbol('unset')
const columnName = (node: unknown): string | undefined => {
if (!node || typeof node !== 'object') {
return undefined
}
const candidate = node as {
name?: unknown
table?: unknown
dataType?: unknown
columnType?: unknown
}
if (
typeof candidate.name === 'string' &&
(candidate.table || candidate.dataType || candidate.columnType)
) {
return candidate.name
}
return undefined
}
const operatorString = (node: unknown): string | undefined => {
if (typeof node === 'string') {
return node
}
if (!node || typeof node !== 'object') {
return undefined
}
const candidate = node as { value?: unknown; queryChunks?: unknown[] }
if (typeof candidate.value === 'string') {
return candidate.value
}
if (Array.isArray(candidate.value)) {
return candidate.value.map(String).join('')
}
if (Array.isArray(candidate.queryChunks)) {
return candidate.queryChunks
.map((chunk) => {
if (typeof chunk === 'string') {
return chunk
}
if (chunk && typeof chunk === 'object' && 'value' in chunk) {
const value = (chunk as { value: unknown }).value
return Array.isArray(value) ? value.join('') : String(value ?? '')
}
return ''
})
.join('')
}
return undefined
}
const paramValue = (node: unknown): unknown => {
if (!node || typeof node !== 'object') {
return UNSET
}
const candidate = node as {
value?: unknown
queryChunks?: unknown[]
table?: unknown
}
if ('value' in candidate && !candidate.queryChunks && !candidate.table) {
return candidate.value
}
return UNSET
}
/**
* Walk a Drizzle SQL tree (`eq` / `and` / `gt`) and recover column comparisons
* so the in-memory store can honor the same predicates the handlers pass in.
* Unknown trees throw instead of silently matching every row.
*/
const extractPredicates = (node: unknown): Predicate[] => {
const predicates: Predicate[] = []
const visit = (current: unknown) => {
if (!current || typeof current !== 'object') {
return
}
const chunks = (current as { queryChunks?: unknown[] }).queryChunks
if (!Array.isArray(chunks)) {
return
}
for (let index = 0; index < chunks.length; index += 1) {
const name = columnName(chunks[index])
if (name) {
const op = operatorString(chunks[index + 1])
const value = paramValue(chunks[index + 2])
if (op && value !== UNSET) {
predicates.push({
column: name,
op: op.replace(/\s+/g, ''),
value,
})
index += 2
continue
}
}
visit(chunks[index])
}
}
visit(node)
return predicates
}
const compare = (actual: unknown, op: string, expected: unknown) => {
if (op === '>' || op === '>=' || op === '<' || op === '<=') {
const left =
actual instanceof Date
? actual.getTime()
: typeof actual === 'number'
? actual
: Number.NaN
const right =
expected instanceof Date
? expected.getTime()
: typeof expected === 'number'
? expected
: Number.NaN
if (op === '>') return left > right
if (op === '>=') return left >= right
i
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The verification endpoint trusted possession of the emailed token as proof of account ownership, without checking that the authenticated user matched the user who initiated the channel creation.
Impact
The victim's email becomes a verified notification channel on the attacker's account and is enrolled in the broadcast list under the attacker's user id, and the victim is then locked out of linking that address to their own account.
What the attacker needed
Attacker has a wallet-authenticated account; victim clicks the genuine verification link
The fix
The verification endpoint should require authentication and only accept the token when the authenticated user matches the user who initiated the channel, or the channel should be bound to the currently authenticated user at verification time.
How it was found
- The attacker, logged in with their own wallet, submits the victim's email address to the channel creation endpoint.
- The system stores the attacker's user id on the pending channel and verification record and sends a genuine verification email to the victim.
- The victim opens the official verification link and clicks the verify button.
- The verification endpoint marks the attacker's pending channel as verified and enrolls the victim's email in the broadcast list under the attacker's user id.
- The victim later tries to add their own email and receives an error that it is already linked to another account.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you add an email address to an account, the site should check that the person who owns the mailbox is the same person who owns the account. Here, the site sent a real verification email but never checked who clicked the link, so anyone who started the request could get someone else's email attached to their account. The victim then could not use their own email on their own account.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.