Despite the defense layers in MediaWiki (via OutputPage::sendCacheControl, and HeaderCallback) we have a a dozen responses where Varnish is protecting us from cache poisoning by disabling caching for an object that claims to be cachable due to it setting cookies.
We wrote this defense layer for Varnish in 2020 (T264378, T256395) after an incident in which session cookies where accidentally cached and served out to someone else, causing impersonation issues.
We have about 256M (2M x 1/128 sampled) requests per day to /w/index.php?action=raw. https://w.wiki/Srzi
We have exactly 11 requests over the same period, that emit this warning. https://logstash.wikimedia.org/goto/f7220207d8cf9b0e209d78571fffbff2
Cacheable object with Set-Cookie found! beresp.status: 200 beresp.was_304: true bereq.http.Host: meta.wikimedia.org bereq.url: /w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Wikiminiatlas.js Cache-Control: public, s-maxage=300, max-age=1209600 Set-Cookie: *** ReqId: 00e52db0-2823-4082-a2c5-2ce167311649 X-Cache-Int: cp6016 miss
I've omitted the cookie for security reasons, but in this case it's actually fine:
Set-Cookie: metawikiUserID=deleted; expires=Thu, 01 Jan 1970 00:00:01 GMT; Max-Age=0; path=/; secure; HttpOnly; SameSite=None
They're all like this. It's not so much the creation of a cookie but the deletion of a cookie.
I have a hunch this may have to do with cross-domain requests not appearing quite valid and so MediaWiki wants to delete it. And then I'm guessing our set-cookie detector is ignoring cases where the cookie is deleted? They look like normal set-cookie headers just with a date in the past and our dummy value of "deleted" so it's not obvious why we'd ignore it.
PS: Note that this task is not about violations in MediaWiki extensions where the aforementioned defense layers in MediaWiki core succesfully catch and correct the cache header before Varnish sees it. For those, see T285210 and T149873.

