cs-haproxy-bouncer icon indicating copy to clipboard operation
cs-haproxy-bouncer copied to clipboard

Recaptcha Remediation is Broken

Open ciphermenial opened this issue 2 years ago • 9 comments

I recently reconfigured everything and tested a recaptcha decision. It never seems to detect that the recaptcha has been remediated.

ciphermenial avatar Sep 09 '23 13:09 ciphermenial

Same here, just stuck in a captcha loop.

mateuszdrab avatar Sep 28 '23 08:09 mateuszdrab

Hey 👋🏻

We have a pending patch that "kind of" fixes the issue https://github.com/crowdsecurity/cs-haproxy-bouncer/commit/6a61a8b6d4f31ef07b044e92ad4ceeb5f46fe591

HAProxy tries to go as fast as possible and sometime it does not wait for the whole post body before our lua code fires, the merge above basically waits for some MS. However, it might not scale well.... there is a option to provide haproxy to wait for full body, however, this can cause some DOS as if they upload a 1gb file then haproxy will load the file into memory

So it would be this https://docs.haproxy.org/2.8/configuration.html#4.2-http-request%20wait-for-body%20time and a condition to say less than your maximum upload

LaurenceJJones avatar Sep 29 '23 09:09 LaurenceJJones

Hey @LaurenceJJones

I'm running 0.0.7 so the fix is there but the issue is still ongoing.

Did I understand right that this is in conjunction with using http-request wait-for-body time 1s at-least 1k if METH_POST?

I'm presuming at-least does not need to be a large value considering that the captcha response POST body should not be a lot data. It just needs to be the minimum to make sure the body is parsed correctly?

mateuszdrab avatar Sep 29 '23 09:09 mateuszdrab

Did I understand right that this is in conjunction with using http-request wait-for-body time 1s at-least 1k if METH_POST?

Hmm it should be used instead of the code, but we have very limited haproxy experience. So if you test it and finds it works any feedback you can provide will help us improve the example we provide.

LaurenceJJones avatar Oct 03 '23 08:10 LaurenceJJones

I think I figured out why this isn't working for me because I noticed a few times I did a few captchas in a row and suddenly it started working.

I'm running a few instances of haproxy and... Well you probably can guess the rest. I probably did all the captchas to satisfy all haproxy instances 🤣

So, I need to research if there's a way to share the content of the stick table between multiple instances.

mateuszdrab avatar Oct 04 '23 16:10 mateuszdrab

I think I figured out why this isn't working for me because I noticed a few times I did a few captchas in a row and suddenly it started working.

I'm running a few instances of haproxy and... Well you probably can guess the rest. I probably did all the captchas to satisfy all haproxy instances 🤣

So, I need to research if there's a way to share the content of the stick table between multiple instances.

Thank you for the update, makes sense now I think about it as once you solve for one node it wont be propagate to others as the decision is only held for that node. I be interested in knowing if it can be if not if a solution like redis or memcached would be needed to have a shared pool.

LaurenceJJones avatar Oct 05 '23 08:10 LaurenceJJones

.

It can be done through stick table peering https://www.haproxy.com/blog/introduction-to-haproxy-stick-tables#peers

However, in Kubernetes, there's little to none support for that unfortunately. https://github.com/haproxytech/kubernetes-ingress/issues/32

mateuszdrab avatar Oct 05 '23 10:10 mateuszdrab

@mateuszdrab I have recently configured Crowdsec and am still running into the same issues with the captcha loop. I am only running 1 haproxy instance, and was not able to fix it in the way you did. However, since your captcha is working, would you be able to provide your config file / any changes you made from the standard installation? Thanks!

SahilPatel650 avatar Feb 24 '24 21:02 SahilPatel650

i have the same issue with captcha loop

dyipon avatar Aug 16 '24 20:08 dyipon

If you are running one instance of HAProxy it most likely your defined body read and body timeout reads are being hit and the lua is not able to get the full post body hence the captcha cannot be verified hence the loop. As suggested above you must play around with HAProxy settings to find a balance between this as by default haproxy tries not to cause latency between itself and the end server.

Classing as "not planned" till users can provide exact details that show a bug or error in code that doesnt rely on client / server networking

LaurenceJJones avatar Aug 28 '24 13:08 LaurenceJJones

I haven't made any changes and it appears to be working again.

ciphermenial avatar Sep 04 '24 01:09 ciphermenial