UNSEEN — GUARD | Stop Crawlers Replaying XenForo's Tokened Style and Language Links

UNSEEN — GUARD | Stop Crawlers Replaying XenForo's Tokened Style and Language Links 1.0.1

No permission to download
Compatible XF 2.x versions
  1. 2.3
Additional requirements
PHP 8.1 or newer. No other add-ons required; Cloudflare is optional.
License
Free, no licence key.
Visible branding
No
Stops crawlers that replay XenForo's tokened light / dark, style and language links without cookies​

1-overview.webp


First: if you can upgrade to XenForo 2.3.14, do that. XenForo 2.3.14 and later print these links without a security token, so a crawler no longer finds new addresses on every page: upgrading closes the trap itself. On those versions Unseen Guard stops the old addresses crawlers already hold, their retries with the route dropped, and tokened links that custom templates or other add-ons may still print. Without the cookie, XenForo's own links that choose light / dark or a language are stopped too, token or not. On XenForo 2.3.0 to 2.3.13 it also stops the new tokened addresses of the light / dark, style and language links.

XenForo 2.3.0 to 2.3.13 print links whose security token changes every second: the light / dark links in the footer of every page, and the links on the style and language chooser pages. A crawler that keeps no cookies sees brand-new addresses on every visit, follows them all, and XenForo answers each one with a full page and lists the crawler as an online guest. On erkanshi.com this meant more than a thousand online guests at a time, and the same crawler kept coming back with the links' route removed, which XenForo answers with the whole forum home.

On XenForo 2.3.14 the core no longer prints new tokened addresses. It answers a link with an old token with a redirect and no page, and a crawler that follows redirects then loads the page it is sent to in full; it answers a light / dark or language link without a token with a confirmation page. Crawlers keep the old addresses for weeks, and a style or add-on that still prints tokened chooser links keeps the trap open.

Unseen Guard answers those replayed links before XenForo starts the session or draws anything: status 400 with a short page (XenForo's own sentence for a request without cookies, in English, 275 bytes, no links) and no online guest. It only acts on requests that carry no CSRF cookie, which XenForo gives with the first page of a visit to every browser that accepts cookies: members and visitors who have that cookie are not stopped, search engines reading your threads and forums are not affected, and your visitors keep the light / dark switch. If your forum runs behind Cloudflare, the add-on also writes a rule for it, so you can stop these requests there before they reach your server; whatever the rule lets through still meets Unseen Guard on your server.

Is your forum affected?​


On XenForo 2.3.0 to 2.3.13, the light / dark and language requests show in the Current visitors list as "Viewing unknown page", and staff with XenForo's "Bypass user privacy" permission (the board's first administrator has it) also see a warning sign on them: XenForo answered them with an error page. Style chooser requests are redirects, which the list does not show on their own. The retried ones show as visitors of your forum home. On 2.3.14 and later the old links are redirects too, so the list shows only the pages they lead to, and XenForo's own light / dark and language links without a token show as "Viewing unknown page" without the warning sign, which are ordinary visits and not the trap: look in your web server's access log for misc/style-variation, misc/style and misc/language addresses with a t= parameter, and for forum home addresses (with or without index.php) that carry a t=1… token or _xfRedirect. Once Unseen Guard is installed, its Overview page counts what it stopped per kind and per day and keeps a few examples.

What it does​


  • Four kinds of links. Stops four kinds of replayed links, each with its own switch: the footer's light / dark links (misc/style-variation), style chooser links (misc/style), language chooser links (misc/language), and the same links retried on the forum home with the route removed (recognised by their _xfRedirect or their XenForo token), which XenForo would answer with the whole forum home
  • Only without the cookie. Acts only on requests without the CSRF cookie (xf_csrf, or your own cookie prefix): members and visitors are not stopped once XenForo has given them the cookie, which it does with the first page of each visit
  • Before the page. Answers before the session, the visitor and the page: no database query of its own, and a stopped request is never listed as an online guest
  • What keeps working. Tracking and campaign links (utm_source, fbclid, an A/B variation= on the forum home and the like), XenForo's own light / dark, style and language switching, and style links without a token keep working
  • A Cloudflare rule for your forum. Cloudflare tab: a WAF custom rule written for your forum's host name, path, cookie name and the kinds you have switched on, with a copy button and step-by-step instructions. It uses only simple comparisons, no regular expressions, so it needs no paid Cloudflare plan (custom rules are available on the free plan, five per domain)
  • Early mode. Optional early mode: one line at the end of src/config.php answers these requests before XenForo connects to the database. The line skips the add-on's file when it is missing or damaged; uninstalling the add-on switches it off (and leaves a note in XenForo's server error log if its settings file cannot be changed); the add-on's page tells you when the line sits in the wrong place or did not start
  • Counters. Counts stopped requests per kind and per day in small files, never in the database, and shows today, the last 7 days and 30-day totals; counters are kept for 30 days
  • Examples, never IP addresses. Keeps a few examples of what was stopped (the address and the browser's user-agent string, never the IP address) for 7 days; the page shows today's and yesterday's
  • A check from a terminal. A ready-made curl command to check the guard from a terminal on macOS or Linux, or from Windows PowerShell (type curl.exe there)
  • Root or folder. Finds your forum's folder, cookie prefix and friendly URLs by itself, whether the forum is at the root of the domain or in a folder
  • Plain files only. In its own folder it writes its data only into plain files (a symbolic or hard link put there is never written through: it is skipped, or replaced by a plain file), and the folder gets XenForo's own permissions
  • A light footprint. No template modifications, no class extensions, no database tables, and no requests to any outside server
  • Twelve languages. English, with eleven language packs included to import as you need them: Turkish, German, Spanish, French, Italian, Dutch, Brazilian Portuguese, Swedish, Japanese, Korean and Simplified Chinese

Screenshots​


Cloudflare — The rule written for your forum's host name, path, cookie name and the kinds you have switched on, with a copy button and the steps to add it.
2-cloudflare.webp


Early mode — The one line for src/config.php, and whether it is in place and working.
3-early-mode.webp


Settings — One switch for each kind of link, under Setup → Options → Unseen Guard.
4-settings.webp


Limits worth knowing​


  • Works with any style: it reads the request, not the page. Not covered: a style that switches through an address of its own, chooser addresses renamed by a route filter, entry scripts other than index.php, crawlers that keep cookies, XenForo's cookie notice in its Advanced mode (Setup → Options → Basic options → Cookie consent; up to 2.3.13 its accept and reject links carry a token as well), and early mode where src/config.php is a link into another folder (as deploy tools share it between releases: the line cannot find the add-on there, so use the add-on without it)
  • It does not remove any link from your pages: up to 2.3.13 XenForo prints the tokened ones, and on 2.3.14 and later only a style or add-on that still prints them does. A search engine that follows a light / dark or language link without the cookie gets 400 from Unseen Guard, with or without a token (up to 2.3.13 XenForo answered these with 400 as well; 2.3.14 redirects one with an old token and shows a confirmation page for one without). Style links are stopped only with a token, which XenForo itself redirects. Search Console may keep listing such addresses
  • Who meets the short page besides crawlers: a visitor whose browser blocks cookies, on the light / dark and language links and on tokened style links; a visit that starts on one of them, such as a tokened style link shared elsewhere, or on a forum home address that carries a XenForo token or _xfRedirect; and guests whose pages come from a cache that drops XenForo's cookies (a CDN that caches whole pages), on the same links. If another add-on sends new visitors to the forum home with _xfRedirect, switch the home kind off
  • Early mode and the counters keep small files in an unseen_guard folder inside XenForo's internal data folder (internal_data, or the path set as internalDataPath in src/config.php; never XenForo's abstracted storage, even when other internal data is stored elsewhere), and the web server must be able to write there. On a board served by several web servers that do not share that folder, each keeps its own counters and early mode settings: switching a kind off, or uninstalling, reaches early mode only on the server that handled it, so remove the line from the others first
  • The Cloudflare rule needs the forum to be proxied through Cloudflare (the orange cloud in DNS) and a free custom rule slot on the domain. It covers the kinds that were switched on when you copied it; on the forum home it recognises a token by its shape (a t that starts with 1 and an encoded comma), so a rare home link of that shape is blocked there as well

Requirements​


  • A XenForo licence for the board you install it on
  • XenForo 2.3, PHP 8.1 or newer

Free​


Unseen Guard is free: no licence key, no licence check, and no request to any outside server.

Installing​


Upload the contents of the upload folder to your forum root and install Unseen Guard from Admin control panel → Add-ons. It works from the start: all four kinds are switched on, and each one can be switched off under Setup → Options → Unseen Guard. The language packs are in src/addons/Erkan/UnseenGuard/translations/; import the ones you need from Appearance → Languages → Import. Uninstalling deletes the add-on's folder internal_data/unseen_guard. If you added the early mode line to src/config.php, uninstalling switches it off (and leaves a note in XenForo's server error log if it cannot); remove the line as well.

Support​


Ask in this resource's discussion thread and mention your XenForo and Unseen Guard versions and whether your forum runs behind Cloudflare.
Author
erkanshi
Downloads
1
Views
14
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from erkanshi

Back
Top Bottom