On mwlog1002, /srv/mw-log/OAuth.log contains oauth_token_secret query parameters. This is unnecessary for debugging and creates a needless risk.
Description
Details
- Risk Rating
- Medium
- Author Affiliation
- Wikimedia Communities
Related Objects
Event Timeline
So the relevant logging action is in src/Backend/MWOAuthDataStore.php. It's using this oauth token format as part of the cache key, so technically nothing to do with query parameters. Since we're just worried about the logging action here, the simplest solution would be removing/redacting the oauth_token_secret value from the $key variable just prior to it getting logged. Testing within shell.php, something like:
$key = preg_replace("/(oauth_token_secret\=\w+:)/", "", $key);
or
$key = preg_replace("/(oauth_token_secret\=\w+:)/", "oauth_token_secret=[REDACTED]:", $key);
should work. Not sure if it's better to show the secret was redacted or have it disappear entirely, for those debugging with OAuth.log.
Proposed patch below. Went with the redacted option to provide a small visual cue about what the cache key should look like.
Deployed to wmf.17: https://sal.toolforge.org/log/CVH9poEB6FQ6iqKillCF
Seems stable so far, I'll continue to monitor.
A quick tail of /srv/mw-log/OAuth.log on mwlog1002 today shows that the patch appears to be working as intended.
Happy to eventually rework in gerrit and add that space as tribute to the style gods.
heads up: I made a minor change to this patch following this backport yesterday: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/OAuth/+/817860
Change 839459 had a related patch set uploaded (by Mmartorana; author: SBassett):
[mediawiki/extensions/OAuth@REL1_39] SECURITY: redact oauth_token_secret within log data
Change 839460 had a related patch set uploaded (by Mmartorana; author: SBassett):
[mediawiki/extensions/OAuth@master] SECURITY: redact oauth_token_secret within log data
Change 839469 had a related patch set uploaded (by Mmartorana; author: SBassett):
[mediawiki/extensions/OAuth@REL1_38] SECURITY: redact oauth_token_secret within log data
Change 839471 had a related patch set uploaded (by Mmartorana; author: SBassett):
[mediawiki/extensions/OAuth@REL1_37] SECURITY: redact oauth_token_secret within log data
Change 839473 had a related patch set uploaded (by Mmartorana; author: SBassett):
[mediawiki/extensions/OAuth@REL1_35] SECURITY: redact oauth_token_secret within log data
Change 839473 merged by jenkins-bot:
[mediawiki/extensions/OAuth@REL1_35] SECURITY: redact oauth_token_secret within log data
Change 839460 merged by SBassett:
[mediawiki/extensions/OAuth@master] SECURITY: redact oauth_token_secret within log data
Change 839471 merged by SBassett:
[mediawiki/extensions/OAuth@REL1_37] SECURITY: redact oauth_token_secret within log data
Change 839459 merged by SBassett:
[mediawiki/extensions/OAuth@REL1_39] SECURITY: redact oauth_token_secret within log data
Change 839469 merged by SBassett:
[mediawiki/extensions/OAuth@REL1_38] SECURITY: redact oauth_token_secret within log data
This commit breaks OAuth on MW 1.35
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/OAuth/+/839473/2/src/Backend/MWOAuthDataStore.php#130
nonceCache is not defined, resulting in Call to a member function add() on null.
It works on 1.35+ as cache was renamed to ´nonceCache`
Change 840668 had a related patch set uploaded (by Zabe; author: Zabe):
[mediawiki/extensions/OAuth@REL1_38] Fix cache var name
Change 840668 merged by Zabe:
[mediawiki/extensions/OAuth@REL1_38] Fix cache var name
Change 840302 had a related patch set uploaded (by Zabe; author: Zabe):
[mediawiki/extensions/OAuth@REL1_37] Fix cache var name
Change 840303 had a related patch set uploaded (by Zabe; author: Zabe):
[mediawiki/extensions/OAuth@REL1_35] Fix cache var name
Change 840303 merged by jenkins-bot:
[mediawiki/extensions/OAuth@REL1_35] Fix cache var name
Change 840302 merged by Zabe:
[mediawiki/extensions/OAuth@REL1_37] Fix cache var name
Yes, unfortunately I used the updated Wikimedia production patch for the supported release branch backports. Apologies for that. And thanks, @Zabe, for the quick fixes.