Page MenuHomePhabricator

Pass through information about the client from the CDN to MediaWiki to Logstash
Open, Needs TriagePublic

Description

MediaWiki is logging IP and user agent for security-sensitive events (such as login attempts) in Logstash. This is not that useful today - it's common that an attacker is rotating through many IPs and fake browser UAs, and we can easily sample the attack (because some aspect of it causes a big spike) but we'd want to identify all the requests (because there might be other aspects of it) and with just IP/UA that can be hard.

The CDN keeps track of less obvious / harder to game information about clients via the backend API headers and JA3N/JA4H hashes, and it would be useful to have those in Logstash (assuming there are no privacy concerns). That would require 1) passing the relevant headers through to MediaWiki, 2) adding them to the security log context (T395204).

Sending these headers from the CDN is something we'd probably want to do anyway for the API gateway.

Acceptance criteria

  • x_is_browser_likely_script and x_is_browser_likely_browser are logged via at least WebRequest::getSecurityLogContext(), if not on all logs

Event Timeline

  1. passing the relevant headers through to MediaWiki

Who from SRE could help with this?

  1. passing the relevant headers through to MediaWiki

Who from SRE could help with this?

I am taking the liberty of adding @CDanis and @Vgutierrez for their comments, in case they want to add something here.

Change #1226815 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[operations/mediawiki-config@master] debug: Add some CDN Backend API headers to Logstash

https://gerrit.wikimedia.org/r/1226815

Change #1226815 merged by jenkins-bot:

[operations/mediawiki-config@master] debug: Add some CDN Backend API headers to Logstash

https://gerrit.wikimedia.org/r/1226815

Mentioned in SAL (#wikimedia-operations) [2026-01-14T14:25:43Z] <tgr@deploy2002> Started scap sync-world: Backport for [[gerrit:1226815|debug: Add some CDN Backend API headers to Logstash (T412396)]]

Mentioned in SAL (#wikimedia-operations) [2026-01-14T14:28:13Z] <tgr@deploy2002> tgr: Backport for [[gerrit:1226815|debug: Add some CDN Backend API headers to Logstash (T412396)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

the headers described on https://wikitech.wikimedia.org/wiki/CDN/Backend_api and x-ja3n/x-ja4h should be hitting MediaWiki already

Mentioned in SAL (#wikimedia-operations) [2026-01-14T14:36:05Z] <tgr@deploy2002> Finished scap sync-world: Backport for [[gerrit:1226815|debug: Add some CDN Backend API headers to Logstash (T412396)]] (duration: 10m 21s)

We should also update some of the dashboards (at least the login one) with some of this data.

the headers described on https://wikitech.wikimedia.org/wiki/CDN/Backend_api and x-ja3n/x-ja4h should be hitting MediaWiki already

Yeah, thanks, I misunderstood some past discussion. Most of the data is in Logstash now (X-Provenance still TBD as it has more structure).

Change #1226903 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[operations/mediawiki-config@master] debug: Add X-Provenance header to Logstash

https://gerrit.wikimedia.org/r/1226903

Change #1226903 merged by jenkins-bot:

[operations/mediawiki-config@master] debug: Add X-Provenance header to Logstash

https://gerrit.wikimedia.org/r/1226903

Mentioned in SAL (#wikimedia-operations) [2026-01-19T21:14:22Z] <tgr@deploy2002> Started scap sync-world: Backport for [[gerrit:1227493|enwikiquote: Add autopatroller protection option (T414711)]], [[gerrit:1226903|debug: Add X-Provenance header to Logstash (T412396)]], [[gerrit:1226366|Urwikiquote: restore flipped icon (T413592)]]

Mentioned in SAL (#wikimedia-operations) [2026-01-19T21:16:22Z] <tgr@deploy2002> seawolf35gerrit, pppery, tgr: Backport for [[gerrit:1227493|enwikiquote: Add autopatroller protection option (T414711)]], [[gerrit:1226903|debug: Add X-Provenance header to Logstash (T412396)]], [[gerrit:1226366|Urwikiquote: restore flipped icon (T413592)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-01-19T21:24:20Z] <tgr@deploy2002> Finished scap sync-world: Backport for [[gerrit:1227493|enwikiquote: Add autopatroller protection option (T414711)]], [[gerrit:1226903|debug: Add X-Provenance header to Logstash (T412396)]], [[gerrit:1226366|Urwikiquote: restore flipped icon (T413592)]] (duration: 09m 58s)

Code-wise this is done. Should probably update some dashboards.