9 ms·
Twitter Direct Message Caching and Firefox
- JBReefer 7y agoMozilla Hacks continues to be the best webdev blog
- faitswulff 7y agoSo basically Twitter wasn't setting its Cache-Control directive correctly? Why is this behavior different from Safari and Chrome? It looks like "no-store" is in this IETF RFC: https://tools.ietf.org/html/rfc7234#section-5.2.2 https://tools.ietf.org/html/rfc7234#section-5.2.2 EDIT - Ah, I see, it's in the original post: > Testing from Twitter showed that the request was not being cached in other browsers. This is because some other browsers disable heuristic caching if an unrelated HTTP header, Content-Disposition, is present. Content-Disposition is a feature that allows sites to identify content for download and to suggest a name for the file to save that content to. > In comparison, Firefox legitimately treats Content-Disposition as unrelated and so does not disable heuristic caching when it is present. It looks like Twitter only tested this in Safari and Chrome and called it a day. Their wording implies that it's Firefox's fault, which is misleading.
- saagarjha 7y ago> This is because some other browsers disable heuristic caching if an unrelated HTTP header, Content-Disposition, is present.
- badrabbit 7y agoI have fuming anger over the whole world deciding Google will set the standard for browsers. I wonder if EFF and similar orgs are doing anything legally, perhaps EU can armtwist again?
- cortesoft 7y agoWhat would the legal issue be, exactly? Twitter is the one deciding to code against chrome’s features, not google.
- badrabbit 7y agoRegulating browser standards so that a commercial org can't publish browsers that don't comply. Much like how cars are regulated to be "road legal".
- detaro 7y agoBoth Chrome and Firefox behave correctly according to the relevant standard.
- scarface74 7y agoSo now we want the government to define what can be defined as a browser? So what is this government agency that has the technical wherewithal to “regulate browsers”? What’s going to happen when someone decides that browsers must have content restrictions? It amazes me how willing some people on HN just willingly give up their freedom to the government.
- jonathankoren 7y ago>So what is this government agency that has the technical wherewithal to “regulate browsers”? NIST for one.
- scarface74 7y agoYou really trust NIST to know the intricacies of creating a browser? Besides, hasn’t the last few years shown you what happens when you have government organizations led by people who aren’t experts but who are appointed for political reasons? Even when you do have competent people in the government like in the CDC, they are still hamstrung by the ideology of the executive branch.
- oefrha 7y agohttps://tools.ietf.org/html/rfc7234#section-4.2.2 https://tools.ietf.org/html/rfc7234#section-4.2.2 Since origin servers do not always provide explicit expiration times, a cache MAY assign a heuristic expiration time when an explicit time is not specified, employing algorithms that use other header field values (such as the Last-Modified time) to estimate a plausible expiration time. This specification does not provide specific algorithms, but does impose worst-case constraints on their results. The standard does not say what heuristics should be used, so Firefox’s heuristics is no more “legitimate” than Chorme/Safari’s heuristics of expiring immediately when Content-Dispostion is present. “Firefox legitimately treats...” is highly misleading, making it sound like Firefox is more standard-compliant, but it’s not; it’s just different.
- detaro 7y agoAnd it's allowed to treat it differently than the other browsers. That's what "legitimately" means. And that needs to be pointed out, because Twitter was very careful to avoid saying it wasn't a Firefox bug.
- SpaceNugget 7y agoI am fairly confident that the article is not trying to imply that Chrome/Safari are NOT standards compliant. The author seems to be trying to heavily emphasize that this is not a Firefox bug, and that Firefox can legitimately do this while being standards compliant. I feel like the author was anticipating a lot of people blaming Firefox for this incident, and is attempting to shut those responses before they get made. I think that trying to write to the responses you expect from your audience unfortunately ends up with these kinds of miscommunications of intention more often than not.
- faitswulff 7y agoTwitter explicitly blamed Firefox for the behavior, so the anticipation is warranted.
- notRobot 7y agoPlease don't use code blocks for quotes. It makes it very hard to read text on mobile, narrow viewports or via screen readers.
- jefftk 7y agoSince this handling of Content-Disposition is also in Safari it likely predates Google's involvement, and might even go all the way back to KHTML. (Disclosure: I work for Google)
- dblohm7 7y agoMozilla dev here, I’ve been told that Gecko’s behaviour matches IE’s and Netscape’s.
- detaro 7y agoGoogle hasn't decided a standard here. It just happened to be the case that their heuristic avoided the problem here, so Twitters bug only caused a potential problem for Firefox.
- Vinnl 7y agoI don't think GP meant that Google decided a standard, but that the world (and in this case, Twitter) decided that whatever Google does is considered the standard. In other words, rather than checking with the standard how to indicate that content should not be cached, they simply checked whether Chrome did not cache it, and since it didn't, decided that whatever they were doing was the way to prevent caching.
- badrabbit 7y agoYes, that is what I meant.
- deleted 7y ago[deleted]
- detaro 7y agoI suspect they didn't test for it at all, noticed later or got a report, and then checked which browsers are affected.
- cortesoft 7y agoThey should have absolutely added a no-store cache directive. It is crazy that they didn’t and instead just checked if browsers cached it or not. To rely on undocumented behavior when there is a specific documented way to do what you want is just bizarre.
- DangitBobby 7y agoI wouldn't even be so sure that they tested caching behavior in any browser.
- dathinab 7y agoSure, but now look at general HTTP API's and see how many set any kind of Cache header. I wouldn't be surprised if _many_ API's used by (Phone)Apps and a (Web)App do not do so and might leak private data into the cache, maybe even secret keys or one-time tokens like recovery codes.
- the_mitsuhiko 7y agoClearly a bug on Twitter's side but the behavior to disable caching when content-disposition is used seems sensible.
- JBReefer 7y agoWhy? It’s not in the spec, how am I, the developer, supposed to know that the browser is being non-compliant?
- detaro 7y agoIt's in the spec that the browser is allowed to pick a duration if you don't tell it one, so you know that you don't know how long it is cached if you do not set a header. https://news.ycombinator.com/item?id=22775479 https://news.ycombinator.com/item?id=22775479
- the_mitsuhiko 7y agoBoth browsers are compliant. However there is generally no reason to cache a resource with content disposition so it seems sensible for Firefox to adopt this behavior.
- gav 7y agoWhy would Twitter send a Content-Disposition header with their API responses? content-disposition: attachment; filename=json.json
- r1ch 7y agoI believe this is for additional XSS protection - if a user clicks a suspicious API link, the worst that happens is the browser downloads a json.json file instead of rendering a potentially malicious payload.
- anamexis 7y agoHow would rendering the file perform a malicious action?
- tambre 7y agoThrough a bug in the renderer that the file exploits.
- chias 7y agoIf the content-type header failed to get sent, or if a browser (lookin' at you, IE) chooses to ignore it in favor of what it thinks it probably should have been, then the result can get rendered as HTML. If you have some json that has angle-brackets in it (which, being JSON, would obviously not be HTML-escaped) and the result is rendered as HTML, this can result in your browser executing attacker-defined javascript in Twitter's origin. Sending it as a "file download" has no effect on what happens when the endpoint is called via AJAX, but in the event that a browser navigates to it directly, ensures that even the dumbest of browsers do not render it as HTML.
- deleted 7y ago[deleted]
- danb232 7y agobecause you can legitimately download your direct message history.
- re 7y agoA small amount of discussion on the previous post from the Twitter Privacy team: https://news.ycombinator.com/item?id=22762467 https://news.ycombinator.com/item?id=22762467
- riquito 7y agoLovely how Twitter's blog post does nothing to explain is not Firefox fault.
- justusthane 7y agoIn fact seems to imply the opposite.
- dmitriid 7y agoTwitter is a very mediocre tech company that thinks it's stellar and brilliant. Their product is consistently subpar, riddled with countless bugs, and they neither acknowledge it or fix it. So yeah, no surprise that they would blame others for their failings.
- ryuukk_ 7y agowho cares? oh right.. 3% user share; nobody
- felipc 7y agoThe thing that boggles my mind is that the only affected users are: (a) - Firefox users && (b) - who downloaded their messaging history on a buried menu option in the account page && (c) - in the last 7 days prior to disclosure && (d) - who did this on a computer where someone else has access The number of affected people is presumably very small, and the only metric that twitter can't know here is (d). How on earth does it make sense to alert every Firefox user with a scary wall of text? Don't they have logs to cross-reference (a), (b) and (c) and e-mail these users? I'd believe that if there's only one API endpoint that would be crucial to log to protect against major leaks, it would be this one to download all your history at once...
- detaro 7y agore (b) Twitter says "took actions like downloading your Twitter data archive or sending or receiving media via Direct Message,", so it isn't just downloading the archive, and to me "actions like" suggests there might be more than the ones named here explicitly. And they might not be able to tell who did it for all these things. I also didn't see any notice, but I don't know if I missed it, my adblocker ate it, or if they actually did only inform users that did one of the at-risk things and I happened to not do so.
- jsjddbbwj 7y agoExpect to see more of these as fewer and fewer people use Firefox and web developers simply don't try their websites on this browser. And as more websites stop working correctly on Firefox, they will lose more market share. Some kind of spiral, you know? I was thinking that a rendering bug (which is what one expects from a browser compatibility bug) is not that bad, but when we are talking privacy and security, now that's a problem.
- ludwigvan 7y agoI think a similar issue exists with Twitter and Safari. (Maybe related to web worker or page caching) Sometimes I need to restart Safari, otherwise Twitter fails to load. When I type twitter.com, the site occasionally hangs in that browser. Just putting this to see if some others are effected.
- SimeVidas 7y agoNo mention of Clear-Site-Data? https://w3c.github.io/webappsec-clear-site-data/#example-signout https://w3c.github.io/webappsec-clear-site-data/#example-sig...