Merge local main (1.17.2) into security-a-118
Conflicts resolved by keeping both sides: lockedAnswer + sign-in rules in plugin.ts and switches.ts, IPv6 grouping in the mail service's new per-visitor address count, both built-site specs in e2e:built, docs and skills (reference copies synced). The lockedAnswer suite and the sign-in-answers spec now reach Payload's lock the 1.18.0 way: a spray from 50 IPs, one failure each (one IP alone gets 429 after five). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -4,7 +4,7 @@ import { createHash, randomBytes } from 'node:crypto'
|
||||
|
||||
import type { ResolvedRelayOptions } from './options.js'
|
||||
|
||||
import { consumeRateLimit } from '../../shared/rateLimit.js'
|
||||
import { consumeRateLimit, ipRateKey } from '../../shared/rateLimit.js'
|
||||
import { type RelayAnswer, type RelayRefusal, relayRequest } from './client.js'
|
||||
import { RELAY_DEFAULTS, type RelayStatusCode, relayStatusFor } from './constants.js'
|
||||
import { currentMailKind, type MailKind, mailKindOf, takeExpectedMail } from './kinds.js'
|
||||
@@ -136,14 +136,14 @@ export async function sendThroughRelay(payload: BasePayload, options: ResolvedRe
|
||||
const windowMs = (own.windowMinutes ?? RELAY_DEFAULTS.accountMail.windowMinutes) * 60_000
|
||||
const perAddress = own.perAddress ?? RELAY_DEFAULTS.accountMail.perAddress
|
||||
const checks = [
|
||||
...(marked?.visitor ? [{ key: `visitor:${marked.visitor}`, max: own.perVisitor ?? RELAY_DEFAULTS.accountMail.perVisitor }] : []),
|
||||
...(marked?.visitor ? [{ key: `visitor:${ipRateKey(marked.visitor)}`, max: own.perVisitor ?? RELAY_DEFAULTS.accountMail.perVisitor }] : []),
|
||||
// 1.18.0: one visitor (IP) gets `perAddress` mails to an address; the address gets `perAddressTotal` from everybody —
|
||||
// a stranger who fills an address's count from one IP no longer stops its owner's own reset mail (IAWL idea 16).
|
||||
...[...(request.to ?? []), ...(request.cc ?? []), ...(request.bcc ?? [])].flatMap((address) => {
|
||||
const to = `to:${sha256Hex(address.toLowerCase())}`
|
||||
return [
|
||||
// no visitor known (server code, no IP header): all such requests are one visitor
|
||||
{ key: marked?.visitor || 'no-visitor', max: perAddress, scope: `mail-relay-account:${to}` },
|
||||
{ key: marked?.visitor ? ipRateKey(marked.visitor) : 'no-visitor', max: perAddress, scope: `mail-relay-account:${to}` },
|
||||
{ key: to, max: own.perAddressTotal ?? RELAY_DEFAULTS.accountMail.perAddressTotal },
|
||||
]
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user