<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/protect-your-web-forms-against-spam-bots-ztqgwrywc" -->

---
title: Protect Your Web Forms Against Spam Bots | daily.dev
description: A hash-based proof-of-work check cut blog comment spam from 30-40 messages per day to about 2-3 per month, with no CAPTCHA or third-party service. The server...
canonical: https://daily.dev/posts/protect-your-web-forms-against-spam-bots-ztqgwrywc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Protect Your Web Forms Against Spam Bots | daily.dev
og:description: A hash-based proof-of-work check cut blog comment spam from 30-40 messages per day to about 2-3 per month, with no CAPTCHA or third-party service. The server...
og:url: https://daily.dev/posts/protect-your-web-forms-against-spam-bots-ztqgwrywc
og:image: https://api.daily.dev/og/posts/ZtQGwryWC.png
og:image:alt: Protect Your Web Forms Against Spam Bots
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Protect Your Web Forms Against Spam Bots

**[Miguel Grinberg](https://daily.dev/sources/miguelgrinberg)** · 25 min read · 0 upvotes · 0 comments

## Summary

A hash-based proof-of-work check cut blog comment spam from 30-40 messages per day to about 2-3 per month, with no CAPTCHA or third-party service. The server sends a random challenge, and the browser finds a suffix whose SHA-512 hash starts with a set number of zeros. A level 4 challenge took about 2 seconds to solve on the author's machine, while the server verifies it with one hash. The challenge sits in the signed Flask session with a short expiry to block replay attacks. It is wrapped as a custom Flask-WTF field.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.miguelgrinberg.com/post/protect-your-web-forms-against-spam-bots>

## Questions this post answers

### How can I stop spam bots on a web form without using a CAPTCHA?

Use a proof-of-work challenge. The server sends a random string, and the browser's JavaScript finds a suffix whose SHA-512 hash starts with a set number of zeros before submitting. Solving is costly but verifying takes one hash. This cut one blog's comment spam from 30-40 messages per day to about 2-3 per month, with no third-party service.

_Developers hardening forms against bots follow anti-spam techniques like this on daily.dev._

### How do I prevent replay attacks on a proof-of-work form challenge in Flask?

Store the challenge and an expiration timestamp in the Flask session, whose cookie is cryptographically signed so clients cannot alter it. Reject solutions after a short validity window, such as 15 seconds. Optionally, also record successfully used challenges in a database so a repeated challenge is refused.

_Anyone securing session-based flows keeps up with replay-attack defenses on daily.dev._

## Similar posts on daily.dev

- [Your sign-up form is a weapon](https://daily.dev/posts/your-sign-up-form-is-a-weapon-cwnsa8fnc) · Hacker News · 0 upvotes · 0 comments
- [How to Block Bots from Visiting Your Website](https://daily.dev/posts/how-to-block-bots-from-visiting-your-website-p1xwarvet) · Pragmatic Pineapple · 0 upvotes · 0 comments
- [Is CAPTCHA Still Effective in 2026 and What to Use Instead](https://daily.dev/posts/is-captcha-still-effective-in-2026-and-what-to-use-instead-2m6gqwky7) · Arcjet · 0 upvotes · 0 comments
- [Build scanner-safe double opt-in](https://daily.dev/posts/build-scanner-safe-double-opt-in-qgdlkj42f) · Flavio Copes · 0 upvotes · 0 comments
- [Has Your Password Leaked? Check It, Then Replace It](https://daily.dev/posts/has-your-password-leaked-check-it-then-replace-it-pmctpjv4w) · Security Boulevard · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#flask](https://daily.dev/tags/flask), [#proof-of-work](https://daily.dev/tags/proof-of-work)

[View this post on daily.dev](https://daily.dev/posts/protect-your-web-forms-against-spam-bots-ztqgwrywc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Protect Your Web Forms Against Spam Bots","url":"https://daily.dev/posts/protect-your-web-forms-against-spam-bots-ztqgwrywc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/protect-your-web-forms-against-spam-bots-ztqgwrywc"},"datePublished":"2026-11-27T17:53:41.895Z","dateModified":"2026-11-27T17:54:02.802Z","description":"A hash-based proof-of-work check cut blog comment spam from 30-40 messages per day to about 2-3 per month, with no CAPTCHA or third-party service. The server...","image":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","thumbnailUrl":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","isAccessibleForFree":true,"articleSection":"Miguel Grinberg","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Miguel Grinberg","logo":"https://media.daily.dev/image/upload/s--1lzsuTn2--/f_auto,q_auto/v1777800749/logos/miguelgrinberg?_a=BAMAMiWQ0","url":"https://daily.dev/sources/miguelgrinberg"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/protect-your-web-forms-against-spam-bots-ztqgwrywc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,flask,proof-of-work","timeRequired":"PT25M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Miguel Grinberg","item":"https://daily.dev/sources/miguelgrinberg"},{"@type":"ListItem","position":3,"name":"Protect Your Web Forms Against Spam Bots"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/protect-your-web-forms-against-spam-bots-ztqgwrywc#faq","mainEntity":[{"@type":"Question","name":"How can I stop spam bots on a web form without using a CAPTCHA?","acceptedAnswer":{"@type":"Answer","text":"Use a proof-of-work challenge. The server sends a random string, and the browser's JavaScript finds a suffix whose SHA-512 hash starts with a set number of zeros before submitting. Solving is costly but verifying takes one hash. This cut one blog's comment spam from 30-40 messages per day to about 2-3 per month, with no third-party service. Developers hardening forms against bots follow anti-spam techniques like this on daily.dev."}},{"@type":"Question","name":"How do I prevent replay attacks on a proof-of-work form challenge in Flask?","acceptedAnswer":{"@type":"Answer","text":"Store the challenge and an expiration timestamp in the Flask session, whose cookie is cryptographically signed so clients cannot alter it. Reject solutions after a short validity window, such as 15 seconds. Optionally, also record successfully used challenges in a database so a repeated challenge is refused. Anyone securing session-based flows keeps up with replay-attack defenses on daily.dev."}}]}
```

