Add link-spam guard: silently drop contact messages containing 4+ URLs
This commit is contained in:
parent
0dc2d24716
commit
648446271f
@ -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(`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user