Issue Feature Closed

#95365Add Submission Timer to EXT:form

Thomas Löffler 09/27/21, 10:01 updated 10/07/26, 19:23

Description

Humans are slow

Add a hidden field to your form that contains the current server time (based on when the form was generated).
Then, upon submission, check the form’s timestamp against the current server time.
If the form was submitted too quickly (say, less than 3 seconds) then a human probably didn’t fill it out.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 4

  1. Benni Mack commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2025-04-11T11:51:44+00:00" > 04/11/25, 11:51 </span>

    that means, we could never ever cache the forms?

  2. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-04-11T13:03:01+00:00" > 04/11/25, 13:03 </span>

    (A middleware could do replacement of a cachable placeholder? The timestamp would need some HMAC like encryption of course. We do this with custom form fieldtypes and solved that in userspace, with good success)

  3. Georg Ringer commented and changed status Needs Feedback Closed <span data-processor="relativetime" data-value="2026-10-07T19:23:41+00:00" > 10/07/26, 19:23 </span>

    Thanks for the idea! A submission timer is a nice, lightweight addition to the existing honeypot.

    The good news: this can be built as a custom extension today, without any change in the core. EXT:form is flexible enough for that:

    • a custom form element (e.g. a hidden field) that holds the timestamp, registered via the form setup YAML
    • a custom validator on that element which rejects submissions that are faster than a configurable threshold
    • the timestamp signed with HashService (HMAC), so it can’t be tampered with
    • if needed, the PSR-14 events of EXT:form (e.g. AfterFormStateInitializedEvent) to hook into the form runtime

    Doing it as an extension also has some real advantages:

    • it is not bound to the core release cycle and can be used right away, also in v13 and v14 installations
    • the threshold, the behaviour and the handling of edge cases can be tuned freely and iterated on quickly
    • it can be tested in real projects first, which gives valuable feedback

    One thing to keep in mind is caching, as Benni already pointed out: the first page of a form is rendered in a cached context, so a timestamp generated there would be the time of the cache entry, not of the page view. Garvin’s approach (a cacheable placeholder that is replaced by a signed timestamp in a middleware) solves that nicely and fits well into an extension.

    Once such an extension exists and has proven itself in practice, we can still evaluate whether it makes sense to move it into the core, then based on real-world experience instead of assumptions.

    Therefore I’m closing this issue for now. If somebody builds such an extension, feel free to share it here!