SMS send routes are rate-limited
Why it matters
SMS is the most expensive metered communication channel in a typical web stack — Twilio charges $0.0079–$0.02 per outbound message, and there is no free tier for abuse. An SMS route without per-IP rate limiting lets an attacker trigger thousands of messages per minute, reaching four-digit charges before any alert fires. CWE-799 (Improper Control of Interaction Frequency) is the direct mapping, alongside OWASP A05:2021. Beyond direct billing, carriers flag high-volume spammy senders for grey-listing or number suspension, destroying your transactional SMS deliverability for legitimate users. This is a cost bomb that also breaks a security-critical channel (OTP delivery).
Severity rationale
High because SMS costs are metered per message with no platform-level cap, making a missing rate limit an immediately exploitable financial attack vector.
Remediation
Add per-IP rate limiting at the route level before the Twilio client is called. Three sends per hour per IP is generous for legitimate OTP flows and stops abuse cold.
import { Ratelimit } from '@upstash/ratelimit'
import { Redis } from '@upstash/redis'
import twilio from 'twilio'
const limiter = new Ratelimit({
redis: Redis.fromEnv(),
limiter: Ratelimit.fixedWindow(3, '1 h'),
})
const client = twilio(process.env.TWILIO_SID!, process.env.TWILIO_AUTH_TOKEN!)
export async function POST(req: Request) {
const ip = req.headers.get('x-forwarded-for') ?? 'anon'
const { success } = await limiter.limit(`sms:${ip}`)
if (!success) return Response.json({ error: 'Rate limited' }, { status: 429 })
const { to, body } = SMSSchema.parse(await req.json())
await client.messages.create({ to, from: process.env.TWILIO_FROM!, body })
return Response.json({ sent: true })
}
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Hidden Cost Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-770 — Allocation of Resources Without Limits or Throttling
- cwe · CWE-799 — Improper Control of Interaction Frequency
- owasp:2021 · A05
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-slop-cost-bombs·automated