Page MenuHomePhabricator

Revision deleting a file does not update fr_deleted
Closed, ResolvedPublicSecurity

Description

RevDelFileItem is missing the corresponding write new code. This results in T423065.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Zabe added a subscriber: gerritbot.

We can probably just push this through Gerrit now that prod is not affected by this anymore.

Virtual +2, For future and after clean up of the old code, we can rely on fr_id instead of fr_name but that's not a blocker.

We can probably just push this through Gerrit now that prod is not affected by this anymore.

if the change introducing the bug is not new, we still need to be careful about third parties but also at the same time. No third party is using the new file system I think (READ_NEW should be quite recent I assume)

$wgFileSchemaMigrationStage is not yet documented to actually support read new. The problem is actually that this is even a WRITE_NEW issue. If any third party wiki already set their wiki to WRITE_BOTH, they will have deviations in their filerevision table.

The next thing I just noticed is that the drift in fr_deleted also exposes a lot of rows in the wiki replicas which should be hidden.

Do we need to write a maintenance script to fix fr_deleted fields that got out of sync with oi_deleted?

Might want to edit the ticket to include why this is a security issue. The bug in T423065 resulted in hidden files being clickable, but clicking on them gave an error message, so the hidden files were not actually viewable.

Do we need to write a maintenance script to fix fr_deleted fields that got out of sync with oi_deleted?

Yes.

Might want to edit the ticket to include why this is a security issue. The bug in T423065 resulted in hidden files being clickable, but clicking on them gave an error message, so the hidden files were not actually viewable.

It also did affect the other kinds of revision deletions. For example did I hide your username on the file you linked in your task (https://test.wikipedia.org/w/index.php?title=Special:Log&logid=461602) and it simply did not work.

Generally, _deleted rows are used in all kinds of permission checks and none of them will work here, so a bit of caution seems like a good idea.

Deployed this as a security patch for now (nothing changed, I just fixed the commit message).

This comment was removed by Zabe.

Meh. I thought I tested it, but my local wiki was set to write old, smart. Here a fixed version.

Instead of querying file table, you can use ->getFileIdFromName() instead. Much simpler.

sbassett added subscribers: Catrope, sbassett.

Meh. I thought I tested it, but my local wiki was set to write old, smart. Here a fixed version.

Did this also get deployed and replace the original patch? Or no? Also, can we just push this up to gerrit? Similar to T423654? I think the Security-Team is fine with that, cc: @Catrope.

Meh. I thought I tested it, but my local wiki was set to write old, smart. Here a fixed version.

Did this also get deployed and replace the original patch? Or no?

No I removed the first version and waited for a review of the new one.

Also, can we just push this up to gerrit? Similar to T423654? I think the Security-Team is fine with that, cc: @Catrope.

We can push it through Gerrit if folks are fine with it.

Also, can we just push this up to gerrit? Similar to T423654? I think the Security-Team is fine with that, cc: @Catrope.

We can push it through Gerrit if folks are fine with it.

Should be fine, yes.

Change #1276084 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@master] Correctly support new file tables in RevDelFileItem

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

Change #1276084 merged by jenkins-bot:

[mediawiki/core@master] Correctly support new file tables in RevDelFileItem

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

sbassett triaged this task as Medium priority.
sbassett changed Author Affiliation from N/A to Wikimedia Communities.
sbassett removed a project: Patch-For-Review.
sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".
sbassett changed the edit policy from "Custom Policy" to "All Users".
sbassett changed Risk Rating from N/A to Medium.

Change #1277777 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@REL1_45] Correctly support new file tables in RevDelFileItem

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

Change #1277778 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@REL1_44] Correctly support new file tables in RevDelFileItem

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

Change #1277777 merged by jenkins-bot:

[mediawiki/core@REL1_45] Correctly support new file tables in RevDelFileItem

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

Change #1277778 merged by jenkins-bot:

[mediawiki/core@REL1_44] Correctly support new file tables in RevDelFileItem

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