Antibot is effective at defeating basic bot submissions when the submission is made on the form itself. The potential weakness is when form data is POSTed remotely to the form endpoint. In a scenario like that, Antibot does not intervene in any way. A solution would be:

1) Generate a key for each form based on the form ID (ie, md5(form_id + time()) and store it in the form.

2) Add a hidden value element to each protected form with no value.

3) Pass the key to the JS settings.

4) Once a form is unlocked, the hidden value is set to the key.

5) Add a validation handler to verify that the key was provided.

6) Test to ensure that the form can still remain cached.

Doing this will stop any remote posts from passing validation. Yes, if an attacker really really wanted to target your specific site then these controls can be bypassed (but so can the regular Antibot protection; and pretty much all bot prevention).

CommentFileSizeAuthor
#31 Selection_010.png30.32 KBmstef
#17 antibot2.PNG66.88 KBSystem Lord
#2 2952198-2.patch3.88 KBmstef

Comments

mstef created an issue. See original summary.

mstef’s picture

StatusFileSize
new3.88 KB

Quick stab at it. It only uses an md5() of the form Id for the key. It would be better if it used something that changed over time but the challenge is keeping the form cacheable.

This also eliminates the need for the /antibot page controller since without JS, you'll never get there.

Edit: I take that last bit back. You'll still end up on the page because the incorrect action will bypass the form submission all together. This just adds an additional layer.

I also think that the md5 is stronger than the action change because the action is almost always just the current page path: which is predictable.

  • mstef committed 02ca11e on 8.x-1.x
    Issue #2952198: Use a generated key to also prevent remote posting by...
mstef’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mstef’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)

Let's port this to 7.x to add extra security.

System Lord’s picture

I can't find where "FormStateInterface " is added to "function antibot_form_alter" in antibot.module.

Apologies up front. I install patches manually so I can't tell you if the patch install fails or not. I just noticed by reviewing the files that there's no place where "FormStateInterface " is added and there's no existing form_alter function with "FormStateInterface " in the dev (or stable version).

mstef’s picture

I haven't provided a 7.x patch for this yet. I want to get in the patch from #2934488: Do not modify the visual experience of the form for users with JavaScript first, which was your original issue.

  • mstef committed 25f6cca on 7.x-1.x
    Issue #2952198 by mstef: Idea: Use a generated key to also prevent...
mstef’s picture

Status: Patch (to be ported) » Fixed

Committed to 7.x.

mstef’s picture

@systemlord, is the view you reported the bug for in #2934488: Do not modify the visual experience of the form for users with JavaScript using AJAX?

mstef’s picture

Can you also show me the complete HTML of the form? I don't understand how antibot_key could be set but the input not be present.

mstef’s picture

Status: Fixed » Needs work

Forget my questions. I am able to reproduce.

Will need to test if this happens in 8.x as well.

mstef’s picture

Fix coming. The one downside, because of how Views exposed filters work, is that the antibot_key will end up in the URL after you submit. There's really nothing I can do about it. I don't know of any other site using Antibot for Views exposed forms, since there's really no write operations that take place from submitting them (unlike comments, login, registration, etc).

  • mstef committed 5556db3 on 7.x-1.x
    Issue #2952198: Fixed integration with Views.
    
mstef’s picture

Status: Needs work » Fixed

Committed.

System Lord’s picture

StatusFileSize
new66.88 KB

Yep, AJAX is turned on for this block view.

HTML in attached image.

System Lord’s picture

#14, I'll see what it does to the URL and let you know if it will be an issue. The upside, for me, is that I don't really need to apply Antibot to this Views search b/c I don't really think there's much interest for a bot, although I really don't know. Data gets input and the search query satisfies or it doesn't. But, if you can get it to work then great! All the better.

mstef’s picture

Status: Fixed » Active

New fix coming. The initial one allowed for this entire feature to potentially be bypassed.

Fix also needed for 8.x.

  • mstef committed 25e89cd on 7.x-1.x
    Issue #2952198: Fixed integration with Views (again).
    

  • mstef committed 911b1c7 on 8.x-1.x
    Issue #2952198: Fixed integration with Views.
    
mstef’s picture

Both branches are good now.

mstef’s picture

Status: Active » Fixed
System Lord’s picture

Ok, I'll redo test for #20. #15 did fix it, but I understand #19.

For the next fews days I'll be doing full site testing hard! I'll let you know if any issues arise.

Thanks mstef! Great support!

System Lord’s picture

As for #14, I haven't seen anything different with the URLs. So far, all works perfectly.

mstef’s picture

With AJAX, you won't. Without it, you will.

mstef’s picture

For reference, this feature seems to do more than just protect against remotely-posted forms. In D7, at least, the user login block seems to be able to be submitted without JS until this feature was implemented. I'm not sure why that one is able to get through with the incorrect form action.

System Lord’s picture

#27 works. I disabled JS and the login form remained present, but after submitting my UID/PWD it jumped right to /antibot page. A nice thing about this is that the failed attempt didn't make it to my dblog, so there's no way to flood it. I didn't check watchdog, though.

If I may....

Change:

You have reached this page because you submitted a form that required JavaScript to be enabled on your browser. This protection is in place to attempt to prevent automated submissions made on forms. Please return to the page that you came from and enable JavaScript on your browser before attempting to submit the form again.

To:

You have reached this page because you submitted a form that requires JavaScript to be enabled on your browser. This protection is in place to aid the prevention of automated (bot) submissions made on forms. Please return to the page that you came from and enable JavaScript on your browser before attempting to submit the form again.

Bolded is only for you.

#26, understood

mstef’s picture

Avoiding even a dblog entry is the reason to use the form action switch as the primary method of bot diversion. It completely kills the form submission process which is the lightest outcome for your site.

As for the text change, let's keep this ticket only about the issue described here. We can open other issues for other topics. But what I will say, is that there's no way everyone will agree on what the string should be. This string really doesn't matter. The only way a human sees it is if they have JS disabled, they use a tool to reveal a hidden form, and still decide to submit the form any way. It might as well just say "..really?".

Alter hooks or contrib modules can be used to override strings pretty easily.

System Lord’s picture

I haven't tested this, but thinking about #28, is it the same for all forms? I.e., a user (without JS) could fill out a long form only to discover this warning...and lose all the info they entered into the form? That would suck! But, this would be an acceptable trade-off. This isn't an issue for my site b/c my users have to get past login to reach my forms, which would mean they have already passed the JS test. Others might have an issue with this "trade-off."

#29, good points. I just can't help myself :)

mstef’s picture

StatusFileSize
new30.32 KB

If you have JS disabled, you should not see the form, and only see a warning message.

See attached.

If that's not happening for you, then there's a problem.

System Lord’s picture

Wheww! Ok, my bad. I haven't been "disabling" JS. I've been preventing antibot.js from running (Chrome inspector). I just went into Chrome and fully disabled JS then refreshed the page and what is displayed in your image above is what I now see. Hmm I'm going to have to run through my previous testing now. Tomorrow.

System Lord’s picture

I just discovered a bonus of Antibot. My site falls apart without JS. Before Antibot there was nothing displayed informing my users why...no "JavaScript must be enabled." Now there is :) This is due to me having views_exposed_form on every page, which triggers Antibot on ever page.

The warning "You must have JavaScript enabled to use this form" won't make sense to them, but they will understand that JS must be enabled, which is good enough.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.