Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added self-hosted GDPR compliant captcha module #109

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

Conversation

fballiano
Copy link
Contributor

@fballiano fballiano commented Feb 17, 2025

This PR adds a new Maho_Captcha module, which implements self-hosted GDPR compliant captcha based on https://altcha.org. Research was done but Altcha seems to be the most active other open source PoW based captcha project.

At the moment the implementation is almost the same as my Turnstile module: https://github.com/fballiano/openmage-cloudflare-turnstile with a lot of observers and a "css selectors" settings that (IMHO) allows for maximum flexibility.

I called it Maho_Captcha cause I think Maho should provide a basic captcha module and, since this one doesn't rely on 3rd party services (like cloudflare/recaptcha) it seems the perfect candidate.

Questions:

  • I used maho_captcha.(xml|csv) naming instead of just captcha.(xml|csv) because I didn't want it to collide with the old Mage_Captcha. Is this a good choice?
  • I used maho/captcha/footer.html as folder structure for templates. I don't like that it differs from maho_captcha but at the same time made more sense to have all modules under the maho/ folder. Is this a good choice?
  • Should we apply this naming (or the final one that we decide) to New feature: blog #103 too? We should have a standard for every new development.
  • Since the module positions the captcha widget "just before the ending" of the form, this position may not be perfectly aligned, is this a dealbreaker? ideas on how to make it better? activating the "floating" catpcha if works perfectly

}

$request = Mage::app()->getRequest();
if ($request->getActionName() == 'prelogin' || !$request->isPost()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this line...

@fballiano fballiano marked this pull request as draft February 22, 2025 10:45
@fballiano
Copy link
Contributor Author

Converted to draft because of altcha-org/altcha#92

@fballiano fballiano marked this pull request as ready for review February 24, 2025 11:16
@fballiano
Copy link
Contributor Author

I found a way to work around the limitation of a single captcha per page so I think this PR is testable

@fballiano
Copy link
Contributor Author

As per https://altcha.org/docs/server-integration/

Replay attacks

To prevent the vulnerability of “replay attacks,” where a client resubmits the same solution multiple times, the server should implement measures that invalidate previously solved challenges.

The server should maintain a registry of solved challenges and reject any submissions that attempt to reuse a challenge that has already been successfully solved.

we have to create a database table to store solved challanges and a cleanup routing after a few days (I'd use 7)

@fballiano
Copy link
Contributor Author

I'd added the challenge-log in the captcha_challenge table, with a cron based cleanup routine

@justinbeaty
Copy link
Contributor

we have to create a database table to store solved challanges and a cleanup routing after a few days (I'd use 7)

One thing I don't get is that the challenge expires in +30 seconds, so why do we have to keep track of them beyond that long? Is the documentation old or written before the expires field was supported?

@fballiano
Copy link
Contributor Author

The thing that is worrying me is that the expire parameter doesn't seem to be baked into the challenge, i'm not sure about that

@justinbeaty
Copy link
Contributor

The thing that is worrying me is that the expire parameter doesn't seem to be baked into the challenge, i'm not sure about that

It seems like it was, I watched the recaptcha widget re-spin on the frontend after around 30 seconds. It just seems to auto update if it knows it's expired.

Also, this commit seems to break the admin login for me. I haven't investigated why yet.
93b55ff using events to solve the single catcha per page limitation

@fballiano
Copy link
Contributor Author

auch, i'll check out backend ASAP, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants