diff --git a/src/routes/contact.js b/src/routes/contact.js index 2d0d7c1..2297117 100644 --- a/src/routes/contact.js +++ b/src/routes/contact.js @@ -75,6 +75,18 @@ router.post('/', contactSubmitRateLimit, asyncHandler(async (req, res) => { return res.status(400).json(ApiResponse(false, null, tooLong('message'))); } + // Link-spam guard: legitimate inquiries virtually never contain more than 3 + // URLs, while bot blasts almost always do. Drop silently with a fake success + // (nothing stored, no emails) so spammers get no signal they were caught. + const linkMatches = message.match(/https?:\/\/[^\s]+/gi); + if (linkMatches && linkMatches.length > 3) { + console.warn(`[Contact] Link spam suspected from IP ${req.ip} (${linkMatches.length} links) — submission dropped`); + return res.status(201).json(ApiResponse(true, { + id: generateId(), + message: 'Thank you for your message! We\'ll get back to you soon.' + })); + } + try { // Create contact_submissions table if not exists await dbRun(`