The module's attack surface is tiny — it attaches one JS file to CiviCRM pages for authenticated users and dispatches a local DOM event. No DB queries, no user input rendering, no file I/O, no routes, no forms, no permissions. Nothing in the Drupal security advisory categories (SQLi, XSS, access bypass, CSRF, RCE) applies directly.

That said, a few things are worth tightening:

1. Missing cache metadata on conditional attachment - should fix
civicrm_autologout_bridge.module:22-48 conditionally attaches a library based on currentUser(), the route name, and the request path, but never adds cache contexts. Under Dynamic Page Cache (which does cache authenticated responses), a CiviCRM page rendered for one user could leak its attachment state to a non-CiviCRM request, or vice versa.

Add:
$attachments['#cache']['contexts'][] = 'user.roles:authenticated';
$attachments['#cache']['contexts'][] = 'route';
// (url.path too, since you fall back to path matching)
$attachments['#cache']['contexts'][] = 'url.path';
This isn't a confidentiality issue (the JS is public), but Drupal's security policy treats cache-context mistakes as correctness/DoS-adjacent, and reviewers on drupal.org will flag it.

2. Path prefix match is too loose - minor
civicrm_autologout_bridge.module:40 uses str_starts_with($path, '/civicrm'), which also matches e.g. /civicrm-something-else. Not exploitable — worst case the library loads where it wasn't meant to — but tighten to:

if ($path === '/civicrm' || str_starts_with($path, '/civicrm/')) {
3. Session-extension semantics (informational, not a bug)
The bridge dispatches preventAutologout on scroll and touchstart. Any script running in the page (including a browser extension or an attacker who has already achieved XSS elsewhere) can trivially keep a session alive by firing synthetic scroll events or the event itself. This is inherent to the upstream autologout module's event-based design, not something this bridge introduces — but if your reason for running autologout is a compliance control (e.g. NHS/financial "must log out after N minutes idle"), be aware that the bridge widens the definition of "activity" to include passive scrolling and touch, which some policies would not consider activity. A policy reviewer might object; a security reviewer shouldn't.

4. Things I checked and found clean
No drupal_set_message, t() with user input, or raw output — no XSS surface.
No Url::fromUserInput, no \Drupal::request()->query reads — no open-redirect or injection surface.
No route or permission declarations — nothing to access-bypass.
JS uses dispatchEvent(new Event(...)) on document.body with a fixed string — no injection.
libraries.yml depends on core/drupal, core/once, autologout/drupal.autologout — all first-party, no third-party CDN or remote asset.
.info.yml dependencies are correctly namespaced.
IIFE wrapper and 'use strict' in the JS — good hygiene.
Summary
Fix the cache contexts (#1) before submission to drupal.org; tighten the path check (#2) while you're there. The rest is clean.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

entropea created an issue. See original summary.

entropea’s picture

Two updates made:-

  • Cache contexts added at the top of the hook (civicrm_autologout_bridge.module:23-26) — set unconditionally (before the anonymous early-return) so the cache metadata is present whether or not the library gets attached. Otherwise a cached "anonymous, no library" variant could be served to an authenticated user on a CiviCRM page.
  • Path check tightened (civicrm_autologout_bridge.module:44) — now matches /civicrm exactly or /civicrm/..., no longer /civicrm-anything.

entropea’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

entropea’s picture

Status: Fixed » Closed (fixed)
entropea’s picture

Fixed in 1.0.3