Antibot blocks multistep webform submission if user fails to move mouse pointer, and all submissions from some assistive technologies

Created on 6 December 2023, 12 months ago
Updated 24 May 2024, 6 months ago

Problem/Motivation

I have a multistep webform with Antibot enabled. It is possible for a user to submit a webform step without moving the mouse. The webform step may have an optional form element, so the user can proceed to the next step without interacting with the form except to click the Next submit button (and it just so happens their mouse pointer is already positioned over the Next submit button). When this occurs, Antibot blocks the submission and an error message is displayed.

Steps to reproduce

  1. Enable Antibot on a webform (created using the Webform module)
  2. Add two pages (steps) to the webform with a single optional text field in each step
  3. In step 1, click the Next submit button to proceed to the next step
  4. In step 2, click the Previous submit button to return to step 1
  5. Without mouse movement click the Next submit button to proceed to again to step 2
  6. The submission is blocked and an error message is displayed advising the user (incorrectly) to enable Javascript on their browser

Proposed resolution

  • Modify antibot.js to listen for pointerdown (equivalent to mousedown and touchstart) events
  • Use the Event.isTrusted property to determine if the event was triggered by the user (and not triggered by script)
πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Glugmeister

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Glugmeister
  • πŸ‡¬πŸ‡§United Kingdom Glugmeister
  • πŸ‡¬πŸ‡§United Kingdom Glugmeister

    I noticed a comment typo in the first patch uploaded. Here's another one.

    I also didn't explain all the changes I have made in this patch.

    The original JS had event listeners to detect humans for mousemove, touchmove and keydown (with a further check that key pressed was tab or enter). The patch changes mousemove to pointermove and adds an additional listener for pointerdown so that if a user clicks submit without mouse movement, the mouse click is detected and antibot protection on the form is unlocked and submission proceeds.

    Pointermove and pointerdown events cover both mouse and touch input events. So there is no need for a separate touchmove event listener and it is removed.

    In relation to the keydown event, I have removed the check for tab or enter keys because it is possible for keyboard users to use space to activate a button. I then thought why not allow any key press to detect a human?

    I have added an additional check for all event listeners to check the Event.isTrusted property is set to true. The browser sets this when an event is triggered by a user as opposed to being triggered programmatically by Javascript. In theory, I was thinking this would be a good extra check to prevent form submissions by more sophisticated bots using a headless browser (with Javascript enabled) to simulate mouse, touch or keyboard events. I have not tested this theory though ...

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States itmaybejj

    I found additional problems that block disabled users, stemming from the same cause.

    1. Screen readers are not reliably detected. Screen reader users can navigate without using the Tab key, and several navigation methods throw no JS events at all. So only meta keys may be received, or it's possible NOTHING will be received before other than a click on the "next page" button.
    2. Voice control (dictation) users are not detected at all. The first event their browser fires is "click" on the submit button.

    I pulled your patch into an issue fork and added some more:

    1. Simple click detection to permit users relying on assistive technologies to submit the form. It's the only event that some browsers are going to fire I'm afraid.
    2. Config settings to make the error messages customizable, so that real human users who are blocked for any reason can be given a fallback contact method, such as email or phone.
  • πŸ‡ΊπŸ‡ΈUnited States itmaybejj
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 6 months ago
    2 pass, 2 fail
  • πŸ‡ΊπŸ‡ΈUnited States itmaybejj
  • Status changed to Needs review 6 months ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 6 months ago
    Patch Failed to Apply
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 6 months ago
    Patch Failed to Apply
  • πŸ‡ΊπŸ‡ΈUnited States itmaybejj
Production build 0.71.5 2024