Last modified: 2014-05-08 10:42:13 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T53064, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 51064 - Full version of "old" image not purged from varnish cache when file deleted
Full version of "old" image not purged from varnish cache when file deleted
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
1.22.0
All All
: High normal (vote)
: 1.22.x release
Assigned To: Bryan Davis
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-09 19:26 UTC by Bawolff (Brian Wolff)
Modified: 2014-05-08 10:42 UTC (History)
10 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---
mah: Backport_to_Stable+


Attachments
Call SquidUpdate::purge() when deleteing (1.34 KB, patch)
2013-08-15 22:58 UTC, Bryan Davis
Details
Call SquidUpdate::purge() when deleteing (2.23 KB, patch)
2013-08-19 18:16 UTC, Bryan Davis
Details

Description Bawolff (Brian Wolff) 2013-07-09 19:26:45 UTC
Filing as a security bug to be paranoid, but I don't really think its actually that much of a security issue. Worst case is someone could get a version of a deleted file, if they planned ahead before it was deleted.

Example: https://upload.wikimedia.org/wikipedia/test/archive/b/b3/20130709191600!Bawolff-test-del.jpg returns the file, despite https://test.wikipedia.org/w/index.php?title=File:Bawolff-test-del.jpg

It appears that we send HTCP purges for old version thumbnails, but not the actual file asset itself.

Steps to reproduce:
*Upload some file
*Overwrite it with something
*In the file description page, click on the old version of the image, thus loading the full resolution version of the old file (and getting it in varnish cache)
*Delete the file
*The old full resolution link still works as its still in varnish cache.

----

I'm working on a patch for this, and I'll post it to the bug when done.
Comment 1 Chris Steipp 2013-07-15 16:14:24 UTC
Hi Brian, I'm assuming you're making progress on this, but let me know if you need help. Thanks!
Comment 2 Andre Klapper 2013-08-13 13:15:55 UTC
bawolff: How are things going? 
Any news, or do you need help from somebody (who)?
Comment 3 Bawolff (Brian Wolff) 2013-08-13 17:40:42 UTC
Bryan is going to try having a go at it, since this is relatively self contained.
Comment 4 Bryan Davis 2013-08-14 21:40:41 UTC
Reproduced on test2 with:
* upload https://test2.wikipedia.org/wiki/File:BDavis-Our-Beach.jpeg
* upload replacement with image flipped upside down
* Open first version: https://upload.wikimedia.org/wikipedia/test2/archive/f/f0/20130814212216%21BDavis-Our-Beach.jpeg
* Delete first version
* Hard reload https://upload.wikimedia.org/wikipedia/test2/archive/f/f0/20130814212216%21BDavis-Our-Beach.jpeg

    Response Headers

    HTTP/1.1 304 Not Modified
    Server: nginx/1.1.19
    Date: Wed, 14 Aug 2013 21:37:56 GMT
    Content-Type: image/jpeg
    Connection: keep-alive
    X-Object-Meta-Sha1base36: q6tjiuuvytupp30yb76eav509pl464c
    Last-Modified: Wed, 14 Aug 2013 21:22:16 GMT
    Etag: f046823df66ca83b706e67c31a6d2420
    X-Timestamp: 1376515336.85862
    x-varnish: 176829175 176335682, 3224550997
    Via: 1.1 varnish, 1.1 varnish
    Accept-Ranges: bytes
    Age: 242
    X-Cache: cp1061 hit (5), cp1062 frontend miss (0)
    access-control-allow-origin: *
Comment 5 Bryan Davis 2013-08-15 22:58:25 UTC
Created attachment 13103 [details]
Call SquidUpdate::purge() when deleteing

I think this patch will send the appropriate squid/varnish purge messages.

I tested it locally by running a sniffer to watch for the HTCP packets being sent. You can get the sniffer I used from https://github.com/bd808/htcpsnoop. I have not tested with an actual squid/varnish cache layer.
Comment 6 Bryan Davis 2013-08-15 22:59:37 UTC
I almost posted a review to gerrit and then I remembered this was marked as "security".
Comment 7 Chris Steipp 2013-08-16 17:13:59 UTC
Aaron, can you look at the patch too, since this is part of filerepo?
Comment 8 Bawolff (Brian Wolff) 2013-08-16 18:45:40 UTC
I've tested and read over this patch. It looks good to me.

Some notes:

*body of the foreach loop should be indented
*There's still a code path with moving files where the old name of the file isn't purged, but that could be a separate issue, since we're not trying to hide the old filename, and long term we want the old filename to give an http redirect anyhow, so really this code path probably doesn't matter.
*The revision delete code path (RevDel_FileList::doPostCommitUpdates) still has this issue. This is a much more important code path then the move file (This includes things like oversight of files), but still could be considered a mildly separate bug. Nonetheless, I would recommend fixing this code path at the same time.
Comment 9 Bryan Davis 2013-08-16 20:36:13 UTC
> *body of the foreach loop should be indented

Easy fix. I think my current listchars setting in vim is making it hard for me to see some of these indent issues. I'll work on that.

> *There's still a code path with moving files where the old name of the file
> isn't purged, but that could be a separate issue, since we're not trying to
> hide the old filename, and long term we want the old filename to give an http
> redirect anyhow, so really this code path probably doesn't matter.

I think that the call to purgeEverything() in move() _should_ purge the squid. File::purgeEverything() calls LocalFile::purgeCache() which in turn calls SquidUpdate::purge(array($this->getURL())).

> *The revision delete code path (RevDel_FileList::doPostCommitUpdates) still
> has this issue. This is a much more important code path then the move file
> (This includes things like oversight of files), but still could be considered
> a mildly separate bug. Nonetheless, I would recommend fixing this code path
> at the same time.

I'm looking at this now. Unfortunately the level of abstraction here and my very limited understanding of the codebase may make this take longer than it could/should. The original patch took me 2 days to create. :)
Comment 10 Bryan Davis 2013-08-19 18:16:33 UTC
Created attachment 13129 [details]
Call SquidUpdate::purge() when deleteing

Updated patch that fixes indent issue and adds a call to SquidUpdate::purge() from RevDel_FileList::doPostCommitUpdates().
Comment 11 Bawolff (Brian Wolff) 2013-08-19 18:26:29 UTC
(In reply to comment #10)
> Created attachment 13129 [details]
> Call SquidUpdate::purge() when deleteing
> 
> Updated patch that fixes indent issue and adds a call to SquidUpdate::purge()
> from RevDel_FileList::doPostCommitUpdates().

This looks good to me
Comment 12 Gerrit Notification Bot 2013-08-19 18:34:14 UTC
Change 79842 had a related patch set uploaded by BryanDavis:
Purge upstream caches when deleting file assets.

https://gerrit.wikimedia.org/r/79842
Comment 13 Gerrit Notification Bot 2013-08-19 18:45:31 UTC
Change 79842 merged by jenkins-bot:
Purge upstream caches when deleting file assets.

https://gerrit.wikimedia.org/r/79842
Comment 14 Gerrit Notification Bot 2013-08-19 18:45:46 UTC
Change 79843 had a related patch set uploaded by BryanDavis:
Purge upstream caches when deleting file assets.

https://gerrit.wikimedia.org/r/79843
Comment 15 Gerrit Notification Bot 2013-08-19 18:53:50 UTC
Change 79844 had a related patch set uploaded by BryanDavis:
Purge upstream caches when deleting file assets.

https://gerrit.wikimedia.org/r/79844
Comment 16 Bawolff (Brian Wolff) 2013-08-19 20:03:14 UTC
The patch for master has been merged, so marking fix. The patches for stable still need to be merged.
Comment 17 Gerrit Notification Bot 2013-08-19 20:22:29 UTC
Change 79915 had a related patch set uploaded by BryanDavis:
Release note update for bug 51064.

https://gerrit.wikimedia.org/r/79915
Comment 18 Gerrit Notification Bot 2013-08-19 20:23:47 UTC
Change 79914 had a related patch set uploaded by BryanDavis:
Release note update for bug 51064.

https://gerrit.wikimedia.org/r/79914
Comment 19 Gerrit Notification Bot 2013-08-19 20:30:40 UTC
Change 79918 had a related patch set uploaded by BryanDavis:
Release note update for bug 51064.

https://gerrit.wikimedia.org/r/79918
Comment 20 Gerrit Notification Bot 2013-08-19 20:37:02 UTC
Change 79914 merged by jenkins-bot:
Release note update for bug 51064.

https://gerrit.wikimedia.org/r/79914
Comment 21 Bawolff (Brian Wolff) 2013-08-20 14:20:14 UTC
Chris: did you want me to merge the backports of Bryan's patch?
Comment 22 Chris Steipp 2013-08-20 17:29:31 UTC
Yes please!
Comment 23 Gerrit Notification Bot 2013-08-20 18:04:35 UTC
Change 79844 merged by jenkins-bot:
Purge upstream caches when deleting file assets.

https://gerrit.wikimedia.org/r/79844
Comment 24 Gerrit Notification Bot 2013-08-20 18:17:41 UTC
Change 79915 merged by jenkins-bot:
Release note update for bug 51064.

https://gerrit.wikimedia.org/r/79915
Comment 25 Gerrit Notification Bot 2013-08-20 18:23:01 UTC
Change 79843 merged by Brian Wolff:
Purge upstream caches when deleting file assets.

https://gerrit.wikimedia.org/r/79843
Comment 26 Gerrit Notification Bot 2013-08-20 18:38:15 UTC
Change 79918 merged by jenkins-bot:
Release note update for bug 51064.

https://gerrit.wikimedia.org/r/79918
Comment 27 Gerrit Notification Bot 2013-08-22 23:16:21 UTC
Change 80515 had a related patch set uploaded by Brian Wolff:
Backport purge upstream caches when deleting file assets.

https://gerrit.wikimedia.org/r/80515
Comment 28 Gerrit Notification Bot 2013-08-22 23:27:59 UTC
Change 80515 merged by jenkins-bot:
Backport purge upstream caches when deleting file assets.

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links