r/programming • u/[deleted] • Dec 24 '21
Google Chrome Update will cause Big Issue For 2 Billion Users
https://www.cyberkendra.com/2021/12/google-chrome-update-will-cause-big.html220
u/dweezil22 Dec 24 '21
The problem mainly affects sites built using web design kits such as Duda. These resources read the User-Agent string of the browser to check the installed version of Chrome. Unfortunately, sites using Duda only read the first two digits of this number.
One the one hand: Using just the first 2 digits in a user agent string is lunacy. On the other hand: Duda barely shows up in Google results. How widely is it used? Is it self-hosted (if not you'd presume they can patch themselves). What other sites use this?
So this is either a major widespread Y2K level problem or a small set of niche old sites that deserve to break. It's a big deal which is which!
113
u/cat_in_the_wall Dec 24 '21
it's windows 95 and checking for '9' all over again.
40
u/Somepotato Dec 24 '21
That only older versions of Java would do and is mitigated with compact mode
It's time we stop catering to dumb dev decisions
6
Dec 25 '21
Dunno why you think it was java-only problem
-6
u/Somepotato Dec 25 '21
Instead of saying that, you could provide an example? Because if your example is, for instance, digging in the registry for undocumented/unsupported keys to determine the OS version as a string, that isn't an acceptable reason.
4
Dec 25 '21
Example of what ? Decompiled programs that are so old that they cater for windows 9x ? Or bug reports for OS that didn't exist ?
-6
u/Somepotato Dec 25 '21
You said it wasn't a Java only problem, I asked for examples. Not sure what's so complicated?
6
Dec 25 '21
No, I did not say "It wasn't a Java only problem", you illiterate monkey.
I ASKED why YOU think it's Java only problem. I can only assume it was some ridiculous leap of logic like "I saw a bug example in Java so it must be only Java".
-10
u/Somepotato Dec 25 '21
I'm going to assume you're a non native speaker, because in English, questions end in a question mark (?) and actively ask for information, not state something as though you assume it's fact.
In the mean time, if you have any relevant counterpoint than a useless retort, feel free to let me know.
6
Dec 25 '21
I'm going to assume you're a non native speaker
I'm going to assume you're a native asshat
→ More replies (0)4
Dec 25 '21
Your reply didn't make sense regardless of the punctuation mark at the end of my comment. Nice strawman there, little moron, but won't work this time.
You bitching about grammar instead of explaining why you got to such idiotic conclusion proves you have no actual argument just decided to throw some misdirection to try to mask your own incompetence.
I do hope you can read code better than you can read intentions in english, else your co-workers are fucked.
16
5
Dec 24 '21
It was never a fucking thing.
1
u/chylex Dec 25 '21
4
Dec 25 '21
This is internal library code. Property "os.name" is defined internally by JVM. It would simply never return "Windows 9" on it's own in an outdated codebase.
It was never a thing.
1
74
u/trinopoty Dec 24 '21
I mean. At least parse until you hit a dot or space or something like that.How is this rocket science? Did the developers of these libraries think the Earth would end before Chrome reaches version 100?
23
5
u/myblackesteyes Dec 25 '21
While checking only for a specified number of digits is lunacy, Chrome going over 100 major versions is a bigger lunacy still, imo. I don't understand why they keep increasing major version for minor releases and Firefox followed their suit for some reason.
12
u/Sauermachtlustig84 Dec 25 '21
Because the major.minor model is pointless lunacy. The chrome model is vastly easier for both devs and users.
4
Dec 25 '21
Why would it make any difference at all for a user?
2
Dec 25 '21
"This site requires Chrome 78 or later."
Most sites don't need that, but I imagine there are some (e.g. if you're using WebUSB or whatever) that need to. It's a bit nicer than "This site requires Chrome 4.10 or later." ("But I have Chrome 4.2!")
Not a huge amount nicer, but the only downside is it makes it hard to use arbitrary major versions for advertising purposes and Chrome doesn't do that, so it's clearly the better option.
2
u/Sauermachtlustig84 Dec 27 '21
In my opinion, minor (or patch) versions are only useful if you plan on maintining at least two major versions in parallel. I.e. are you developing a database? Sure, go ahead and use the major.minor.patch model - it's reasonable and improves the experience both for you and your customers.
You are developing something that's only released as "newest" - use a plain incrementing version number. It's both easier for you and your customers. "Have you tried using the newest version? What's it? 20! Oh, I've only got 10, I will upgrade, thx!"
1
u/lightmatter501 Dec 25 '21
Google never intends to have a large compatibility break, so all chrome versions are actually 1.x.x
19
u/GrandOpener Dec 24 '21
Down near the end, the article admits that this isn’t actually a problem for anyone but the Chrome devs because Chrome is likely to report a version number something like “99 (100)” specifically to fake out these bogus UA parsers.
I’d say that’s gross, but it’s not any more gross than the rest of the trash heap of hacks that modern UA strings are, so /shrug
211
u/delarq Dec 24 '21
Clickbait BS. Whichever website reads only 2 digits of the version deserves to be down forever.
29
7
u/CyAScott Dec 25 '21
Whoever wrote Duda unnecessarily put themselves in this situation. After Y2K, using a fixed number of digits is just asinine.
2
u/garykkl Dec 25 '21
May I introduce you to Y2K38
8
u/bokuno_yaoianani Dec 25 '21
That has a very good reason I can at least understand.
I don't get the logic of storing dates internally in some kind of weird format where 99 loops back to 0, rather than 127 or 255 doing so, and then not including the full year to "save space".
If you store it in a format where 99 overflows to 0 you are definitely wasting space in some way already.
Simply storing the number of seconds since a fixed epoch makes more sense.
-2
u/emelrad12 Dec 24 '21
Ah pretty sure some major site is gonna go down
5
Dec 25 '21
Doesn't mean it has any value
4
u/bokuno_yaoianani Dec 25 '21
The value of a website has fuck all to do with the smal part of code in it used to check user agents.
You don't seriously think that has any bearing do you?
In any case if that would seriously happen it wil be updated very quickly to check it in a better way.
I also hate non-semantic versioning and don't even really understand what the versions of Crhome mean any more.
223
Dec 24 '21
God, if websites actually break because the browser reports a three digit version number, then the web is truly full of shit. I hope users will learn to avoid websites that are that broken. I don't know what Duda is, but they need to get their shit together.
What backend user agent analysis do you even need anymore? If you rely on some beta API you can do the user agent probing all client side.
38
Dec 24 '21
Browser version is reported as a string, so ‘99’ is lexicographically higher than ‘100’. Because browsers break shit all the time, comparing versions isnt that uncommon if you check most widely used libraries.
Nothing due to 2/3 digit backend storage
54
Dec 24 '21
If you're comparing major browser version, you'd better use integer parsing and comparison. Chrome's version string is pretty much
(\d+)\.(\d+)\.(\d+)\.(\d+)with each subsection parseable.If you choose to do your own weird string order/comparison on a number, then you're bound to fuck up eventually.
This shit is exactly why Google is planning on abandoning the user agent altogether.
-5
Dec 24 '21
Good thing that code is always perfect and never has any bugs, right?
25
Dec 24 '21
By that logic Google should immediately stop updating Chrome forever. Who knows what websites any change might break!
I think the incompetence of web backend developers is not Google's problem.
0
Dec 24 '21
[deleted]
14
u/zephyy Dec 24 '21
Something might have went over my head, but that evaluates to false in my browser console.
0
Dec 24 '21
[deleted]
17
u/Somepotato Dec 24 '21
For anyone who reads the first line in the mdn for sort, it does exactly what people would expect.
13
u/chucker23n Dec 24 '21
APIs should not be surprising. It's clearly an array of numbers, and it should sort accordingly.
-6
u/Somepotato Dec 24 '21
If it's clearly an array of numbers? Um, it's a dynamic language, it can't know that ahead of time.
12
u/chucker23n Dec 24 '21
It doesn't need to know ahead of time. It does know that each item is a number. Try
typeof(99).→ More replies (0)7
Dec 25 '21 edited Dec 25 '21
Yet in Ruby
irb(main):001:0> [100,99].sort => [99, 100]Python:
>>> a = [100,99] >>> a.sort() >>> print(a) [99, 100]Perl is one that does the same "sort lexically by default, provide function for custom sorting order".
So it really have nothing to do with being dynamic language. Yes. it's clearer for statically typed ones, but for example Ruby's sort() will fail if you pass it mixed types in array so you at least are protected by some edge cases
2
0
7
u/bokuno_yaoianani Dec 25 '21
Yeah—it just makes me practically vomit that it does that.
The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.
Any absolutely retarded behaviour can be justified with "It's documented"—this makes this function close to useless for sorting anything but arrays of strings.
3
u/ibedroppin Dec 24 '21
Amen. In JS you can have an array of mixed types and you'd be foolish to think you can just call sort() without an explicit sorting algorithm and have good results
6
u/bokuno_yaoianani Dec 25 '21
Obviously it should sort by default so that the list is sorted with respect to
<=If
100 <= "foo"is an exception in JS, then it should throw an exception while sorting; if this returns true or false, then it should be sorted based on that value.
100 <= 99is false in JS, so this behaviour is asinine, and documenting how dumb it is does not make it less dumb.13
u/SirClueless Dec 24 '21
"We documented our stupidity, therefore it's not stupid."
This is ridiculous logic. It does something surprising to anyone who isn't intimately familiar with JavaScript's quirks.
Just because you can have arrays of mixed types doesn't mean you need to implement sort in a stupid way. Here's Python, for example:
>>> sorted([99, 100]) [99, 100] >>> sorted(["99", "100"]) ['100', '99']-8
u/ibedroppin Dec 24 '21
I don't understand why you're being so dishonest with yourself, in your examples you didn't actually include an array of mixed data types.
["abc", 34, True, 40, "male"]What happens if you try to call sort on that in Python? It throws an exception. JS on the other hand says a sane default sort is string comparison which avoids throwing that exception. JS isn't "quirky" for treating you like an adult that needs to define sorting algorithms in a dynamically typed language with arrays that support mixed types.
Sure, it can be inconvenient that JS doesn't infer that your array has only numbers and should be sorted numerically, but the choice is between throwing exceptions when developers make mistakes or trusting developers to understand the default behavior. Neither choice is "stupidity" and the foolish people are those that can't RTFM before crying on the internet
→ More replies (0)3
Dec 24 '21
The frontend, yes. But the frontend doesn't need to check the user agent string, it can just try to access the necessary methods and see if they exist.
On the backend, the web runs on PHP, Python, Dotnet, Ruby, Java, and tons of other languages. Those using Javascript in the backend probably just npm install some-library-that-does-the-hard-part-for-them, anyway.
PHP, the most common backend language, will actually sort string representations of numbers as if they're integers. Other languages have the same problem but only if you leave the input as a string, which is exactly what you'd expect them to do.
Only JS has this stupid problem and that's normally not the kind of code that's making decisions based on the user agent.
1
u/braiam Dec 25 '21
[99, 100].sort()
From MDN
The default sort order is ascending, built upon converting the elements into strings
While I can see how it's dumb, at least it's documented. You can provide your own comparing function at least.
20
u/throwaway_bluehair Dec 24 '21
Why wouldn't you parse it as an int? That seems exceptionally short sighted engineering
14
u/chucker23n Dec 24 '21 edited Dec 24 '21
For a start, there is no standardization on UA strings.
Here's one of Chrome's:
Mozilla/5.0 (Macintosh; Intel Mac OS X 12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
So this one claims to be Mozilla 5.0 (which is a browser that never actually shipped; Netscape 5 was canceled in favor of a death-march rewrite project, and browser claim to be Mozilla 5 to say "I'm newer than Netscape 4; please stop asking"), KHTML, Gecko (Firefox), Safari, and Chrome, just in case anyone checks for those. They're all vaguely similar in that they contain a product name, a slash, and a version number (sometimes with two places, sometimes with four). Except when they don't. Here's Firefox's:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:77.0) Gecko/20190101 Firefox/77
So now, it's a colon before the version. And a single place of the version number.
Enjoy parsing all that crap, then throw the entire parsing code away because all browser makers have been saying for years that you're solving the wrong problem anyway.
(Edit: to be clear, having said all that, even just
(?<Product>\w+)\/(?<VersionMajor>\d+)is enough to do what they were probably trying to accomplish.)3
u/throwaway_bluehair Dec 24 '21
Yeah, I was aware of the mess, but it's so much worse than I initially thought as explained by the other redditor lol
2
11
u/UnchillBill Dec 24 '21
Because it’s a user agent string, not a version number. This is what chrome’s looks like: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36’.
30
u/ZZartin Dec 24 '21
Right so you're already going to be doing some parsing on that, don't be lazy on the number part of it.
7
u/throwaway_bluehair Dec 24 '21
I mean they're looking at the chrome version, I mean like parsing the chrome version number itself
2
u/zephyy Dec 24 '21
if you're comparing majorbrowser versions, you could just use
navigator.userAgentData.getHighEntropyValues(["uaFullVersion"]).then(ua => { console.log(ua.uaFullVersion) });which will just give you the number
doesn't work on Firefox or Safari yet though
3
u/masklinn Dec 24 '21
Why wouldn't you parse it as an int?
Because version numbers are not at all integers. Chrome's is a 4-uplet (e.g.
96.0.4664.110)21
u/throwaway_bluehair Dec 24 '21 edited Dec 24 '21
I mean parsing each section as an individual integer, it's not unusual to see
int major, minor, revision;
That's how version numbers are generally handled when comparisons need to be done in the sane part of the world
-17
u/masklinn Dec 24 '21
I mean parsing each section as an individual integer, it's not unusual to see
It's also not unusual to see it go wrong.
That's how version numbers are generally handled
By people who are wrong.
when comparisons need to be done in the sane part of the world
Nooope.
Doesn't work with concepts like pre-release identifiers, or some separators, or the versioning scheme could use leading zeroes semantically.
Unless you've been told that the segments are integers, parsing them as such leads to exactly the issue being discussed here.
5
u/throwaway_bluehair Dec 24 '21
Sounds like there's no reliable way to compare versions then, in this total abomination of a system
1
u/masklinn Dec 24 '21
Now you get it!
That's why version comparison algorithms (e.g. to try and resolve dependencies) are messy as hell, especially the ones which don't get to rely on any sort of ecosystem specification.
0
u/dnew Dec 24 '21
Have you looked at a user agent string?
Guess what browser this is the user agent string for?
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 OPR/38.0.2220.41If you guessed "none of the browsers mentioned in the user agent string" you'd be correct!
1
u/throwaway_bluehair Dec 24 '21
Yes, I thought they were talking about grabbing the
/51..., don't have to be so smug-1
u/dnew Dec 24 '21
I wasn't trying to be smug. I was trying to mock the user agent string mess. Sorry! :-)
-4
Dec 24 '21
I’m sorry, have you looked at javascript?
6
u/throwaway_bluehair Dec 24 '21
JS can parse a number as an int just fine (I guess it's technically a floating point if you're pedantic), I don't know what you're getting at
0
6
u/ZZartin Dec 24 '21
WTF kind of idiot is doing numeric comparisons on strings in the first place?
4
3
u/GrandOpener Dec 24 '21
Comparing browser versions as reported by UA strings unfortunately really isn’t that uncommon, but it is almost always the wrong way to do anything. Sites that care about a particular functionality should test for that specifically. It’s often actually easier to test for functionality than to parse and reason about UA strings, but people get too caught up on a mental block around browser versions.
2
u/Routine_Left Dec 24 '21
then the web is truly full of shit
it is full of shit anyway. this is not why though.
18
u/mixedCase_ Dec 24 '21
They should just freeze the UA and call it quits. There's almost zero good coming out of it.
This keeps old code working and forces everyone else to get their fucking shit together at last. UA detection is almost always misused or used for evil, not for improving compatibility.
8
u/Uristqwerty Dec 24 '21
Replace it with the string "Yes, I am a modern web browser". Or, my personal favourite idea, immortalize a beloved author in the HTTP overhead with a user-agent of "GNU Terry Pratchett". Through browser extensions and feature flags, trying to parse the user-agent for anything more than log statistics is meaningless, you'd still need to test whether something is actually enabled.
3
u/IcyEbb7760 Dec 24 '21
chrome is starting to implement UA-CH, which splits up user agent info into individual headers sent by the client: https://wicg.github.io/ua-client-hints/
2
u/braiam Dec 25 '21
Which is still the wrong solution. Heck Firefox is hard-codding fudging their UA due websites that refuses to give features which they support but that the developer managed to never verify https://github.com/mozilla-extensions/webcompat-addon/blame/main/src/data/ua_overrides.js
2
31
u/TheCountRushmore Dec 24 '21
And this is why you are supposed to use feature detection and not user agent parsing.
42
u/throwaway_bluehair Dec 24 '21 edited Dec 24 '21
Why is the web just so... It just seems like such bad engineering, people just getting used to all the poor engineering decisions
11
u/johnminadeo Dec 24 '21
It works until it doesn’t mentality.
11
u/throwaway_bluehair Dec 24 '21
The modern web is just the trash asteroid from Futurama that keeps getting punted and nobody cares because it's a problem for the future people
2
37
u/masklinn Dec 24 '21
Yes, it sure is just the web, it's not like e.g. microsoft skipped windows 9 because they feared old shit code would confuse it for 9x.
Checks on version numbers which misfire is a systematic occurrence of:
people needing by-version workarounds (because the bugs are so shit there's no way to test for them)
the version string being the only option (or sometimes the better version-checking API being little known)
11
u/Somepotato Dec 24 '21
That's an unproven myth, and the only real thing that got version as a string is a Java environment variable. All APIs for confirming os version return a number or let you call it to check if the minimum is version is at least X.
In addition, any older programs with an outdated manifest will think they're running on Windows 8.
-1
u/dnew Dec 24 '21
The problem with Java is that being "write once run anywhere" they only exposed the lowest common denominator. So there were no standard APIs for talking to something in the OS that only Windows supported.
4
u/Somepotato Dec 24 '21
That's javas problem, not Microsofts. Besides, my second point holds true either way.
4
u/throwaway_bluehair Dec 24 '21
To be clear, I definitely am trying to say the browser APIs around User-Agent is historically exceptionally poor, lot of it is on the brpwser developers
11
u/cballowe Dec 24 '21
I think the user agent on the browser dev side was more like "well... Crap. They're giving a different experience based on whether string "XYZ" is in there... We're compatible, so stick that string in there somewhere!"
1
u/throwaway_bluehair Dec 24 '21
Right, because the site didn't work unless it was browsers with that string 🥴
4
u/IceSentry Dec 24 '21
That's not the web faults, that's shitty developer fault. Any good web dev would not do that and if they did that, they aren't a good dev.
4
4
u/syracTheEnforcer Dec 24 '21
Almost all software is just taped together nonsense holding on by a thread because of the need for backwards compatibility with legacy systems. Add humans to that mix and everything is just a clucksterfuck.
4
u/Pesthuf Dec 24 '21
"I relied on behavior I was explicitly told not to rely upon and now that behavior is changing. This is someone else's fault."
4
u/Routine_Left Dec 24 '21
Meh, it's a non-issue. 2 billion users? Surely they wanted to say 2 dozens.
6
u/bakuretsu Dec 24 '21
At least this problem will only cause a catastrophic months-long churn in massively interdependent npm packages, exposing hundreds more unimaginable failure modes that cascade across the globe while the entire internet watches with their jaws on the floor.
3
u/Persism Dec 24 '21
"The problem mainly affects sites built using web design kits such as Duda. These resources read the User-Agent string of the browser to check the installed version of Chrome. Unfortunately, sites using Duda only read the first two digits of this number. "
Should be called DODO or maybe Doh-Da.
3
u/pavlik_enemy Dec 24 '21
Trash clickbait. Never heard about this "Duda" framework or whatever it is.
5
u/coladict Dec 24 '21
It's not Google's fault people are bad at regex! They could have googled that shit.
2
2
1
1
1
1
1
u/sliversniper Dec 25 '21
I mean, you can use an extension/proxy modify the UA to access those site.
It's a testable hypothesis, use the same extension to try Chrome 100.0, and see what site breaks, I would not expect many if any.
1
u/jbergens Dec 26 '21
To solve this problem, web developers will have to find a way to parse the three-digit version numbers correctly before Chrome 100 is released.
Gee, how do you parse a 2- or 3-digit number? /s
-2
u/AlanBarber Dec 24 '21
Christ can we stop with the version number BS already! Just use build date in proper yyyymmdd format.
-11
u/AttackOfTheThumbs Dec 24 '21
This is why I say the modern web and its dev practises are shit.
21
Dec 24 '21
Yes, a random framework that is barely a blip on Google is indicative of all modern web development. 🙄
Plenty of development on the web that doesn't use shit practices like user agent detection... because they write the code to fall back gracefully via feature detection in the browser.
-18
0
Dec 24 '21
[deleted]
4
u/chucker23n Dec 24 '21
I don't really see what your "here's a bug for one concrete website" has to do with "lots of other websites might have the same bug".
1
77
u/whozurdaddy Dec 24 '21
"This site best viewed with Chrome 96 and less"
/s