diff --git a/apps/waterfall-wiki/ACCOUNT.md b/apps/waterfall-wiki/ACCOUNT.md index 03fbf3f..6f49425 100644 --- a/apps/waterfall-wiki/ACCOUNT.md +++ b/apps/waterfall-wiki/ACCOUNT.md @@ -35,7 +35,10 @@ the global cap to 60 per trusted client address. Do not enable it on the direct Limits count failures and successes. Registration/resend always give the same success response for existing/unknown emails, and login uses a dummy KDF for unknown accounts. The rate limit itself can reveal recent activity for a known email; it does not reveal -whether an account exists. No password recovery or account deletion is included. +whether an account exists. Synchronous SMTP latency can still expose a timing side channel; +a durable asynchronous mail queue would be needed to fully decouple delivery timing. +Logout remains available when login/mail limits are exhausted. No password recovery or +account deletion is included. ## Verification diff --git a/apps/waterfall-wiki/src/lib/account-handler.ts b/apps/waterfall-wiki/src/lib/account-handler.ts index 4a7dbbb..1c9c8b9 100644 --- a/apps/waterfall-wiki/src/lib/account-handler.ts +++ b/apps/waterfall-wiki/src/lib/account-handler.ts @@ -14,10 +14,11 @@ export async function POST(request: Request,context: Context) { const {action} = await context.params; if (!['register','resend','verify','login','logout'].includes(action)) return json({error:'不存在'},404); try { + // Revocation remains available even when login or mail limits are exhausted. + if (action === 'logout') { await logoutAccount(request); const r=json({ok:true});r.headers.set('Set-Cookie',accountCookie('',true));return r; } // Use a global cap by default: forwarding headers are untrusted unless the deployment explicitly enables a trusted ingress. const ip = process.env.ACCOUNT_TRUST_PROXY === 'true' ? request.headers.get('x-forwarded-for')?.split(',')[0].trim() || 'unknown' : 'global'; if (!await rateLimit('request:'+ip,process.env.ACCOUNT_TRUST_PROXY === 'true' ? 60 : 300)) return json({error:'请求过于频繁,请稍后再试'},429); - if (action === 'logout') { await logoutAccount(request); const r=json({ok:true});r.headers.set('Set-Cookie',accountCookie('',true));return r; } if (Number(request.headers.get('content-length') || 0)>4096) return json({error:'请求过大'},413); const text=await request.text(); if(text.length>4096)return json({error:'请求过大'},413); let body;try{body=JSON.parse(text);}catch{return json({error:'请求格式错误'},400);}