Add an optional proof of work for joining rooms #1

Closed
asxpi wants to merge 1 commit from asxpi/anotherim-server:feat/muc-pow into master
Member

Registration already sits behind an XEP-0158 SHA-256 hashcash, but
ejabberd 26.09 only offers an image CAPTCHA for captcha_protected rooms:
its captcha_pow (processone/ejabberd#4594) is wired into registration
alone. Spam bots joining public rooms are the next problem, and an image
CAPTCHA needs ImageMagick on the server and a person at the client.

Carry a patched copy of ejabberd_captcha in ejabberd/overrides that
also offers the SHA-256 field in a room's challenge, compiled and tested
in the build and swapped for the release's beam after checking that beam
is 26.09's own. upstream.diff is the same change against the 26.09
source, meant to go upstream so the override can be dropped.

MUC_CAPTCHA=1 makes new rooms captcha_protected (off by default, as the
apps cannot answer a room's challenge yet); make muc-captcha switches
existing rooms. CAPTCHA_IMAGE=1 builds an image with ImageMagick and
offers a picture beside the proof of work, for people on clients that
cannot solve it. Owners, admins, members and captcha_whitelist are never
challenged.

Tested: make test (131), make test-muc-pow (25), make test-login (18).

Part of a proof of concept across anotherim-server, libtacky and anotherim-js (branch feat/muc-pow in each). Each part is tested on its own; not yet run end to end.

🤖 Generated with Claude Code

Registration already sits behind an XEP-0158 SHA-256 hashcash, but ejabberd 26.09 only offers an image CAPTCHA for captcha_protected rooms: its captcha_pow (processone/ejabberd#4594) is wired into registration alone. Spam bots joining public rooms are the next problem, and an image CAPTCHA needs ImageMagick on the server and a person at the client. Carry a patched copy of ejabberd_captcha in ejabberd/overrides that also offers the SHA-256 field in a room's challenge, compiled and tested in the build and swapped for the release's beam after checking that beam is 26.09's own. upstream.diff is the same change against the 26.09 source, meant to go upstream so the override can be dropped. MUC_CAPTCHA=1 makes new rooms captcha_protected (off by default, as the apps cannot answer a room's challenge yet); make muc-captcha switches existing rooms. CAPTCHA_IMAGE=1 builds an image with ImageMagick and offers a picture beside the proof of work, for people on clients that cannot solve it. Owners, admins, members and captcha_whitelist are never challenged. Tested: make test (131), make test-muc-pow (25), make test-login (18). Part of a proof of concept across anotherim-server, libtacky and anotherim-js (branch `feat/muc-pow` in each). Each part is tested on its own; not yet run end to end. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Registration already sits behind an XEP-0158 SHA-256 hashcash, but
ejabberd 26.09 only offers an image CAPTCHA for captcha_protected rooms:
its captcha_pow (processone/ejabberd#4594) is wired into registration
alone. Spam bots joining public rooms are the next problem, and an image
CAPTCHA needs ImageMagick on the server and a person at the client.

Carry a patched copy of ejabberd_captcha in ejabberd/overrides that
also offers the SHA-256 field in a room's challenge, compiled and tested
in the build and swapped for the release's beam after checking that beam
is 26.09's own. upstream.diff is the same change against the 26.09
source, meant to go upstream so the override can be dropped.

MUC_CAPTCHA=1 makes new rooms captcha_protected (off by default, as the
apps cannot answer a room's challenge yet); make muc-captcha switches
existing rooms. CAPTCHA_IMAGE=1 builds an image with ImageMagick and
offers a picture beside the proof of work, for people on clients that
cannot solve it. Owners, admins, members and captcha_whitelist are never
challenged.

Tested: make test (131), make test-muc-pow (25), make test-login (18).

Assisted-by: Claude:opus-5-5
Owner

Thanks, this is close to what we did in parallel on feat/room-pow. That branch is a patch on the 26.09 source plus a .deb for servers on ProcessOne's packages, which is what production runs; this PR's override only reaches our container image.

One real issue here: with captcha_pow set and no captcha_cmd, is_feature_available/0 becomes true, and mod_register_web relies on it. Web registration would then refuse everyone (captcha_not_valid) and try to draw an image it cannot make, so those two calls need to check captcha_cmd instead. Also, the PoW-only body talks about joining a room, but create_captcha/6 serves mod_block_strangers too.

We'll go with feat/room-pow for the patch itself, so I'm closing this one. MUC_CAPTCHA and make muc-captcha could come as a small follow-up PR on top of it if we decide we want them.

Thanks, this is close to what we did in parallel on feat/room-pow. That branch is a patch on the 26.09 source plus a .deb for servers on ProcessOne's packages, which is what production runs; this PR's override only reaches our container image. One real issue here: with captcha_pow set and no captcha_cmd, is_feature_available/0 becomes true, and mod_register_web relies on it. Web registration would then refuse everyone (captcha_not_valid) and try to draw an image it cannot make, so those two calls need to check captcha_cmd instead. Also, the PoW-only body talks about joining a room, but create_captcha/6 serves mod_block_strangers too. We'll go with feat/room-pow for the patch itself, so I'm closing this one. MUC_CAPTCHA and `make muc-captcha` could come as a small follow-up PR on top of it if we decide we want them.
ann closed this pull request 2026-11-01 22:19:54 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
another-im/anotherim-server!1
No description provided.