Page MenuHomePhabricator

Add validation to length of oathauth_devices.oad_data
Closed, ResolvedPublic

Description

Similar to T260636: OAuth doesn't validate length of grants fields/T277379: OAuth doesn't validate length of oarc_grants and oarc_oauth2_allowed_grants JSON, and T260633: BotPasswords doesn't validate length of resultant bp_grants JSON before it, we should add validation that the length of oathauth_devices.oad_data doesn't end up larger than the maximum length:

			{
				"name": "oad_data",
				"comment": "Data",
				"type": "blob",
				"options": { "length": 65530, "notnull": false }
			}

Useful for T108255: Enable MariaDB/MySQL's Strict Mode down the line for WMF wikis, but also prevents issues in dev wikis etc.

As it is possible to also set OATHMaxRecoveryCodesCount and OATHRecoveryCodesCount to large values, it is possible for this overflow the length of the DB field.

While this is mostly theoretical, 10 encrypted recovery codes takes up 664 characters.

A recovery code when encrypted takes 59 characters, so (65530-664)/59 would be ~1100 more (encrypted) recovery codes to be somewhere near the limit.

This is without other changes to the schema or similar in the future, which may increase the data size in other ways.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Reedy updated the task description. (Show Details)

Change #1283899 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/OATHAuth@master] OATHUserRepository: Add oad_data length validation

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

Change #1283899 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] OATHUserRepository: Add oad_data length validation

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

Reedy claimed this task.